[PATCH] D140751: Implement a FIXME for better poison handling in SimplifyCFG.
Owen Anderson via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Jan 1 20:29:31 PST 2023
resistor updated this revision to Diff 485840.
resistor added a comment.
Update for comments
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,21 @@
if (EquivalenceSet && EquivalenceSet->contains(IV0) &&
EquivalenceSet->contains(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) && !isa<PoisonValue>(IV0) &&
+ isGuaranteedNotToBePoison(IV1))
+ return true;
+ if (isa<UndefValue>(IV1) && !isa<PoisonValue>(IV1) &&
+ isGuaranteedNotToBePoison(IV0))
+ return true;
+
+ // It is okay if one of the incoming values is a `poison` value.
+ if (isa<PoisonValue>(IV0) && !isa<PoisonValue>(IV1))
+ return true;
+ if (isa<PoisonValue>(IV1) && !isa<PoisonValue>(IV0))
+ return true;
return false;
});
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D140751.485840.patch
Type: text/x-patch
Size: 1561 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20230102/7666a123/attachment.bin>
More information about the llvm-commits
mailing list