[all-commits] [llvm/llvm-project] 00871e: [SimplifyCFG] Try to fold switch with single resul...
chenglin.bi via All-commits
all-commits at lists.llvm.org
Thu Apr 14 09:17:46 PDT 2022
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 00871e2f4f9fdebcfe84f998c17c47465079bc67
https://github.com/llvm/llvm-project/commit/00871e2f4f9fdebcfe84f998c17c47465079bc67
Author: chenglin.bi <chenglin.bi at cixcomputing.com>
Date: 2022-04-15 (Fri, 15 Apr 2022)
Changed paths:
M llvm/lib/Transforms/Utils/SimplifyCFG.cpp
M llvm/test/Transforms/SimplifyCFG/switch-to-select-two-case.ll
Log Message:
-----------
[SimplifyCFG] Try to fold switch with single result value and power-of-2 cases to mask+select
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
Reviewed By: spatel
Differential Revision: https://reviews.llvm.org/D122485
More information about the All-commits
mailing list