@@ -923,6 +923,7 @@ bool VPInstruction::opcodeMayReadOrWriteFromMemory() const {
923923 case VPInstruction::LogicalAnd:
924924 case VPInstruction::Not:
925925 case VPInstruction::PtrAdd:
926+ case VPInstruction::StepVector:
926927 return false ;
927928 default :
928929 return true ;
@@ -1071,8 +1072,6 @@ void VPInstruction::print(raw_ostream &O, const Twine &Indent,
10711072
10721073void VPInstructionWithType::execute (VPTransformState &State) {
10731074 State.setDebugLocFrom (getDebugLoc ());
1074- assert (vputils::onlyFirstLaneUsed (this ) &&
1075- " Codegen only implemented for first lane." );
10761075 switch (getOpcode ()) {
10771076 case Instruction::ZExt:
10781077 case Instruction::Trunc: {
@@ -1082,6 +1081,12 @@ void VPInstructionWithType::execute(VPTransformState &State) {
10821081 State.set (this , Cast, VPLane (0 ));
10831082 break ;
10841083 }
1084+ case VPInstruction::StepVector: {
1085+ Value *StepVector =
1086+ State.Builder .CreateStepVector (VectorType::get (ResultTy, State.VF ));
1087+ State.set (this , StepVector);
1088+ break ;
1089+ }
10851090 default :
10861091 llvm_unreachable (" opcode not implemented yet" );
10871092 }
@@ -1092,9 +1097,17 @@ void VPInstructionWithType::print(raw_ostream &O, const Twine &Indent,
10921097 VPSlotTracker &SlotTracker) const {
10931098 O << Indent << " EMIT " ;
10941099 printAsOperand (O, SlotTracker);
1095- O << " = " << Instruction::getOpcodeName (getOpcode ()) << " " ;
1096- printOperands (O, SlotTracker);
1097- O << " to " << *ResultTy;
1100+ O << " = " ;
1101+ switch (getOpcode ()) {
1102+ case VPInstruction::StepVector:
1103+ O << " step-vector " << *ResultTy;
1104+ break ;
1105+ default :
1106+ O << Instruction::getOpcodeName (getOpcode ()) << " " ;
1107+ printOperands (O, SlotTracker);
1108+ O << " to " << *ResultTy;
1109+ break ;
1110+ }
10981111}
10991112#endif
11001113
@@ -1858,7 +1871,8 @@ InstructionCost VPHeaderPHIRecipe::computeCost(ElementCount VF,
18581871// / (0 * Step, 1 * Step, 2 * Step, ...)
18591872// / to each vector element of Val.
18601873// / \p Opcode is relevant for FP induction variable.
1861- static Value *getStepVector (Value *Val, Value *Step,
1874+ // / \p InitVec is an integer step vector from 0 with a step of 1.
1875+ static Value *getStepVector (Value *Val, Value *Step, Value *InitVec,
18621876 Instruction::BinaryOps BinOp, ElementCount VF,
18631877 IRBuilderBase &Builder) {
18641878 assert (VF.isVector () && " only vector VFs are supported" );
@@ -1874,15 +1888,6 @@ static Value *getStepVector(Value *Val, Value *Step,
18741888
18751889 SmallVector<Constant *, 8 > Indices;
18761890
1877- // Create a vector of consecutive numbers from zero to VF.
1878- VectorType *InitVecValVTy = ValVTy;
1879- if (STy->isFloatingPointTy ()) {
1880- Type *InitVecValSTy =
1881- IntegerType::get (STy->getContext (), STy->getScalarSizeInBits ());
1882- InitVecValVTy = VectorType::get (InitVecValSTy, VLen);
1883- }
1884- Value *InitVec = Builder.CreateStepVector (InitVecValVTy);
1885-
18861891 if (STy->isIntegerTy ()) {
18871892 Step = Builder.CreateVectorSplat (VLen, Step);
18881893 assert (Step->getType () == Val->getType () && " Invalid step vec" );
@@ -1948,8 +1953,11 @@ void VPWidenIntOrFpInductionRecipe::execute(VPTransformState &State) {
19481953 }
19491954
19501955 Value *SplatStart = Builder.CreateVectorSplat (State.VF , Start);
1951- Value *SteppedStart = getStepVector (SplatStart, Step, ID.getInductionOpcode (),
1952- State.VF , State.Builder );
1956+ assert (cast<VPInstruction>(getStepVector ())->getOpcode () ==
1957+ VPInstruction::StepVector);
1958+ Value *SteppedStart =
1959+ ::getStepVector (SplatStart, Step, State.get(getStepVector()),
1960+ ID.getInductionOpcode(), State.VF, State.Builder);
19531961
19541962 // We create vector phi nodes for both integer and floating-point induction
19551963 // variables. Here, we determine the kind of arithmetic we will perform.
0 commit comments