[llvm] [VPlan] Consistently use (Part, 0) for first lane scalar values (PR #80271)

via llvm-commits llvm-commits at lists.llvm.org
Sun Feb 18 06:12:48 PST 2024


================
@@ -279,11 +279,17 @@ Value *VPInstruction::generateInstruction(VPTransformState &State,
   Builder.SetCurrentDebugLocation(getDebugLoc());
 
   if (Instruction::isBinaryOp(getOpcode())) {
+    bool OnlyFirstLaneUsed = vputils::onlyFirstLaneUsed(this);
     if (Part != 0 && vputils::onlyFirstPartUsed(this))
-      return State.get(this, 0);
-
-    Value *A = State.get(getOperand(0), Part);
-    Value *B = State.get(getOperand(1), Part);
+      return OnlyFirstLaneUsed ? State.get(this, VPIteration(0, 0))
+                               : State.get(this, 0);
----------------
ayalz wrote:

Perhaps it would be clearer to add another `State.get(VPValue, Part, bool IsScalarPerPart)` which would redirect to either State.get(VPValue, Part) or State.get(VPValue, Part, VPIteration(Part, 0)), instead of having callers do so explicitly repeatedly.

Could also add an analogous State.set(), to simplify VPInstruction::execute() below.

That may simplify changing how scalar values per part are stored and retrieved in the future.

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


More information about the llvm-commits mailing list