[llvm] 4c5702c - Fix bug introduced with 6f34839 (poison flags on floating point ops)

Philip Reames via llvm-commits llvm-commits at lists.llvm.org
Tue Oct 12 20:28:37 PDT 2021


Author: Philip Reames
Date: 2021-10-12T20:25:00-07:00
New Revision: 4c5702cb123b8fd705982c638fb18c999f69d63a

URL: https://github.com/llvm/llvm-project/commit/4c5702cb123b8fd705982c638fb18c999f69d63a
DIFF: https://github.com/llvm/llvm-project/commit/4c5702cb123b8fd705982c638fb18c999f69d63a.diff

LOG: Fix bug introduced with 6f34839 (poison flags on floating point ops)

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.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Analysis/ValueTracking.cpp b/llvm/lib/Analysis/ValueTracking.cpp
index e5b1b2423845c..ece7c88fb3466 100644
--- a/llvm/lib/Analysis/ValueTracking.cpp
+++ b/llvm/lib/Analysis/ValueTracking.cpp
@@ -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();

diff  --git a/llvm/test/Transforms/InstCombine/freeze.ll b/llvm/test/Transforms/InstCombine/freeze.ll
index 981d671fbcfe9..a2c788098ff32 100644
--- a/llvm/test/Transforms/InstCombine/freeze.ll
+++ b/llvm/test/Transforms/InstCombine/freeze.ll
@@ -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
+}


        


More information about the llvm-commits mailing list