When switch with 2^n cases go to one result, check if the 2^n cases can be covered by n bit masks.
If yes we can use "and condition, ~mask" to simplify the switch
case 0 2 4 6 -> and condition, -7
https://alive2.llvm.org/ce/z/jjH_0N
case 0 2 8 10 -> and condition, -11
https://alive2.llvm.org/ce/z/K7E-2V
case 2 4 8 12 -> and (sub condition, 2), -11
https://alive2.llvm.org/ce/z/CrxbYg
Fix one case of https://github.com/llvm/llvm-project/issues/39957
@spatel I'm a little worry about here. I remove the early out this version. It will cause compile time increase if we have some very large switch with many cases to the same result but not the pattern we can fold. But I have no detail data to show how much extra compile this change will be involved. Do we have some common compile time tests?
Another way to do is enlarge MaxCasesPerResult. The patch first version adjust MaxCasesPerResult to 16. But 16 is also a magic number. Maybe we can add a config for it.
How about your suggestions?