[PATCH] D104569: [SimplifyCFG] Fix SimplifyBranchOnICmpChain to be undef/poison safe.
Hyeongyu Kim via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 18 14:25:12 PDT 2021
hyeongyukim created this revision.
Herald added a subscriber: hiraditya.
hyeongyukim requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.
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
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D104569
Files:
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
llvm/test/Transforms/SimplifyCFG/switch_create-custom-dl.ll
llvm/test/Transforms/SimplifyCFG/switch_create.ll
llvm/test/Transforms/SimplifyCFG/switch_msan.ll
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D104569.353099.patch
Type: text/x-patch
Size: 9953 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210618/67e71667/attachment.bin>
More information about the llvm-commits
mailing list