aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenModule.cpp
diff options
context:
space:
mode:
authorValery Pykhtin <valery.pykhtin@gmail.com>2023-11-13 15:37:55 +0100
committerGitHub <noreply@github.com>2023-11-13 15:37:55 +0100
commitf054947c0da99ec8b3c4bb043e5225672420a313 (patch)
tree859bf6f667255404390e5ad445b0982385c8b13b /clang/lib/CodeGen/CodeGenModule.cpp
parentdde85f86919bdf7f4ffc865f1edfa2750caf4570 (diff)
downloadllvm-f054947c0da99ec8b3c4bb043e5225672420a313.zip
llvm-f054947c0da99ec8b3c4bb043e5225672420a313.tar.gz
llvm-f054947c0da99ec8b3c4bb043e5225672420a313.tar.bz2
[SimplifyCFG] Prevent merging cbranch to cbranch if the branch probability from the first to second is too low. (#69375)
AMDGPU target has faced the situation which can be illustrated with the following testcase: define void @dont_merge_cbranches(i32 %V) { %divergent_cond = icmp ne i32 %V, 0 %uniform_cond = call i1 @uniform_result(i1 %divergent_cond) br i1 %uniform_cond, label %bb2, label %exit, !prof !0 bb2: br i1 %divergent_cond, label %bb3, label %exit bb3: call void @bar( ) br label %exit exit: ret void } !0 = !{!"branch_weights", i32 1, i32 100000} SimplifyCFG merges branches on %uniform_cond and %divergent_cond which is undesirable because the first branch to bb2 is taken extremely rare and the second branch is expensive. The merged branch becomes as expensive as the second. This patch prevents such merging if the branch to the second branch is unlikely to happen.
Diffstat (limited to 'clang/lib/CodeGen/CodeGenModule.cpp')
0 files changed, 0 insertions, 0 deletions