[llvm] [InstCombine] Canonicalize `switch(X^C)` expressions to `switch(X)` (PR #143677)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 13 01:22:37 PDT 2025
dtcxzyw wrote:
> > From llvm-opt-benchmark, a potential problem is that this can something turn small switch values into very large ones -- the common case is a xor by INT_MIN. I haven't checked how this affects codegen.
>
> When not invoking the middle-end (except for SimplifyCFG, was not expecting llc to invoke it), the codegen looks slightly worse both in the optimized and unoptimized case: https://llvm.godbolt.org/z/jceqnev4n. Not sure if we wish to proceed further with the canonicalization :(
I think it is ok to perform this canonicalization as it doesn't break the `density` of switch cases (i.e., reverting SimplifyCFG transforms). As for the regression, it can be fixed by canonicalizing `sub X, INT_MIN -> xor X, INT_MIN`: https://alive2.llvm.org/ce/z/UGblFI
https://github.com/llvm/llvm-project/pull/143677
More information about the llvm-commits
mailing list