[Bug rtl-optimization/27671] [4.2 Regression] optimization error on pentium4-Linux with %, regression from gcc-4.1.0
--- Comment #6 from pinskia at gcc dot gnu dot org 2006-05-29 16:09 --- *** Bug 27322 has been marked as a duplicate of this bug. *** -- pinskia at gcc dot gnu dot org changed: What|Removed |Added CC||martin at mpa-garching dot ||mpg dot de http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27671
[Bug rtl-optimization/27671] [4.2 Regression] optimization error on pentium4-Linux with %, regression from gcc-4.1.0
--- Comment #5 from kazu at gcc dot gnu dot org 2006-05-21 15:17 --- Just checked in a patch. -- kazu at gcc dot gnu dot org changed: What|Removed |Added Status|ASSIGNED|RESOLVED Resolution||FIXED http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27671
[Bug rtl-optimization/27671] [4.2 Regression] optimization error on pentium4-Linux with %, regression from gcc-4.1.0
--- Comment #4 from kazu at gcc dot gnu dot org 2006-05-21 15:13 --- Subject: Bug 27671 Author: kazu Date: Sun May 21 15:13:36 2006 New Revision: 113955 URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113955 Log: 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. Added: trunk/gcc/testsuite/gcc.c-torture/execute/pr27671-1.c trunk/gcc/testsuite/gcc.dg/pr27671-2.c Modified: trunk/gcc/ChangeLog trunk/gcc/simplify-rtx.c trunk/gcc/testsuite/ChangeLog -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27671
[Bug rtl-optimization/27671] [4.2 Regression] optimization error on pentium4-Linux with %, regression from gcc-4.1.0
--- Comment #3 from kazu at gcc dot gnu dot org 2006-05-20 19:52 --- Posted a patch. -- kazu at gcc dot gnu dot org changed: What|Removed |Added URL||http://gcc.gnu.org/ml/gcc- ||patches/2006- ||05/msg01034.html http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27671
[Bug rtl-optimization/27671] [4.2 Regression] optimization error on pentium4-Linux with %, regression from gcc-4.1.0
--- Comment #2 from kazu at gcc dot gnu dot org 2006-05-20 04:57 --- The whole problem is reduced to the combiner doing wrong simplification of XOR. Here are some details. Consider: 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); } Note that c == a <==> a ^ b == a <==> b == 0 So foo aborts if and only if b == 0. In the above testcase, b gets 1, so foo shouldn't abort, but it does. The combiner tries to combine the following two insns. (I'm omitting clobbers for brevity.) (set (reg:SI 61) (xor:SI (reg/v:SI 60 [ b ]) (reg/v:SI 59 [ a ]))) (set (reg:CCZ 17 flags) (compare:CCZ (reg:SI 61) (reg/v:SI 59 [ a ]))) The combiner produces (set (reg:CCZ 17 flags) (compare:CCZ (reg/v:SI 59 [ a ]) (const_int 0 [0x0]))) Note that this is wrong. What matters is whether b is 0 or not. Once the problem is reduced to this level, -march=pentium4 is no longer needed. Is is just that with -march=pentium4, "k % 2" is expanded using XOR. -- http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27671
[Bug rtl-optimization/27671] [4.2 Regression] optimization error on pentium4-Linux with %, regression from gcc-4.1.0
-- kazu at gcc dot gnu dot org changed: What|Removed |Added AssignedTo|unassigned at gcc dot gnu |kazu at gcc dot gnu dot org |dot org | Status|NEW |ASSIGNED http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27671
[Bug rtl-optimization/27671] [4.2 Regression] optimization error on pentium4-Linux with %, regression from gcc-4.1.0
--- Comment #1 from pinskia at gcc dot gnu dot org 2006-05-18 21:19 --- Combine is causing the code to turn into: (insn 17 16 18 2 (set (reg:CCGOC 17 flags) (compare:CCGOC (mem/c/i:SI (reg/f:SI 16 argp) [0 k+0 S4 A32]) (const_int 0 [0x0]))) 3 {*cmpsi_ccno_1} (nil) (nil)) -- pinskia at gcc dot gnu dot org changed: What|Removed |Added CC||pinskia at gcc dot gnu dot ||org Status|UNCONFIRMED |NEW Component|regression |rtl-optimization Ever Confirmed|0 |1 Keywords||wrong-code Last reconfirmed|-00-00 00:00:00 |2006-05-18 21:19:13 date|| Summary|optimization error on |[4.2 Regression] |pentium4-Linux with %, |optimization error on |regression from gcc-4.1.0 |pentium4-Linux with %, ||regression from gcc-4.1.0 Target Milestone|--- |4.2.0 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=27671