[llvm] [LICM] Allow hoisting of InsertElementInst's past non-hoistable InsertElementInsts (PR #200532)

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 11 03:50:23 PDT 2026


================
@@ -1058,6 +1072,83 @@ bool llvm::hoistRegion(DomTreeNode *N, AAResults *AA, LoopInfo *LI,
   return Changed;
 }
 
+static std::optional<uint64_t>
+getConstantInsertionIndex(InsertElementInst *Ins) {
+  // Must have constant insertion lane.
+  auto *InsertedIdxCI = dyn_cast<ConstantInt>(Ins->getOperand(2));
+  if (!InsertedIdxCI)
+    return std::nullopt;
+  auto *VecTy = cast<VectorType>(Ins->getType());
+
+  // Avoid hoisting past out of bounds inserts
----------------
nikic wrote:

```suggestion
  // Avoid hoisting past out of bounds inserts.
```
Here and elsewhere.

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


More information about the llvm-commits mailing list