[llvm] [VPlan] Explicitly handle scalar pointer inductions. (PR #83068)
via llvm-commits
llvm-commits at lists.llvm.org
Fri Mar 22 01:22:52 PDT 2024
================
@@ -511,17 +550,33 @@ void VPInstruction::execute(VPTransformState &State) {
"Recipe not a FPMathOp but has fast-math flags?");
if (hasFastMathFlags())
State.Builder.setFastMathFlags(getFastMathFlags());
+ State.Builder.SetCurrentDebugLocation(getDebugLoc());
+ bool OnlyGenerateFirstLane =
+ canGenerateScalarForFirstLane() &&
+ (vputils::onlyFirstLaneUsed(this) ||
+ getOpcode() == VPInstruction::ComputeReductionResult);
+ bool GeneratesPerAllLanes = doesGeneratePerAllLanes();
for (unsigned Part = 0; Part < State.UF; ++Part) {
- Value *GeneratedValue = generateInstruction(State, Part);
+ if (GeneratesPerAllLanes) {
+ for (unsigned Lane = 0, NumLanes = State.VF.getKnownMinValue();
+ Lane != NumLanes; ++Lane) {
+ Value *P = generatePerLane(State, VPIteration(Part, Lane));
+ State.set(this, P, VPIteration(Part, Lane));
+ }
+ continue;
+ }
+
+ Value *GeneratedValue = OnlyGenerateFirstLane
+ ? generatePerLane(State, VPIteration(Part, 0))
+ : generatePerPart(State, Part);
if (!hasResult())
continue;
assert(GeneratedValue && "generateInstruction must produce a value");
- bool IsVector = GeneratedValue->getType()->isVectorTy();
- State.set(this, GeneratedValue, Part, !IsVector);
- assert((IsVector || getOpcode() == VPInstruction::ComputeReductionResult ||
- State.VF.isScalar() || vputils::onlyFirstLaneUsed(this)) &&
- "scalar value but not only first lane used");
+ State.set(this, GeneratedValue, Part, /*IsScalar*/ OnlyGenerateFirstLane);
----------------
ayalz wrote:
nit: better to set State after the following assert.
https://github.com/llvm/llvm-project/pull/83068
More information about the llvm-commits
mailing list