[PATCH] D120827: [VPlan] Helper to check if a recipe only uses scalar values of op.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 9 12:48:52 PST 2022


fhahn updated this revision to Diff 414190.
fhahn marked an inline comment as done.
fhahn added a comment.

Address comments, thanks!

In D120827#3370915 <https://reviews.llvm.org/D120827#3370915>, @Ayal wrote:

> Perhaps drop "only" - "usesScalars()" instead of "onlyScalarsUsed()"? As opposed to usesVectors.

Adjusted, thanks!


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D120827

Files:
  llvm/lib/Transforms/Vectorize/VPlan.h


Index: llvm/lib/Transforms/Vectorize/VPlan.h
===================================================================
--- llvm/lib/Transforms/Vectorize/VPlan.h
+++ llvm/lib/Transforms/Vectorize/VPlan.h
@@ -772,6 +772,13 @@
            "Op must be an operand of the recipe");
     return false;
   }
+
+  /// Returns true if the recipe only uses scalars of operand \p Op.
+  virtual bool usesScalars(const VPValue *Op) const {
+    assert(is_contained(operands(), Op) &&
+           "Op must be an operand of the recipe");
+    return onlyFirstLaneUsed(Op);
+  }
 };
 
 inline bool VPUser::classof(const VPDef *Def) {
@@ -1558,6 +1565,13 @@
            "Op must be an operand of the recipe");
     return isUniform();
   }
+
+  /// Returns true if the recipe only uses scalars of operand \p Op.
+  bool usesScalars(const VPValue *Op) const override {
+    assert(is_contained(operands(), Op) &&
+           "Op must be an operand of the recipe");
+    return true;
+  }
 };
 
 /// A recipe for generating conditional branches on the bits of a mask.
@@ -1626,6 +1640,13 @@
   void print(raw_ostream &O, const Twine &Indent,
              VPSlotTracker &SlotTracker) const override;
 #endif
+
+  /// Returns true if the recipe only uses scalars of operand \p Op.
+  bool usesScalars(const VPValue *Op) const override {
+    assert(is_contained(operands(), Op) &&
+           "Op must be an operand of the recipe");
+    return true;
+  }
 };
 
 /// A Recipe for widening load/store operations.
@@ -1895,6 +1916,14 @@
   VPCanonicalIVPHIRecipe *getCanonicalIV() const;
   VPValue *getStartValue() const { return getOperand(1); }
   VPValue *getStepValue() const { return getOperand(2); }
+
+  /// Returns true if the recipe only uses the first lane of operand \p Op.
+  /// Conservatively returns false.
+  bool onlyFirstLaneUsed(const VPValue *Op) const override {
+    assert(is_contained(operands(), Op) &&
+           "Op must be an operand of the recipe");
+    return true;
+  }
 };
 
 /// VPBasicBlock serves as the leaf of the Hierarchical Control-Flow Graph. It


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D120827.414190.patch
Type: text/x-patch
Size: 2062 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20220309/f8f4b7c0/attachment.bin>


More information about the llvm-commits mailing list