diff options
author | Kazu Hirata <kazu@codesourcery.com> | 2006-05-21 15:13:36 +0000 |
---|---|---|
committer | Kazu Hirata <kazu@gcc.gnu.org> | 2006-05-21 15:13:36 +0000 |
commit | 4d49d44d6619d257f7635ef4c449d0b036add018 (patch) | |
tree | 34fe4de54e40acf8897300094b90a362f9af7693 /gcc | |
parent | 6531d1be909aabc40e765eccd6327512528a94bc (diff) | |
download | gcc-4d49d44d6619d257f7635ef4c449d0b036add018.zip gcc-4d49d44d6619d257f7635ef4c449d0b036add018.tar.gz gcc-4d49d44d6619d257f7635ef4c449d0b036add018.tar.bz2 |
re PR rtl-optimization/27671 (optimization error on pentium4-Linux with %, regression from gcc-4.1.0)
gcc/
PR rtl-optimization/27671
* simplify-rtx.c (simplify_relational_operation_1): Fix
simplifications of (eq/ne (xor x y) y) and
(eq/ne (xor x y) x).
gcc/testsuite/
PR rtl-optimization/27671
* gcc.c-torture/execute/pr27671-1.c: New.
* gcc.dg/pr27671-2.c: Likewise.
From-SVN: r113955
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/simplify-rtx.c | 15 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 6 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/pr27671-1.c | 21 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/pr27671-2.c | 24 |
5 files changed, 67 insertions, 6 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7bd222e..94ba651 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2006-05-21 Kazu Hirata <kazu@codesourcery.com> + + PR rtl-optimization/27671 + * simplify-rtx.c (simplify_relational_operation_1): Fix + simplifications of (eq/ne (xor x y) y) and + (eq/ne (xor x y) x). + 2006-05-21 Bernhard Fischer <aldot@gcc.gnu.org> * tree-cfg.c: Prune whitespace. diff --git a/gcc/simplify-rtx.c b/gcc/simplify-rtx.c index 962c2de..6ab5cb7 100644 --- a/gcc/simplify-rtx.c +++ b/gcc/simplify-rtx.c @@ -3604,18 +3604,21 @@ simplify_relational_operation_1 (enum rtx_code code, enum machine_mode mode, return simplify_gen_relational (code, mode, cmp_mode, XEXP (op0, 0), XEXP (op0, 1)); - /* (eq/ne (xor x y) x) simplifies to (eq/ne x 0). */ + /* (eq/ne (xor x y) x) simplifies to (eq/ne y 0). */ if ((code == EQ || code == NE) && op0code == XOR && rtx_equal_p (XEXP (op0, 0), op1) - && !side_effects_p (XEXP (op0, 1))) - return simplify_gen_relational (code, mode, cmp_mode, op1, const0_rtx); - /* Likewise (eq/ne (xor x y) y) simplifies to (eq/ne y 0). */ + && !side_effects_p (XEXP (op0, 0))) + return simplify_gen_relational (code, mode, cmp_mode, + XEXP (op0, 1), const0_rtx); + + /* 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, 0))) - return simplify_gen_relational (code, mode, cmp_mode, op1, const0_rtx); + && !side_effects_p (XEXP (op0, 1))) + return simplify_gen_relational (code, mode, cmp_mode, + XEXP (op0, 0), const0_rtx); /* (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 13713e6..11e358a 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2006-05-21 Kazu Hirata <kazu@codesourcery.com> + + PR rtl-optimization/27671 + * gcc.c-torture/execute/pr27671-1.c: New. + * gcc.dg/pr27671-2.c: Likewise. + 2006-05-21 Paul Thomas <pault@gcc.gnu.org> PR fortran/27613 diff --git a/gcc/testsuite/gcc.c-torture/execute/pr27671-1.c b/gcc/testsuite/gcc.c-torture/execute/pr27671-1.c new file mode 100644 index 0000000..dd2982c --- /dev/null +++ b/gcc/testsuite/gcc.c-torture/execute/pr27671-1.c @@ -0,0 +1,21 @@ +/* PR rtl-optimization/27671. + The combiner used to simplify "a ^ b == a" to "a" via + simplify_relational_operation_1 in simplify-rtx.c. */ + +extern void abort (void) __attribute__ ((noreturn)); +extern void exit (int) __attribute__ ((noreturn)); + +static int __attribute__((noinline)) +foo (int a, int b) +{ + int c = a ^ b; + if (c == a) + abort (); +} + +int +main (void) +{ + foo (0, 1); + exit (0); +} diff --git a/gcc/testsuite/gcc.dg/pr27671-2.c b/gcc/testsuite/gcc.dg/pr27671-2.c new file mode 100644 index 0000000..7882042 --- /dev/null +++ b/gcc/testsuite/gcc.dg/pr27671-2.c @@ -0,0 +1,24 @@ +/* PR rtl-optimization/27671. + The combiner used to simplify "a ^ b == a" to "a" via + simplify_relational_operation_1 in simplify-rtx.c. */ +/* { dg-do run } */ +/* { dg-options "-O1" } */ +/* { dg-options "-O1 -march=pentium4" { target { { i?86-*-* x86_64-*-* } && ilp32 } } } */ + +extern void abort (void) __attribute__ ((noreturn)); +extern void exit (int) __attribute__ ((noreturn)); + +static void __attribute__ ((noinline)) +bar (int k) +{ + int n = k % 2; + if (n == 0) + abort (); +} + +int +main (void) +{ + bar (1); + exit (0); +} |