[VPlan] Address missed suggestions from D149082.
authorFlorian Hahn <flo@fhahn.com>
Tue, 9 May 2023 14:17:20 +0000 (15:17 +0100)
committerFlorian Hahn <flo@fhahn.com>
Tue, 9 May 2023 14:17:20 +0000 (15:17 +0100)
This address 2 comments missed from D149082. It sets inbounds directly
when creating the GEP and fixes the order in the enum.

llvm/lib/Transforms/Vectorize/VPlan.h
llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

index 95b8371..6392a5a 100644 (file)
@@ -942,8 +942,8 @@ class VPRecipeWithIRFlags : public VPRecipeBase {
   enum class OperationType : unsigned char {
     OverflowingBinOp,
     PossiblyExactOp,
-    FPMathOp,
     GEPOp,
+    FPMathOp,
     Other
   };
   struct WrapFlagsTy {
@@ -1066,6 +1066,12 @@ public:
       break;
     }
   }
+
+  bool isInBounds() const {
+    assert(OpType == OperationType::GEPOp &&
+           "recipe doesn't have inbounds flag");
+    return GEPFlags.IsInBounds;
+  }
 };
 
 /// VPWidenRecipe is a recipe for producing a copy of vector type its
index 596afc9..37b0308 100644 (file)
@@ -835,9 +835,7 @@ void VPWidenGEPRecipe::execute(VPTransformState &State) {
       // Create the new GEP. Note that this GEP may be a scalar if VF == 1,
       // but it should be a vector, otherwise.
       auto *NewGEP = State.Builder.CreateGEP(GEP->getSourceElementType(), Ptr,
-                                             Indices, "");
-      if (auto *I = dyn_cast<GetElementPtrInst>(NewGEP))
-        setFlags(I);
+                                             Indices, "", isInBounds());
       assert((State.VF.isScalar() || NewGEP->getType()->isVectorTy()) &&
              "NewGEP is not a pointer vector");
       State.set(this, NewGEP, Part);