[llvm] 00bc500 - [VPlan] Store FPBinOp directly in VPDerivedIVRecipe (NFCI).

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 14 13:45:40 PDT 2023


Author: Florian Hahn
Date: 2023-08-14T21:45:19+01:00
New Revision: 00bc5008307c3e9daccf5cbc08ee875c74c25431

URL: https://github.com/llvm/llvm-project/commit/00bc5008307c3e9daccf5cbc08ee875c74c25431
DIFF: https://github.com/llvm/llvm-project/commit/00bc5008307c3e9daccf5cbc08ee875c74c25431.diff

LOG: [VPlan] Store FPBinOp directly in VPDerivedIVRecipe (NFCI).

Address post-commit simplification suggestion for 8a56179bcd8c:
Store operator only for floating point inductions (i.e. the binary op is
a FPMathOperator).

Added: 
    

Modified: 
    llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
    llvm/lib/Transforms/Vectorize/VPlan.h

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
index 589c8ac0676985..0241641e34f883 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
@@ -9479,14 +9479,14 @@ void VPDerivedIVRecipe::execute(VPTransformState &State) {
 
   // Fast-math-flags propagate from the original induction instruction.
   IRBuilder<>::FastMathFlagGuard FMFG(State.Builder);
-  if (BinOp && isa<FPMathOperator>(BinOp))
-    State.Builder.setFastMathFlags(BinOp->getFastMathFlags());
+  if (FPBinOp)
+    State.Builder.setFastMathFlags(FPBinOp->getFastMathFlags());
 
   Value *Step = State.get(getStepValue(), VPIteration(0, 0));
   Value *CanonicalIV = State.get(getCanonicalIV(), VPIteration(0, 0));
-  Value *DerivedIV = emitTransformedIndex(State.Builder, CanonicalIV,
-                                          getStartValue()->getLiveInIRValue(),
-                                          Step, Kind, BinOp);
+  Value *DerivedIV = emitTransformedIndex(
+      State.Builder, CanonicalIV, getStartValue()->getLiveInIRValue(), Step,
+      Kind, cast_if_present<BinaryOperator>(FPBinOp));
   DerivedIV->setName("offset.idx");
   if (TruncResultTy) {
     assert(TruncResultTy != DerivedIV->getType() &&

diff  --git a/llvm/lib/Transforms/Vectorize/VPlan.h b/llvm/lib/Transforms/Vectorize/VPlan.h
index beb7b5a2956229..0ab0539f5d499f 100644
--- a/llvm/lib/Transforms/Vectorize/VPlan.h
+++ b/llvm/lib/Transforms/Vectorize/VPlan.h
@@ -2143,9 +2143,11 @@ class VPDerivedIVRecipe : public VPRecipeBase, public VPValue {
   /// TruncResultTy.
   Type *TruncResultTy;
 
-  /// Kind and binary operator of the induction.
+  /// Kind of the induction.
   const InductionDescriptor::InductionKind Kind;
-  const BinaryOperator *BinOp;
+  /// If not nullptr, the floating point induction binary operator. Must be set
+  /// for floating point inductions.
+  const FPMathOperator *FPBinOp;
 
 public:
   VPDerivedIVRecipe(const InductionDescriptor &IndDesc, VPValue *Start,
@@ -2153,7 +2155,8 @@ class VPDerivedIVRecipe : public VPRecipeBase, public VPValue {
                     Type *TruncResultTy)
       : VPRecipeBase(VPDef::VPDerivedIVSC, {Start, CanonicalIV, Step}),
         VPValue(this), TruncResultTy(TruncResultTy), Kind(IndDesc.getKind()),
-        BinOp(IndDesc.getInductionBinOp()) {}
+        FPBinOp(dyn_cast_or_null<FPMathOperator>(IndDesc.getInductionBinOp())) {
+  }
 
   ~VPDerivedIVRecipe() override = default;
 


        


More information about the llvm-commits mailing list