[Bug target/78438] [7 Regression] incorrect comparison optimization
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78438 --- Comment #7 from Segher Boessenkool --- Author: segher Date: Wed Nov 23 14:33:13 2016 New Revision: 242757 URL: https://gcc.gnu.org/viewcvs?rev=242757&root=gcc&view=rev Log: combine: Convert subreg-of-lshiftrt to zero_extract properly (PR78390) r242414, for PR77881, introduces some bugs (PR78390, PR78438, PR78477). It all has the same root cause: that patch makes combine convert every lowpart subreg of a logical shift right to a zero_extract. This cannot work at all if it is not a constant shift, and it has to be a bit more careful exactly which bits it extracts. PR target/77881 PR bootstrap/78390 PR target/78438 PR bootstrap/78477 * combine.c (make_compound_operation_int): Do not convert a subreg of a non-constant logical shift right to a zero_extract. Handle the case where some zero bits have been shifted into the range covered by that subreg. Modified: trunk/gcc/ChangeLog trunk/gcc/combine.c
[Bug target/78438] [7 Regression] incorrect comparison optimization
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78438 --- Comment #6 from Segher Boessenkool --- n/m, too tired I guess, please ignore comment 5.
[Bug target/78438] [7 Regression] incorrect comparison optimization
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78438 --- Comment #5 from Segher Boessenkool --- Why is this wrong? This isn't the same reg 94 (it is reused): Failed to match this instruction: (set (mem/c:QI (symbol_ref:DI ("a") [flags 0x2] ) [0 a+0 S1 A8]) (subreg:QI (ashiftrt:SI (reg:SI 93 [ b ]) (const_int 26 [0x1a])) 0)) Successfully matched this instruction: (set (reg:SI 94) (ashiftrt:SI (reg:SI 93 [ b ]) (const_int 26 [0x1a]))) Successfully matched this instruction: (set (mem/c:QI (symbol_ref:DI ("a") [flags 0x2] ) [0 a+0 S1 A8]) (subreg:QI (reg:SI 94) 0)) The low 8 bits of r93 a>> 26 are exactly what we need to store afaics?
[Bug target/78438] [7 Regression] incorrect comparison optimization
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78438 Jeffrey A. Law changed: What|Removed |Added Priority|P3 |P1 CC||law at redhat dot com
[Bug target/78438] [7 Regression] incorrect comparison optimization
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78438 Jakub Jelinek changed: What|Removed |Added Status|ASSIGNED|NEW --- Comment #4 from Jakub Jelinek --- Oops, #c3 was meant for PR78436.
[Bug target/78438] [7 Regression] incorrect comparison optimization
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78438 Jakub Jelinek changed: What|Removed |Added Status|NEW |ASSIGNED --- Comment #3 from Jakub Jelinek --- The over-sized bitfield isn't really needed for this, making it more severe: struct S { long int : 23; long int a : 24; long int b : 10; long int c : 24; signed char d : 8; } s; __attribute__((noinline, noclone)) void foo () { s.d = 0; s.c = -1193165L; } int main () { foo (); if (s.d != 0) __builtin_abort (); return 0; }
[Bug target/78438] [7 Regression] incorrect comparison optimization
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78438 --- Comment #2 from Jakub Jelinek --- Before combine we have: (insn 6 5 7 2 (parallel [ (set (reg:SI 92) (ashiftrt:SI (reg:SI 93 [ b ]) (const_int 11 [0xb]))) (clobber (reg:CC 17 flags)) ]) "pr78438.c":7 563 {*ashrsi3_1} (expr_list:REG_DEAD (reg:SI 93 [ b ]) (expr_list:REG_UNUSED (reg:CC 17 flags) (expr_list:REG_EQUAL (ashiftrt:SI (mem/c:SI (symbol_ref:DI ("b") [flags 0x2] ) [1 b+0 S4 A32]) (const_int 11 [0xb])) (nil) (insn 7 6 8 2 (parallel [ (set (reg:HI 94) (lshiftrt:HI (subreg:HI (reg:SI 92) 0) (const_int 15 [0xf]))) (clobber (reg:CC 17 flags)) ]) "pr78438.c":7 572 {*lshrhi3_1} (expr_list:REG_DEAD (reg:SI 92) (expr_list:REG_UNUSED (reg:CC 17 flags) (nil combine turns that into non-equivalent: (insn 7 6 8 2 (parallel [ (set (reg:SI 94) (ashiftrt:SI (reg:SI 93 [ b ]) (const_int 26 [0x1a]))) (clobber (reg:CC 17 flags)) ]) "pr78438.c":7 563 {*ashrsi3_1} (expr_list:REG_UNUSED (reg:CC 17 flags) (expr_list:REG_DEAD (reg:SI 93 [ b ]) (nil
[Bug target/78438] [7 Regression] incorrect comparison optimization
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78438 Jakub Jelinek changed: What|Removed |Added Status|UNCONFIRMED |NEW Last reconfirmed||2016-11-21 CC||jakub at gcc dot gnu.org Target Milestone|--- |7.0 Summary|incorrect comparison|[7 Regression] incorrect |optimization|comparison optimization Ever confirmed|0 |1 --- Comment #1 from Jakub Jelinek --- Started with r242414. Simplified testcase: char a = 0; int b = 197412621; __attribute__ ((noinline, noclone)) void foo () { a = 0 > (short) (b >> 11); } int main () { asm volatile ("" : : : "memory"); foo (); if (a != 0) __builtin_abort (); return 0; }