@@ -475,6 +475,7 @@ unsigned VPInstruction::getNumOperandsForOpcode(unsigned Opcode) {
475
475
case VPInstruction::FirstOrderRecurrenceSplice:
476
476
case VPInstruction::LogicalAnd:
477
477
case VPInstruction::PtrAdd:
478
+ case VPInstruction::WidePtrAdd:
478
479
case VPInstruction::WideIVStep:
479
480
return 2 ;
480
481
case Instruction::Select:
@@ -494,9 +495,8 @@ unsigned VPInstruction::getNumOperandsForOpcode(unsigned Opcode) {
494
495
}
495
496
#endif
496
497
497
- bool VPInstruction::doesGeneratePerAllLanes (VPTransformState &State) const {
498
- return Opcode == VPInstruction::PtrAdd && !vputils::onlyFirstLaneUsed (this ) &&
499
- !State.hasVectorValue (getOperand (1 ));
498
+ bool VPInstruction::doesGeneratePerAllLanes () const {
499
+ return Opcode == VPInstruction::PtrAdd && !vputils::onlyFirstLaneUsed (this );
500
500
}
501
501
502
502
bool VPInstruction::canGenerateScalarForFirstLane () const {
@@ -514,6 +514,7 @@ bool VPInstruction::canGenerateScalarForFirstLane() const {
514
514
case VPInstruction::CalculateTripCountMinusVF:
515
515
case VPInstruction::CanonicalIVIncrementForPart:
516
516
case VPInstruction::PtrAdd:
517
+ case VPInstruction::WidePtrAdd:
517
518
case VPInstruction::ExplicitVectorLength:
518
519
case VPInstruction::AnyOf:
519
520
return true ;
@@ -849,7 +850,14 @@ Value *VPInstruction::generate(VPTransformState &State) {
849
850
return Builder.CreateLogicalAnd (A, B, Name);
850
851
}
851
852
case VPInstruction::PtrAdd: {
853
+ assert (vputils::onlyFirstLaneUsed (this ) &&
854
+ " can only generate first lane for PtrAdd" );
852
855
Value *Ptr = State.get (getOperand (0 ), VPLane (0 ));
856
+ Value *Addend = State.get (getOperand (1 ), VPLane (0 ));
857
+ return Builder.CreatePtrAdd (Ptr, Addend, Name, getGEPNoWrapFlags ());
858
+ }
859
+ case VPInstruction::WidePtrAdd: {
860
+ Value *Ptr = State.get (getOperand (0 ), true );
853
861
Value *Addend = State.get (getOperand (1 ), vputils::onlyFirstLaneUsed (this ));
854
862
return Builder.CreatePtrAdd (Ptr, Addend, Name, getGEPNoWrapFlags ());
855
863
}
@@ -910,6 +918,9 @@ InstructionCost VPInstruction::computeCost(ElementCount VF,
910
918
}
911
919
}
912
920
921
+ assert (!doesGeneratePerAllLanes () &&
922
+ " Should only generate a vector value or single scalar, not scalars "
923
+ " for all lanes." );
913
924
return Ctx.TTI .getArithmeticInstrCost (getOpcode (), ResTy, Ctx.CostKind );
914
925
}
915
926
@@ -997,7 +1008,7 @@ void VPInstruction::execute(VPTransformState &State) {
997
1008
bool GeneratesPerFirstLaneOnly = canGenerateScalarForFirstLane () &&
998
1009
(vputils::onlyFirstLaneUsed (this ) ||
999
1010
isVectorToScalar () || isSingleScalar ());
1000
- bool GeneratesPerAllLanes = doesGeneratePerAllLanes (State );
1011
+ bool GeneratesPerAllLanes = doesGeneratePerAllLanes ();
1001
1012
if (GeneratesPerAllLanes) {
1002
1013
for (unsigned Lane = 0 , NumLanes = State.VF .getFixedValue ();
1003
1014
Lane != NumLanes; ++Lane) {
@@ -1041,6 +1052,7 @@ bool VPInstruction::opcodeMayReadOrWriteFromMemory() const {
1041
1052
case VPInstruction::LogicalAnd:
1042
1053
case VPInstruction::Not:
1043
1054
case VPInstruction::PtrAdd:
1055
+ case VPInstruction::WidePtrAdd:
1044
1056
case VPInstruction::WideIVStep:
1045
1057
case VPInstruction::StepVector:
1046
1058
case VPInstruction::ReductionStartVector:
@@ -1078,6 +1090,7 @@ bool VPInstruction::onlyFirstLaneUsed(const VPValue *Op) const {
1078
1090
case VPInstruction::ReductionStartVector:
1079
1091
return true ;
1080
1092
case VPInstruction::PtrAdd:
1093
+ case VPInstruction::WidePtrAdd:
1081
1094
return Op == getOperand (0 ) || vputils::onlyFirstLaneUsed (this );
1082
1095
case VPInstruction::ComputeAnyOfResult:
1083
1096
case VPInstruction::ComputeFindIVResult:
@@ -1181,6 +1194,9 @@ void VPInstruction::print(raw_ostream &O, const Twine &Indent,
1181
1194
case VPInstruction::PtrAdd:
1182
1195
O << " ptradd" ;
1183
1196
break ;
1197
+ case VPInstruction::WidePtrAdd:
1198
+ O << " wide-ptradd" ;
1199
+ break ;
1184
1200
case VPInstruction::AnyOf:
1185
1201
O << " any-of" ;
1186
1202
break ;
@@ -1765,7 +1781,8 @@ bool VPIRFlags::flagsValidForOpcode(unsigned Opcode) const {
1765
1781
return Opcode == Instruction::AShr;
1766
1782
case OperationType::GEPOp:
1767
1783
return Opcode == Instruction::GetElementPtr ||
1768
- Opcode == VPInstruction::PtrAdd;
1784
+ Opcode == VPInstruction::PtrAdd ||
1785
+ Opcode == VPInstruction::WidePtrAdd;
1769
1786
case OperationType::FPMathOp:
1770
1787
return Opcode == Instruction::FAdd || Opcode == Instruction::FMul ||
1771
1788
Opcode == Instruction::FSub || Opcode == Instruction::FNeg ||
0 commit comments