From 45acde2fe01cea0e2e11dda9d336133c5b526f6d Mon Sep 17 00:00:00 2001 From: Uros Bizjak Date: Sun, 7 Apr 2019 21:19:08 +0200 Subject: [PATCH] re PR target/89945 (ICE in gen_lowpart_general, at rtlhooks.c:63) PR target/89945 * config/i386/i386.md (anddi_1 to andsi_1_zext splitter): Avoid calling gen_lowpart with SYMBOL_REF and LABEL_REF operand. testsuite/ChangeLog: PR target/89945 * gcc.target/i386/pr89945.c: New test. From-SVN: r270190 --- gcc/ChangeLog | 6 ++++++ gcc/config/i386/i386.md | 11 ++++++++++- gcc/testsuite/ChangeLog | 5 +++++ gcc/testsuite/gcc.target/i386/pr89945.c | 21 +++++++++++++++++++++ 4 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr89945.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index f4075784288..778c70af280 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2019-04-07 Uroš Bizjak + + PR target/89945 + * config/i386/i386.md (anddi_1 to andsi_1_zext splitter): + Avoid calling gen_lowpart with SYMBOL_REF and LABEL_REF operand. + 2019-04-05 Joern Rennecke * sched-deps.c (sched_macro_fuse_insns): Check return value of diff --git a/gcc/config/i386/i386.md b/gcc/config/i386/i386.md index 46277f158bb..0fe778fda92 100644 --- a/gcc/config/i386/i386.md +++ b/gcc/config/i386/i386.md @@ -8609,7 +8609,16 @@ [(parallel [(set (match_dup 0) (zero_extend:DI (and:SI (match_dup 1) (match_dup 2)))) (clobber (reg:CC FLAGS_REG))])] - "operands[2] = gen_lowpart (SImode, operands[2]);") +{ + if (GET_CODE (operands[2]) == SYMBOL_REF + || GET_CODE (operands[2]) == LABEL_REF) + { + operands[2] = shallow_copy_rtx (operands[2]); + PUT_MODE (operands[2], SImode); + } + else + operands[2] = gen_lowpart (SImode, operands[2]); +}) ;; See comment for addsi_1_zext why we do use nonimmediate_operand (define_insn "*andsi_1_zext" diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4208625d09e..50ac61c649d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,8 @@ +2019-04-07 Uroš Bizjak + + PR target/89945 + * gcc.target/i386/pr89945.c: New test. + 2019-04-06 Thomas Koenig PR fortran/87352 diff --git a/gcc/testsuite/gcc.target/i386/pr89945.c b/gcc/testsuite/gcc.target/i386/pr89945.c new file mode 100644 index 00000000000..39e864a9d65 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr89945.c @@ -0,0 +1,21 @@ +/* PR target/89945 */ +/* { dg-do compile } */ +/* { dg-options "-O2" } */ + +void +foo () +{ + void *g[] = {&&a, &&b}; + + for (unsigned c = 0x1F;; c >>= 1) + { + unsigned d = (long)"a"; + long e = 8; + + while (e) + { + a: goto *g[c&d]; + b: e--; + } + } +} -- 2.30.2