[PATCH] D130408: [Reassociate][NFC] Consistent checking if FastMathFlags are suitable
Warren Ristow via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Fri Jul 22 19:39:12 PDT 2022
wristow created this revision.
wristow added reviewers: spatel, RKSimon.
Herald added a subscriber: hiraditya.
Herald added a project: All.
wristow requested review of this revision.
Herald added a project: LLVM.
In D129523 <https://reviews.llvm.org/D129523>, it was noted by @spatel that the approach to check whether
a value can have FastMathFlags was done in different ways, and they
should be made consistent. This patch makes minor changes to fix that.
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.447023.patch
Type: text/x-patch
Size: 1439 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220723/9adbf83c/attachment.bin>
More information about the llvm-commits
mailing list