[Bug fortran/86945] [8/9 Regression] BUG with optimisation of select case statement in gfortran
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86945 --- Comment #9 from Richard Biener --- Author: rguenth Date: Wed Aug 22 08:07:36 2018 New Revision: 263761 URL: https://gcc.gnu.org/viewcvs?rev=263761=gcc=rev Log: 2018-08-22 Richard Biener PR tree-optimization/86945 * tree-cfg.c (generate_range_test): Use unsigned arithmetic. * gcc.dg/torture/pr86945.c: New testcase. Added: trunk/gcc/testsuite/gcc.dg/torture/pr86945.c Modified: trunk/gcc/ChangeLog trunk/gcc/testsuite/ChangeLog trunk/gcc/tree-cfg.c
[Bug fortran/86945] [8/9 Regression] BUG with optimisation of select case statement in gfortran
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86945 --- Comment #8 from Richard Biener --- C testcase: void __attribute__((noinline,noipa)) foo(int id) { switch (id) { case (-__INT_MAX__ - 1)...-1: __builtin_abort (); default:; } } int main() { foo(1); return 0; }
[Bug fortran/86945] [8/9 Regression] BUG with optimisation of select case statement in gfortran
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86945 --- Comment #7 from Richard Biener --- With -fsanitize=undefined we get even at -O0 id= 1 : runtime error: signed integer overflow: 1 - -2147483647 cannot be represented in type 'integer(kind=4)' ierr1, OK =0 T : runtime error: signed integer overflow: 1 - -2147483648 cannot be represented in type 'integer(kind=4)' ierr2, OK =0 T so both foo1 and foo2 do not "work".
[Bug fortran/86945] [8/9 Regression] BUG with optimisation of select case statement in gfortran
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86945 Richard Biener changed: What|Removed |Added Priority|P4 |P2 Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org --- Comment #6 from Richard Biener --- Confirmed. Likely caused by CFG cleanup convert_single_case_switch which generates a range test which is done in a signed type: : id.8_1 = CHAIN.11->id; _3 = id.8_1 - -2147483648; _4 = (unsigned int) _3; if (_4 <= 2147483647) when forwprop then combines this we fold (unsigned int) _3 <= 2147483647 to _3 >= 2147483647 which then is folded as id.8_1 - -2147483648 >= 2147483647 which is then folded to id.8_1 >= 2147483647 + -2147483648. But something goes wrong end we end up simplifying it as true.
[Bug fortran/86945] [8/9 Regression] BUG with optimisation of select case statement in gfortran
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=86945 Dominique d'Humieres changed: What|Removed |Added Priority|P3 |P4 Status|UNCONFIRMED |NEW Known to work||7.3.0 Keywords||wrong-code Last reconfirmed||2018-08-16 Ever confirmed|0 |1 Summary|BUG with optimisation of|[8/9 Regression] BUG with |select case statement in|optimisation of select case |gfortran v8.x |statement in gfortran Target Milestone|--- |8.3 Known to fail||8.2.0, 9.0 --- Comment #5 from Dominique d'Humieres --- The bug appeared between revisions r251624 (2017-09-03, OK) and r251946 (2017-09-10, wrong code).