[all-commits] [llvm/llvm-project] e338d0: [SimplifyCFG] Fix SimplifyBranchOnICmpChain to be ...
Hyeongyu Kim via All-commits
all-commits at lists.llvm.org
Mon Jul 12 23:35:33 PDT 2021
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: e338d08ae609bf07b1f43ad15a6488e7c302800b
https://github.com/llvm/llvm-project/commit/e338d08ae609bf07b1f43ad15a6488e7c302800b
Author: hyeongyu kim <gusrb406 at snu.ac.kr>
Date: 2021-07-13 (Tue, 13 Jul 2021)
Changed paths:
M llvm/lib/Transforms/Utils/SimplifyCFG.cpp
M llvm/test/Transforms/SimplifyCFG/switch_create-custom-dl.ll
M llvm/test/Transforms/SimplifyCFG/switch_create.ll
M llvm/test/Transforms/SimplifyCFG/switch_msan.ll
Log Message:
-----------
[SimplifyCFG] Fix SimplifyBranchOnICmpChain to be undef/poison safe.
This patch fixes the problem of SimplifyBranchOnICmpChain that occurs
when extra values are Undef or poison.
Suppose the %mode is 51 and the %Cond is poison, and let's look at the
case below.
```
%A = icmp ne i32 %mode, 0
%B = icmp ne i32 %mode, 51
%C = select i1 %A, i1 %B, i1 false
%D = select i1 %C, i1 %Cond, i1 false
br i1 %D, label %T, label %F
=>
br i1 %Cond, label %switch.early.test, label %F
switch.early.test:
switch i32 %mode, label %T [
i32 51, label %F
i32 0, label %F
]
```
incorrectness: https://alive2.llvm.org/ce/z/BWScX
Code before transformation will not raise UB because %C and %D is false,
and it will not use %Cond. But after transformation, %Cond is being used
immediately, and it will raise UB.
This problem can be solved by adding freeze instruction.
correctness: https://alive2.llvm.org/ce/z/x9x4oY
Reviewed By: nikic
Differential Revision: https://reviews.llvm.org/D104569
More information about the All-commits
mailing list