[llvm] GVN: generalize impliesEquivalence (NFC) (PR #111416)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 10 03:26:11 PDT 2024


https://github.com/artagnon updated https://github.com/llvm/llvm-project/pull/111416

>From 791468d93a4244fbac324765489c97d5ac9bd70c Mon Sep 17 00:00:00 2001
From: Ramkumar Ramachandra <ramkumar.ramachandra at codasip.com>
Date: Mon, 7 Oct 2024 12:20:57 +0100
Subject: [PATCH] GVN: strip bad TODO, FIXME (NFC)

In impliesEquivalenceIfTrue and impliesEquivalenceIfFalse, note that the
optimization is invalid for the no-signed-zeros case: strip the bad
FIXME. Also note that, a ConstantVector would be handled by
select(fcmp()) pattern in InstCombine, and GVN is not the right place
for the optimization: strip the bad TODO.

Alive2 proof: https://alive2.llvm.org/ce/z/vEaK8M
---
 llvm/lib/Transforms/Scalar/GVN.cpp | 8 --------
 1 file changed, 8 deletions(-)

diff --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp
index 2ba600497e00d3..bb75488aebef80 100644
--- a/llvm/lib/Transforms/Scalar/GVN.cpp
+++ b/llvm/lib/Transforms/Scalar/GVN.cpp
@@ -2003,14 +2003,10 @@ static bool impliesEquivalanceIfTrue(CmpInst* Cmp) {
       Value *RHS = Cmp->getOperand(1);
       // If we can prove either side non-zero, then equality must imply
       // equivalence.
-      // FIXME: We should do this optimization if 'no signed zeros' is
-      // applicable via an instruction-level fast-math-flag or some other
-      // indicator that relaxed FP semantics are being used.
       if (isa<ConstantFP>(LHS) && !cast<ConstantFP>(LHS)->isZero())
         return true;
       if (isa<ConstantFP>(RHS) && !cast<ConstantFP>(RHS)->isZero())
         return true;
-      // TODO: Handle vector floating point constants
   }
   return false;
 }
@@ -2029,14 +2025,10 @@ static bool impliesEquivalanceIfFalse(CmpInst* Cmp) {
       Value *RHS = Cmp->getOperand(1);
       // If we can prove either side non-zero, then equality must imply
       // equivalence.
-      // FIXME: We should do this optimization if 'no signed zeros' is
-      // applicable via an instruction-level fast-math-flag or some other
-      // indicator that relaxed FP semantics are being used.
       if (isa<ConstantFP>(LHS) && !cast<ConstantFP>(LHS)->isZero())
         return true;
       if (isa<ConstantFP>(RHS) && !cast<ConstantFP>(RHS)->isZero())
         return true;
-      // TODO: Handle vector floating point constants
   }
   return false;
 }



More information about the llvm-commits mailing list