aboutsummaryrefslogtreecommitdiff
path: root/lldb/unittests/ScriptInterpreter/Python
diff options
context:
space:
mode:
authorKunqiu Chen <camsyn@foxmail.com>2025-11-08 20:52:19 +0800
committerGitHub <noreply@github.com>2025-11-08 20:52:19 +0800
commita0e222f7c7bc7b6de43391fbbdada8d511004b9c (patch)
treeddc94369659b91efff77a36b4ae4f35b3884231d /lldb/unittests/ScriptInterpreter/Python
parentffb5831fceac7dd0af461f0abd0bd66cdc6e77a8 (diff)
downloadllvm-a0e222f7c7bc7b6de43391fbbdada8d511004b9c.zip
llvm-a0e222f7c7bc7b6de43391fbbdada8d511004b9c.tar.gz
llvm-a0e222f7c7bc7b6de43391fbbdada8d511004b9c.tar.bz2
[SimplifyCFG] Simplify uncond br with icmp & select (#165580)
Previously, SimplifyCFG only simplified unconditional branches when they met a pattern (`swicth` -> `icmp` -> `br` -> `phi`) as follows: ```LLVM switch i8 %A, label %DEFAULT [ i8 1, label %end i8 2, label %end ] DEFAULT: %tmp = icmp eq i8 %A, 92 br label %end end: ... = phi i1 [ true, %entry ], [ %tmp, %DEFAULT ], [ true, %entry ] ``` This PR supports a new and more generic pattern (`switch` -> `icmp` -> `select` -> `br` -> `phi` ) to simplify unconditional branches as follows: ```LLVM ; BEFORE case1: switch i32 %x, label %DEFAULT [ i32 0, label %end i32 1, label %case2 ] case2: br label %end DEFAULT: %tmp = icmp eq i32 %x, 2 %val = select i1 %tmp, i32 V3, i32 V4 br label %end end: ... = phi i32 [ V1, %case1 ], [ V2, %case2 ], [ %val, %DEFAULT ] ``` We prefer to split the edge to 'end' so that there are TWO entries of V3/V4 to the PHI, merging the icmp & select into the switch, as follows: ```LLVM ; AFTER case1: switch i32 %x, label %DEFAULT [ i32 0, label %end i32 1, label %case2 i32 2, label %case3 ] case2: br label %end case3: br label %end DEFAULT: br label %end end: ... = phi i32 [ V1, %case1 ], [ V2, %case2 ], [ V3, %case3 ], [ V4, %DEFAULT] ``` Alive2 Proof: https://alive2.llvm.org/ce/z/jYHM4f Promising Optimization Impact: https://github.com/dtcxzyw/llvm-opt-benchmark/pull/3006
Diffstat (limited to 'lldb/unittests/ScriptInterpreter/Python')
0 files changed, 0 insertions, 0 deletions