Skip to content
This repository was archived by the owner on Sep 15, 2025. It is now read-only.

Commit bb86c5d

Browse files
committed
[VPlan] Use inferScalarType in VPInstruction::ResumePhi codegen (NFC).
Use VPlan-based type analysis to retrieve type of phi node. Also adds missing type inference for ResumePhi and ComputeReductionResult opcodes.
1 parent 93c2577 commit bb86c5d

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,10 +61,16 @@ Type *VPTypeAnalysis::inferScalarTypeForRecipe(const VPInstruction *R) {
6161
case Instruction::ICmp:
6262
case VPInstruction::ActiveLaneMask:
6363
return inferScalarType(R->getOperand(1));
64+
case VPInstruction::ComputeReductionResult: {
65+
auto *PhiR = cast<VPReductionPHIRecipe>(R->getOperand(0));
66+
auto *OrigPhi = cast<PHINode>(PhiR->getUnderlyingValue());
67+
return OrigPhi->getType();
68+
}
6469
case VPInstruction::ExplicitVectorLength:
6570
return Type::getIntNTy(Ctx, 32);
6671
case VPInstruction::FirstOrderRecurrenceSplice:
6772
case VPInstruction::Not:
73+
case VPInstruction::ResumePhi:
6874
return SetResultTyFromOp();
6975
case VPInstruction::ExtractFromEnd: {
7076
Type *BaseTy = inferScalarType(R->getOperand(0));

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -629,7 +629,7 @@ Value *VPInstruction::generate(VPTransformState &State) {
629629
Value *IncomingFromOtherPreds =
630630
State.get(getOperand(1), /* IsScalar */ true);
631631
auto *NewPhi =
632-
Builder.CreatePHI(IncomingFromOtherPreds->getType(), 2, Name);
632+
Builder.CreatePHI(State.TypeAnalysis.inferScalarType(this), 2, Name);
633633
BasicBlock *VPlanPred =
634634
State.CFG
635635
.VPBB2IRBB[cast<VPBasicBlock>(getParent()->getPredecessors()[0])];

0 commit comments

Comments
 (0)