[all-commits] [llvm/llvm-project] 4997af: [SimplifyCFG] Simplify nested branches (#97067)
Yingwei Zheng via All-commits
all-commits at lists.llvm.org
Sun Jun 30 12:36:00 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 4997af98a008e71a3df61707559710d1c2769839
https://github.com/llvm/llvm-project/commit/4997af98a008e71a3df61707559710d1c2769839
Author: Yingwei Zheng <dtcxzyw2333 at gmail.com>
Date: 2024-07-01 (Mon, 01 Jul 2024)
Changed paths:
M llvm/lib/Transforms/Utils/SimplifyCFG.cpp
M llvm/test/CodeGen/ARM/and-cmp0-sink.ll
A llvm/test/Transforms/SimplifyCFG/branch-nested.ll
Log Message:
-----------
[SimplifyCFG] Simplify nested branches (#97067)
This patch folds the following pattern (I don't know what to call this):
```
bb0:
br i1 %cond1, label %bb1, label %bb2
bb1:
br i1 %cond2, label %bb3, label %bb4
bb2:
br i1 %cond2, label %bb4, label %bb3
bb3:
...
bb4:
...
```
into
```
bb0:
%cond = xor i1 %cond1, %cond2
br i1 %cond, label %bb4, label %bb3
bb3:
...
bb4:
...
```
Alive2: https://alive2.llvm.org/ce/z/5iOJEL
Closes https://github.com/llvm/llvm-project/issues/97022.
Closes https://github.com/llvm/llvm-project/issues/83417.
I found this pattern in some verilator-generated code, which is widely
used in RTL simulation. This fold will reduces branches and improves the
performance of CPU frontend. To my surprise, this pattern is also common
in C/C++ code base.
Affected libraries/applications:
cmake/cvc5/freetype/git/gromacs/jq/linux/openblas/openmpi/openssl/php/postgres/ruby/sqlite/wireshark/z3/...
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list