@@ -930,6 +930,7 @@ bool VPInstruction::opcodeMayReadOrWriteFromMemory() const {
930930 case VPInstruction::Not:
931931 case VPInstruction::PtrAdd:
932932 case VPInstruction::WideIVStep:
933+ case VPInstruction::StepVector:
933934 return false ;
934935 default :
935936 return true ;
@@ -1078,8 +1079,6 @@ void VPInstruction::print(raw_ostream &O, const Twine &Indent,
10781079
10791080void VPInstructionWithType::execute (VPTransformState &State) {
10801081 State.setDebugLocFrom (getDebugLoc ());
1081- assert (vputils::onlyFirstLaneUsed (this ) &&
1082- " Codegen only implemented for first lane." );
10831082 switch (getOpcode ()) {
10841083 case Instruction::ZExt:
10851084 case Instruction::Trunc: {
@@ -1089,6 +1088,12 @@ void VPInstructionWithType::execute(VPTransformState &State) {
10891088 State.set (this , Cast, VPLane (0 ));
10901089 break ;
10911090 }
1091+ case VPInstruction::StepVector: {
1092+ Value *StepVector =
1093+ State.Builder .CreateStepVector (VectorType::get (ResultTy, State.VF ));
1094+ State.set (this , StepVector);
1095+ break ;
1096+ }
10921097 default :
10931098 llvm_unreachable (" opcode not implemented yet" );
10941099 }
@@ -1106,6 +1111,9 @@ void VPInstructionWithType::print(raw_ostream &O, const Twine &Indent,
11061111 O << " wide-iv-step " ;
11071112 printOperands (O, SlotTracker);
11081113 break ;
1114+ case VPInstruction::StepVector:
1115+ O << " step-vector " << *ResultTy;
1116+ break ;
11091117 default :
11101118 assert (Instruction::isCast (getOpcode ()) && " unhandled opcode" );
11111119 O << Instruction::getOpcodeName (getOpcode ()) << " " ;
@@ -1875,7 +1883,8 @@ InstructionCost VPHeaderPHIRecipe::computeCost(ElementCount VF,
18751883// / (0 * Step, 1 * Step, 2 * Step, ...)
18761884// / to each vector element of Val.
18771885// / \p Opcode is relevant for FP induction variable.
1878- static Value *getStepVector (Value *Val, Value *Step,
1886+ // / \p InitVec is an integer step vector from 0 with a step of 1.
1887+ static Value *getStepVector (Value *Val, Value *Step, Value *InitVec,
18791888 Instruction::BinaryOps BinOp, ElementCount VF,
18801889 IRBuilderBase &Builder) {
18811890 assert (VF.isVector () && " only vector VFs are supported" );
@@ -1891,15 +1900,6 @@ static Value *getStepVector(Value *Val, Value *Step,
18911900
18921901 SmallVector<Constant *, 8 > Indices;
18931902
1894- // Create a vector of consecutive numbers from zero to VF.
1895- VectorType *InitVecValVTy = ValVTy;
1896- if (STy->isFloatingPointTy ()) {
1897- Type *InitVecValSTy =
1898- IntegerType::get (STy->getContext (), STy->getScalarSizeInBits ());
1899- InitVecValVTy = VectorType::get (InitVecValSTy, VLen);
1900- }
1901- Value *InitVec = Builder.CreateStepVector (InitVecValVTy);
1902-
19031903 if (STy->isIntegerTy ()) {
19041904 Step = Builder.CreateVectorSplat (VLen, Step);
19051905 assert (Step->getType () == Val->getType () && " Invalid step vec" );
@@ -1965,8 +1965,11 @@ void VPWidenIntOrFpInductionRecipe::execute(VPTransformState &State) {
19651965 }
19661966
19671967 Value *SplatStart = Builder.CreateVectorSplat (State.VF , Start);
1968- Value *SteppedStart = getStepVector (SplatStart, Step, ID.getInductionOpcode (),
1969- State.VF , State.Builder );
1968+ assert (cast<VPInstruction>(getStepVector ())->getOpcode () ==
1969+ VPInstruction::StepVector);
1970+ Value *SteppedStart =
1971+ ::getStepVector (SplatStart, Step, State.get(getStepVector()),
1972+ ID.getInductionOpcode(), State.VF, State.Builder);
19701973
19711974 // We create vector phi nodes for both integer and floating-point induction
19721975 // variables. Here, we determine the kind of arithmetic we will perform.
0 commit comments