From 9d31ea5b56b8d101435315814039876457a8691b Mon Sep 17 00:00:00 2001 From: Richard Sandiford Date: Sun, 7 Sep 2014 08:54:49 +0000 Subject: [PATCH] re PR rtl-optimization/62208 (ICE with -fwhole-program on valid code at -O3 on x86_64-linux-gnu in trunc_int_for_mode, at explow.c:56) gcc/ PR rtl-optimization/62208 * simplify-rtx.c (simplify_relational_operation_1): Use CONST0_RTX rather than const0_rtx in eq/ne-xor simplifications. gcc/testsuite/ * gcc.target/i386/pr62208.c: New test. From-SVN: r215002 --- gcc/ChangeLog | 6 ++++++ gcc/simplify-rtx.c | 8 ++++---- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.target/i386/pr62208.c | 23 +++++++++++++++++++++++ 4 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 gcc/testsuite/gcc.target/i386/pr62208.c diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 3596380d1c3..e32812cf522 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2014-09-07 Richard Sandiford + + PR rtl-optimization/62208 + * simplify-rtx.c (simplify_relational_operation_1): Use CONST0_RTX + rather than const0_rtx in eq/ne-xor simplifications. + 2014-09-06 Joern Rennecke * config/arc/arc.c (arc_print_operand): Fix format for HOST_WIDE_INT. diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 9478b3c1f1e..32df80d331e 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -4480,16 +4480,16 @@ simplify_relational_operation_1 (enum rtx_code code, enum machine_mode mode, && op0code == XOR && rtx_equal_p (XEXP (op0, 0), op1) && !side_effects_p (XEXP (op0, 0))) - return simplify_gen_relational (code, mode, cmp_mode, - XEXP (op0, 1), const0_rtx); + return simplify_gen_relational (code, mode, cmp_mode, XEXP (op0, 1), + CONST0_RTX (mode)); /* Likewise (eq/ne (xor x y) y) simplifies to (eq/ne x 0). */ if ((code == EQ || code == NE) && op0code == XOR && rtx_equal_p (XEXP (op0, 1), op1) && !side_effects_p (XEXP (op0, 1))) - return simplify_gen_relational (code, mode, cmp_mode, - XEXP (op0, 0), const0_rtx); + return simplify_gen_relational (code, mode, cmp_mode, XEXP (op0, 0), + CONST0_RTX (mode)); /* (eq/ne (xor x C1) C2) simplifies to (eq/ne x (C1^C2)). */ if ((code == EQ || code == NE) diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index dac150700a9..084c0d10455 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2014-09-07 Richard Sandiford + + * gcc.target/i386/pr62208.c: New test. + 2014-09-06 John David Anglin PR testsuite/56194 diff --git a/gcc/testsuite/gcc.target/i386/pr62208.c b/gcc/testsuite/gcc.target/i386/pr62208.c new file mode 100644 index 00000000000..1fc9733b881 --- /dev/null +++ b/gcc/testsuite/gcc.target/i386/pr62208.c @@ -0,0 +1,23 @@ +/* { dg-options "-O3 -fwhole-program -march=x86-64" } */ + +int *a; +unsigned int b; + +void fn2 () +{ + int t[9]; + for (; b; b++) + *a ^= (~t[b] != t[b]); +} + +int fn1 () +{ + fn2 (); + return 0; +} + +int main () +{ + fn1 (); + return 0; +} -- 2.30.2