Open Quuxplusone opened 3 years ago
Bugzilla Link | PR48602 |
Status | NEW |
Importance | P enhancement |
Reported by | David Bolvansky (david.bolvansky@gmail.com) |
Reported on | 2020-12-26 01:37:24 -0800 |
Last modified on | 2020-12-26 02:22:13 -0800 |
Version | trunk |
Hardware | PC Linux |
CC | llvm-bugs@lists.llvm.org, nikita.ppv@gmail.com, spatel+llvm@rotateright.com |
Fixed by commit(s) | |
Attachments | |
Blocks | |
Blocked by | |
See also |
So the proposed optimization here is: If all switch destinations apart from the default are the same, and the number of (non-default) destinations is one less than the size of the switched over value range, then the switch can be converted into a comparison and conditional branch.
What I don't get is how that would bring us to the GCC codegen. It would eliminate the switch, but we'd still have to do something like (load)&3==1, while GCC seems to have dropped the 0x3 mask entirely.
https://gcc.gnu.org/git/?p=gcc.git&a=commit;h=16842d34e7fceebcecc24910e9219a1581fffb32
gcc patch
Also this may help
https://gcc.gnu.org/legacy-ml/gcc-patches/2017-01/msg01936/pr67328-2.patch