[llvm] [VPlan] Improve code in VPInstruction::generate (NFC) (PR #169470)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Tue Nov 25 03:27:41 PST 2025


================
@@ -808,8 +807,7 @@ Value *VPInstruction::generate(VPTransformState &State) {
         cast<StructType>(State.TypeAnalysis.inferScalarType(getOperand(0)));
     Value *Res = PoisonValue::get(toVectorizedTy(StructTy, State.VF));
     for (const auto &[LaneIndex, Op] : enumerate(operands())) {
-      for (unsigned FieldIndex = 0; FieldIndex != StructTy->getNumElements();
-           FieldIndex++) {
+      for (unsigned FieldIndex : seq<unsigned>(StructTy->getNumElements())) {
----------------
artagnon wrote:

seq has the advantage that getNumElements() is only evaluated once, and the iota_range is expanded -- this would be equivalent to `I = Begin, E = End; I != E; ++I`, and hence more efficient.

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


More information about the llvm-commits mailing list