[PATCH] D140751: Implement a FIXME for better poison handling in SimplifyCFG.

Owen Anderson via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 28 22:07:20 PST 2022


resistor created this revision.
Herald added a subscriber: hiraditya.
Herald added a project: All.
resistor requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

Repository:
  rG LLVM Github Monorepo

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,19 @@
     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) && isGuaranteedNotToBePoison(IV1))
+      return true;
+    if (isa<UndefValue>(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.485581.patch
Type: text/x-patch
Size: 1491 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20221229/b8e062a2/attachment.bin>


More information about the llvm-commits mailing list