[PATCH] D104569: [SimplifyCFG] Fix SimplifyBranchOnICmpChain to be undef/poison safe.
Hyeongyu Kim via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Jun 21 03:49:12 PDT 2021
hyeongyukim added a comment.
entry:
%cmp = icmp ult i8 %c, 33 ; ExtraCase
%cmp4 = icmp eq i8 %c, 46
%or.cond = or i1 %cmp, %cmp4
%cmp9 = icmp eq i8 %c, 44
%or.cond1 = or i1 %or.cond, %cmp9
%cmp14 = icmp eq i8 %c, 58
%or.cond2 = or i1 %or.cond1, %cmp14
%cmp19 = icmp eq i8 %c, 59
%or.cond3 = or i1 %or.cond2, %cmp19
%cmp24 = icmp eq i8 %c, 60
%or.cond4 = or i1 %or.cond3, %cmp24
%cmp29 = icmp eq i8 %c, 62
%or.cond5 = or i1 %or.cond4, %cmp29
%cmp34 = icmp eq i8 %c, 34
%or.cond6 = or i1 %or.cond5, %cmp34
%cmp39 = icmp eq i8 %c, 92
%or.cond7 = or i1 %or.cond6, %cmp39
br i1 %or.cond7, label %lor.end, label %lor.rhs ; BI
====
// Currently isGuaranteedNotToBePoison returns false.
if (!isGuaranteedNotToBePoison(ExtraCase, AC, BI, DT))
ExtraCase = Builder.CreateFreeze(ExtraCase);
`%or.cond7` cannot be poison because `%or.cond7` is a branching condition.
Also, `%cmp` cannot be poison because `%or.cond7` is not poison.
But `isGuaranteedNotToBePosion` is returning false, and an unnecessary freeze is generated.
I think this situation does not appear to be considered in the current implementation of `isGuaranteedNotToBePosion`.
Therefore, it seems that `isGuaranteedNotToBePosion` should be modified so that this case can be dealt with. (I would like to add a code that handles the case when 'CtxI' is a branching instruction.)
Of course, I may have misused `isGuaranteedNotToBePosition`, and if there is anything wrong with me, please let me know.
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D104569/new/
https://reviews.llvm.org/D104569
More information about the llvm-commits
mailing list