[PATCH] D130408: [Reassociate][NFC] Consistent checking if FastMathFlags are suitable

Warren Ristow via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Jul 24 17:46:56 PDT 2022


This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG3089b411a465: [Reassociate][NFC] Consistent checking for FastMathFlags suitability (authored by wristow).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D130408/new/

https://reviews.llvm.org/D130408

Files:
  llvm/lib/Transforms/Scalar/Reassociate.cpp


Index: llvm/lib/Transforms/Scalar/Reassociate.cpp
===================================================================
--- llvm/lib/Transforms/Scalar/Reassociate.cpp
+++ llvm/lib/Transforms/Scalar/Reassociate.cpp
@@ -147,7 +147,7 @@
 /// Instruction::isAssociative() because it includes operations like fsub.
 /// (This routine is only intended to be called for floating-point operations.)
 static bool hasFPAssociativeFlags(Instruction *I) {
-  assert(I && I->getType()->isFPOrFPVectorTy() && "Should only check FP ops");
+  assert(I && isa<FPMathOperator>(I) && "Should only check FP ops");
   return I->hasAllowReassoc() && I->hasNoSignedZeros();
 }
 
@@ -778,7 +778,7 @@
       Constant *Undef = UndefValue::get(I->getType());
       NewOp = BinaryOperator::Create(Instruction::BinaryOps(Opcode),
                                      Undef, Undef, "", I);
-      if (NewOp->getType()->isFPOrFPVectorTy())
+      if (isa<FPMathOperator>(NewOp))
         NewOp->setFastMathFlags(I->getFastMathFlags());
     } else {
       NewOp = NodesToRewrite.pop_back_val();
@@ -2227,7 +2227,7 @@
 
   // Don't optimize floating-point instructions unless they have the
   // appropriate FastMathFlags for reassociation enabled.
-  if (I->getType()->isFPOrFPVectorTy() && !hasFPAssociativeFlags(I))
+  if (isa<FPMathOperator>(I) && !hasFPAssociativeFlags(I))
     return;
 
   // Do not reassociate boolean (i1) expressions.  We want to preserve the


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D130408.447158.patch
Type: text/x-patch
Size: 1439 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220725/b82217d8/attachment.bin>


More information about the llvm-commits mailing list