Fix bug introduced with 6f34839 (poison flags on floating point ops)
authorPhilip Reames <listmail@philipreames.com>
Wed, 13 Oct 2021 03:23:22 +0000 (20:23 -0700)
committerPhilip Reames <listmail@philipreames.com>
Wed, 13 Oct 2021 03:25:00 +0000 (20:25 -0700)
The newly introduced API for checking whether poison comes solely from flags which can be dropped was out of sync.  This was noticed by a reviewer post commit.

For the moment, disable the floating point flags.  In a follow up change, I plan to add support in dropPoisonGeneratingFlags, but that deserves to be a change of it's own.

llvm/lib/Analysis/ValueTracking.cpp
llvm/test/Transforms/InstCombine/freeze.ll

index e5b1b24..ece7c88 100644 (file)
@@ -4959,11 +4959,14 @@ static bool canCreateUndefOrPoison(const Operator *Op, bool PoisonOnly,
     if (const auto *ExactOp = dyn_cast<PossiblyExactOperator>(Op))
       if (ExactOp->isExact())
         return true;
-    if (const auto *FP = dyn_cast<FPMathOperator>(Op)) {
-      auto FMF = FP->getFastMathFlags();
-      if (FMF.noNaNs() || FMF.noInfs())
-        return true;
-    }
+  }
+
+  // TODO: this should really be under the ConsiderFlags block, but currently
+  // these are not dropped by dropPoisonGeneratingFlags
+  if (const auto *FP = dyn_cast<FPMathOperator>(Op)) {
+    auto FMF = FP->getFastMathFlags();
+    if (FMF.noNaNs() || FMF.noInfs())
+      return true;
   }
 
   unsigned Opcode = Op->getOpcode();
index 981d671..a2c7880 100644 (file)
@@ -374,3 +374,14 @@ define i8* @propagate_drop_gep2(i8* %arg, i64 %unknown) {
   ret i8* %v1.fr
 }
 
+
+define float @propagate_drop_fadd(float %arg) {
+; CHECK-LABEL: @propagate_drop_fadd(
+; CHECK-NEXT:    [[V1:%.*]] = fadd ninf float [[ARG:%.*]], 2.000000e+00
+; CHECK-NEXT:    [[V1_FR:%.*]] = freeze float [[V1]]
+; CHECK-NEXT:    ret float [[V1_FR]]
+;
+  %v1 = fadd ninf float %arg, 2.0
+  %v1.fr = freeze float %v1
+  ret float %v1.fr
+}