[PATCH] D140751: Implement a FIXME for better poison handling in SimplifyCFG.
Owen Anderson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 3 21:30:09 PST 2023
resistor updated this revision to Diff 486158.
resistor added a comment.
Update for feedback
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D140751/new/
https://reviews.llvm.org/D140751
Files:
llvm/lib/Transforms/Utils/SimplifyCFG.cpp
Index: llvm/lib/Transforms/Utils/SimplifyCFG.cpp
===================================================================
--- llvm/lib/Transforms/Utils/SimplifyCFG.cpp
+++ llvm/lib/Transforms/Utils/SimplifyCFG.cpp
@@ -319,9 +319,6 @@
assert(IncomingBlocks.size() == 2 &&
"Only for a pair of incoming blocks at the time!");
- // FIXME: it is okay if one of the incoming values is an `undef` value,
- // iff the other incoming value is guaranteed to be a non-poison value.
- // FIXME: it is okay if one of the incoming values is a `poison` value.
return all_of(BB->phis(), [IncomingBlocks, EquivalenceSet](PHINode &PN) {
Value *IV0 = PN.getIncomingValueForBlock(IncomingBlocks[0]);
Value *IV1 = PN.getIncomingValueForBlock(IncomingBlocks[1]);
@@ -330,6 +327,20 @@
if (EquivalenceSet && EquivalenceSet->contains(IV0) &&
EquivalenceSet->contains(IV1))
return true;
+
+ // It is okay if one of the incoming values is a `poison` value.
+ if (isa<PoisonValue>(IV0))
+ return true;
+ if (isa<PoisonValue>(IV1))
+ return true;
+
+ // It is okay if one of the incoming values is an `undef` value, iff the
+ // other incoming value is guaranteed to be a non-poison value.
+ if (isa<UndefValue>(IV0) && isGuaranteedNotToBePoison(IV1))
+ return true;
+ if (isa<UndefValue>(IV1) && isGuaranteedNotToBePoison(IV0))
+ return true;
+
return false;
});
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140751.486158.patch
Type: text/x-patch
Size: 1441 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230104/493221c5/attachment.bin>
More information about the llvm-commits
mailing list