[llvm] [llubi] Vector manipulation intrinsics cleanup (PR #195004)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 30 00:56:46 PDT 2026


================
@@ -744,8 +746,20 @@ class InstExecutor : public InstVisitor<InstExecutor, void>,
       const auto &Vec = Args[0].asAggregate();
       const auto &SubVec = Args[1].asAggregate();
       const auto &Idx = Args[2].asInteger();
-      const uint64_t Offset = Idx.getZExtValue();
-      if (Offset + SubVec.size() > Vec.size())
+      auto EC =
+          cast<VectorType>(CB.getArgOperand(1)->getType())->getElementCount();
+      const uint64_t RawOffset = Idx.getZExtValue();
+      if (RawOffset % EC.getKnownMinValue() != 0) {
+        reportImmediateUB("llvm.vector.insert index is not a multiple of the "
+                          "subvector's known minimum vector length.");
+        return AnyValue::poison();
+      }
+      const uint32_t VScale = Ctx.getVScale();
+      if (EC.isScalable() && VScale != 0 &&
----------------
nikic wrote:

We should probably add some input validation for the vscale command line argument to make sure it's a power of two (and thus also not zero)? Shouldn't have to check this in individual places.

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


More information about the llvm-commits mailing list