[llvm] [SandboxVec][BottomUpVec] Generate vector instructions (PR #115087)

Jorge Gorbe Moya via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 5 15:48:57 PST 2024


================
@@ -66,6 +66,40 @@ class VecUtils {
     }
     return true;
   }
+
+  /// \Returns the number of vector lanes of \p Ty or 1 if not a vector.
+  /// NOTE: It asserts that \p Ty is a fixed vector type.
+  static unsigned getNumLanes(Type *Ty) {
+    assert(!isa<ScalableVectorType>(Ty) && "Expect fixed vector");
+    if (!isa<FixedVectorType>(Ty))
+      return 1;
+    return cast<FixedVectorType>(Ty)->getNumElements();
+  }
+
+  /// \Returns the expected vector lanes of \p V or 1 if not a vector.
+  /// NOTE: It asserts that \p V is a fixed vector.
+  static int getNumLanes(Value *V) {
----------------
slackito wrote:

Nit: return `unsigned` to match the return type of `VecUtils::getNumLanes(Type*)`

https://github.com/llvm/llvm-project/pull/115087


More information about the llvm-commits mailing list