[Bug middle-end/107443] [10/11/12/13 Regression] Removing switch with __builtin_unreachable causes missed optimizations
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107443 Richard Biener changed: What|Removed |Added Priority|P3 |P2
[Bug middle-end/107443] [10/11/12/13 Regression] Removing switch with __builtin_unreachable causes missed optimizations
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107443 Richard Biener changed: What|Removed |Added CC||marxin at gcc dot gnu.org, ||rguenth at gcc dot gnu.org --- Comment #2 from Richard Biener --- I think we simply "optimize" the switch instead of, like for the if, preserving the range asserting side-effect until some point in the compilation. Ideally switch conversion would turn the switch side-effect into a single if. But I also think the testcase is somewhat artificial so I wonder if we should worry here at all ...
[Bug middle-end/107443] [10/11/12/13 Regression] Removing switch with __builtin_unreachable causes missed optimizations
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=107443 Andrew Pinski changed: What|Removed |Added Target Milestone|--- |10.5 Last reconfirmed||2022-10-27 Ever confirmed|0 |1 Status|UNCONFIRMED |NEW Known to fail||8.1.0 Summary|Switch conversion removing |[10/11/12/13 Regression] |code|Removing switch with ||__builtin_unreachable ||causes missed optimizations Known to work||7.1.0 --- Comment #1 from Andrew Pinski --- Testcase which shows this is a regression and switch conversion just exposed it: void dead (unsigned n); void foo (unsigned n); void func (unsigned n) { switch(n) { case 0: __builtin_unreachable(); case 1: __builtin_unreachable(); case 2: __builtin_unreachable(); case 3: __builtin_unreachable(); case 4: __builtin_unreachable(); case 5: __builtin_unreachable(); case 6: __builtin_unreachable(); case 7: __builtin_unreachable(); default: ; } foo (n); if (n < 8) dead (n); } after building the CFG we get with the above testcase: Removing basic block 10 Removing basic block 9 Removing basic block 8 Removing basic block 7 Removing basic block 6 Removing basic block 5 Removing basic block 4 Removing basic block 3 Merging blocks 2 and 11