@@ -928,6 +928,7 @@ bool VPInstruction::opcodeMayReadOrWriteFromMemory() const {
928928 case VPInstruction::LogicalAnd:
929929 case VPInstruction::Not:
930930 case VPInstruction::PtrAdd:
931+ case VPInstruction::StepVector:
931932 return false ;
932933 default :
933934 return true ;
@@ -1076,8 +1077,6 @@ void VPInstruction::print(raw_ostream &O, const Twine &Indent,
10761077
10771078void VPInstructionWithType::execute (VPTransformState &State) {
10781079 State.setDebugLocFrom (getDebugLoc ());
1079- assert (vputils::onlyFirstLaneUsed (this ) &&
1080- " Codegen only implemented for first lane." );
10811080 switch (getOpcode ()) {
10821081 case Instruction::ZExt:
10831082 case Instruction::Trunc: {
@@ -1087,6 +1086,12 @@ void VPInstructionWithType::execute(VPTransformState &State) {
10871086 State.set (this , Cast, VPLane (0 ));
10881087 break ;
10891088 }
1089+ case VPInstruction::StepVector: {
1090+ Value *StepVector =
1091+ State.Builder .CreateStepVector (VectorType::get (ResultTy, State.VF ));
1092+ State.set (this , StepVector);
1093+ break ;
1094+ }
10901095 default :
10911096 llvm_unreachable (" opcode not implemented yet" );
10921097 }
@@ -1097,9 +1102,17 @@ void VPInstructionWithType::print(raw_ostream &O, const Twine &Indent,
10971102 VPSlotTracker &SlotTracker) const {
10981103 O << Indent << " EMIT " ;
10991104 printAsOperand (O, SlotTracker);
1100- O << " = " << Instruction::getOpcodeName (getOpcode ()) << " " ;
1101- printOperands (O, SlotTracker);
1102- O << " to " << *ResultTy;
1105+ O << " = " ;
1106+ switch (getOpcode ()) {
1107+ case VPInstruction::StepVector:
1108+ O << " step-vector " << *ResultTy;
1109+ break ;
1110+ default :
1111+ O << Instruction::getOpcodeName (getOpcode ()) << " " ;
1112+ printOperands (O, SlotTracker);
1113+ O << " to " << *ResultTy;
1114+ break ;
1115+ }
11031116}
11041117#endif
11051118
@@ -1863,7 +1876,8 @@ InstructionCost VPHeaderPHIRecipe::computeCost(ElementCount VF,
18631876// / (0 * Step, 1 * Step, 2 * Step, ...)
18641877// / to each vector element of Val.
18651878// / \p Opcode is relevant for FP induction variable.
1866- static Value *getStepVector (Value *Val, Value *Step,
1879+ // / \p InitVec is an integer step vector from 0 with a step of 1.
1880+ static Value *getStepVector (Value *Val, Value *Step, Value *InitVec,
18671881 Instruction::BinaryOps BinOp, ElementCount VF,
18681882 IRBuilderBase &Builder) {
18691883 assert (VF.isVector () && " only vector VFs are supported" );
@@ -1879,15 +1893,6 @@ static Value *getStepVector(Value *Val, Value *Step,
18791893
18801894 SmallVector<Constant *, 8 > Indices;
18811895
1882- // Create a vector of consecutive numbers from zero to VF.
1883- VectorType *InitVecValVTy = ValVTy;
1884- if (STy->isFloatingPointTy ()) {
1885- Type *InitVecValSTy =
1886- IntegerType::get (STy->getContext (), STy->getScalarSizeInBits ());
1887- InitVecValVTy = VectorType::get (InitVecValSTy, VLen);
1888- }
1889- Value *InitVec = Builder.CreateStepVector (InitVecValVTy);
1890-
18911896 if (STy->isIntegerTy ()) {
18921897 Step = Builder.CreateVectorSplat (VLen, Step);
18931898 assert (Step->getType () == Val->getType () && " Invalid step vec" );
@@ -1953,8 +1958,11 @@ void VPWidenIntOrFpInductionRecipe::execute(VPTransformState &State) {
19531958 }
19541959
19551960 Value *SplatStart = Builder.CreateVectorSplat (State.VF , Start);
1956- Value *SteppedStart = getStepVector (SplatStart, Step, ID.getInductionOpcode (),
1957- State.VF , State.Builder );
1961+ assert (cast<VPInstruction>(getStepVector ())->getOpcode () ==
1962+ VPInstruction::StepVector);
1963+ Value *SteppedStart =
1964+ ::getStepVector (SplatStart, Step, State.get(getStepVector()),
1965+ ID.getInductionOpcode(), State.VF, State.Builder);
19581966
19591967 // We create vector phi nodes for both integer and floating-point induction
19601968 // variables. Here, we determine the kind of arithmetic we will perform.
0 commit comments