Skip to content

Commit 6069374

Browse files
authored
[SDAG] Remove IndexType manipulation in getUniformBase and callers (#151578)
All paths set it to the same value, just propagate that value to the consumer.
1 parent 2b1e065 commit 6069374

File tree

1 file changed

+23
-34
lines changed

1 file changed

+23
-34
lines changed

llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp

Lines changed: 23 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -4909,9 +4909,8 @@ void SelectionDAGBuilder::visitMaskedStore(const CallInst &I,
49094909
// extract the splat value and use it as a uniform base.
49104910
// In all other cases the function returns 'false'.
49114911
static bool getUniformBase(const Value *Ptr, SDValue &Base, SDValue &Index,
4912-
ISD::MemIndexType &IndexType, SDValue &Scale,
4913-
SelectionDAGBuilder *SDB, const BasicBlock *CurBB,
4914-
uint64_t ElemSize) {
4912+
SDValue &Scale, SelectionDAGBuilder *SDB,
4913+
const BasicBlock *CurBB, uint64_t ElemSize) {
49154914
SelectionDAG& DAG = SDB->DAG;
49164915
const TargetLowering &TLI = DAG.getTargetLoweringInfo();
49174916
const DataLayout &DL = DAG.getDataLayout();
@@ -4929,7 +4928,6 @@ static bool getUniformBase(const Value *Ptr, SDValue &Base, SDValue &Index,
49294928
ElementCount NumElts = cast<VectorType>(Ptr->getType())->getElementCount();
49304929
EVT VT = EVT::getVectorVT(*DAG.getContext(), TLI.getPointerTy(DL), NumElts);
49314930
Index = DAG.getConstant(0, SDB->getCurSDLoc(), VT);
4932-
IndexType = ISD::SIGNED_SCALED;
49334931
Scale = DAG.getTargetConstant(1, SDB->getCurSDLoc(), TLI.getPointerTy(DL));
49344932
return true;
49354933
}
@@ -4959,7 +4957,6 @@ static bool getUniformBase(const Value *Ptr, SDValue &Base, SDValue &Index,
49594957

49604958
Base = SDB->getValue(BasePtr);
49614959
Index = SDB->getValue(IndexVal);
4962-
IndexType = ISD::SIGNED_SCALED;
49634960

49644961
Scale =
49654962
DAG.getTargetConstant(ScaleVal, SDB->getCurSDLoc(), TLI.getPointerTy(DL));
@@ -4981,9 +4978,8 @@ void SelectionDAGBuilder::visitMaskedScatter(const CallInst &I) {
49814978

49824979
SDValue Base;
49834980
SDValue Index;
4984-
ISD::MemIndexType IndexType;
49854981
SDValue Scale;
4986-
bool UniformBase = getUniformBase(Ptr, Base, Index, IndexType, Scale, this,
4982+
bool UniformBase = getUniformBase(Ptr, Base, Index, Scale, this,
49874983
I.getParent(), VT.getScalarStoreSize());
49884984

49894985
unsigned AS = Ptr->getType()->getScalarType()->getPointerAddressSpace();
@@ -4993,8 +4989,8 @@ void SelectionDAGBuilder::visitMaskedScatter(const CallInst &I) {
49934989
if (!UniformBase) {
49944990
Base = DAG.getConstant(0, sdl, TLI.getPointerTy(DAG.getDataLayout()));
49954991
Index = getValue(Ptr);
4996-
IndexType = ISD::SIGNED_SCALED;
4997-
Scale = DAG.getTargetConstant(1, sdl, TLI.getPointerTy(DAG.getDataLayout()));
4992+
Scale =
4993+
DAG.getTargetConstant(1, sdl, TLI.getPointerTy(DAG.getDataLayout()));
49984994
}
49994995

50004996
EVT IdxVT = Index.getValueType();
@@ -5006,7 +5002,7 @@ void SelectionDAGBuilder::visitMaskedScatter(const CallInst &I) {
50065002

50075003
SDValue Ops[] = { getMemoryRoot(), Src0, Mask, Base, Index, Scale };
50085004
SDValue Scatter = DAG.getMaskedScatter(DAG.getVTList(MVT::Other), VT, sdl,
5009-
Ops, MMO, IndexType, false);
5005+
Ops, MMO, ISD::SIGNED_SCALED, false);
50105006
DAG.setRoot(Scatter);
50115007
setValue(&I, Scatter);
50125008
}
@@ -5099,9 +5095,8 @@ void SelectionDAGBuilder::visitMaskedGather(const CallInst &I) {
50995095
SDValue Root = DAG.getRoot();
51005096
SDValue Base;
51015097
SDValue Index;
5102-
ISD::MemIndexType IndexType;
51035098
SDValue Scale;
5104-
bool UniformBase = getUniformBase(Ptr, Base, Index, IndexType, Scale, this,
5099+
bool UniformBase = getUniformBase(Ptr, Base, Index, Scale, this,
51055100
I.getParent(), VT.getScalarStoreSize());
51065101
unsigned AS = Ptr->getType()->getScalarType()->getPointerAddressSpace();
51075102
MachineMemOperand *MMO = DAG.getMachineFunction().getMachineMemOperand(
@@ -5112,8 +5107,8 @@ void SelectionDAGBuilder::visitMaskedGather(const CallInst &I) {
51125107
if (!UniformBase) {
51135108
Base = DAG.getConstant(0, sdl, TLI.getPointerTy(DAG.getDataLayout()));
51145109
Index = getValue(Ptr);
5115-
IndexType = ISD::SIGNED_SCALED;
5116-
Scale = DAG.getTargetConstant(1, sdl, TLI.getPointerTy(DAG.getDataLayout()));
5110+
Scale =
5111+
DAG.getTargetConstant(1, sdl, TLI.getPointerTy(DAG.getDataLayout()));
51175112
}
51185113

51195114
EVT IdxVT = Index.getValueType();
@@ -5124,8 +5119,9 @@ void SelectionDAGBuilder::visitMaskedGather(const CallInst &I) {
51245119
}
51255120

51265121
SDValue Ops[] = { Root, Src0, Mask, Base, Index, Scale };
5127-
SDValue Gather = DAG.getMaskedGather(DAG.getVTList(VT, MVT::Other), VT, sdl,
5128-
Ops, MMO, IndexType, ISD::NON_EXTLOAD);
5122+
SDValue Gather =
5123+
DAG.getMaskedGather(DAG.getVTList(VT, MVT::Other), VT, sdl, Ops, MMO,
5124+
ISD::SIGNED_SCALED, ISD::NON_EXTLOAD);
51295125

51305126
PendingLoads.push_back(Gather.getValue(1));
51315127
setValue(&I, Gather);
@@ -6438,9 +6434,8 @@ void SelectionDAGBuilder::visitVectorHistogram(const CallInst &I,
64386434
SDValue Root = DAG.getRoot();
64396435
SDValue Base;
64406436
SDValue Index;
6441-
ISD::MemIndexType IndexType;
64426437
SDValue Scale;
6443-
bool UniformBase = getUniformBase(Ptr, Base, Index, IndexType, Scale, this,
6438+
bool UniformBase = getUniformBase(Ptr, Base, Index, Scale, this,
64446439
I.getParent(), VT.getScalarStoreSize());
64456440

64466441
unsigned AS = Ptr->getType()->getScalarType()->getPointerAddressSpace();
@@ -6453,7 +6448,6 @@ void SelectionDAGBuilder::visitVectorHistogram(const CallInst &I,
64536448
if (!UniformBase) {
64546449
Base = DAG.getConstant(0, sdl, TLI.getPointerTy(DAG.getDataLayout()));
64556450
Index = getValue(Ptr);
6456-
IndexType = ISD::SIGNED_SCALED;
64576451
Scale =
64586452
DAG.getTargetConstant(1, sdl, TLI.getPointerTy(DAG.getDataLayout()));
64596453
}
@@ -6469,7 +6463,7 @@ void SelectionDAGBuilder::visitVectorHistogram(const CallInst &I,
64696463

64706464
SDValue Ops[] = {Root, Inc, Mask, Base, Index, Scale, ID};
64716465
SDValue Histogram = DAG.getMaskedHistogram(DAG.getVTList(MVT::Other), VT, sdl,
6472-
Ops, MMO, IndexType);
6466+
Ops, MMO, ISD::SIGNED_SCALED);
64736467

64746468
setValue(&I, Histogram);
64756469
DAG.setRoot(Histogram);
@@ -8531,14 +8525,12 @@ void SelectionDAGBuilder::visitVPGather(
85318525
MachinePointerInfo(AS), MachineMemOperand::MOLoad,
85328526
LocationSize::beforeOrAfterPointer(), *Alignment, AAInfo, Ranges);
85338527
SDValue Base, Index, Scale;
8534-
ISD::MemIndexType IndexType;
8535-
bool UniformBase = getUniformBase(PtrOperand, Base, Index, IndexType, Scale,
8536-
this, VPIntrin.getParent(),
8537-
VT.getScalarStoreSize());
8528+
bool UniformBase =
8529+
getUniformBase(PtrOperand, Base, Index, Scale, this, VPIntrin.getParent(),
8530+
VT.getScalarStoreSize());
85388531
if (!UniformBase) {
85398532
Base = DAG.getConstant(0, DL, TLI.getPointerTy(DAG.getDataLayout()));
85408533
Index = getValue(PtrOperand);
8541-
IndexType = ISD::SIGNED_SCALED;
85428534
Scale = DAG.getTargetConstant(1, DL, TLI.getPointerTy(DAG.getDataLayout()));
85438535
}
85448536
EVT IdxVT = Index.getValueType();
@@ -8550,7 +8542,7 @@ void SelectionDAGBuilder::visitVPGather(
85508542
LD = DAG.getGatherVP(
85518543
DAG.getVTList(VT, MVT::Other), VT, DL,
85528544
{DAG.getRoot(), Base, Index, Scale, OpValues[1], OpValues[2]}, MMO,
8553-
IndexType);
8545+
ISD::SIGNED_SCALED);
85548546
PendingLoads.push_back(LD.getValue(1));
85558547
setValue(&VPIntrin, LD);
85568548
}
@@ -8594,16 +8586,13 @@ void SelectionDAGBuilder::visitVPScatter(
85948586
MachinePointerInfo(AS), MachineMemOperand::MOStore,
85958587
LocationSize::beforeOrAfterPointer(), *Alignment, AAInfo);
85968588
SDValue Base, Index, Scale;
8597-
ISD::MemIndexType IndexType;
8598-
bool UniformBase = getUniformBase(PtrOperand, Base, Index, IndexType, Scale,
8599-
this, VPIntrin.getParent(),
8600-
VT.getScalarStoreSize());
8589+
bool UniformBase =
8590+
getUniformBase(PtrOperand, Base, Index, Scale, this, VPIntrin.getParent(),
8591+
VT.getScalarStoreSize());
86018592
if (!UniformBase) {
86028593
Base = DAG.getConstant(0, DL, TLI.getPointerTy(DAG.getDataLayout()));
86038594
Index = getValue(PtrOperand);
8604-
IndexType = ISD::SIGNED_SCALED;
8605-
Scale =
8606-
DAG.getTargetConstant(1, DL, TLI.getPointerTy(DAG.getDataLayout()));
8595+
Scale = DAG.getTargetConstant(1, DL, TLI.getPointerTy(DAG.getDataLayout()));
86078596
}
86088597
EVT IdxVT = Index.getValueType();
86098598
EVT EltTy = IdxVT.getVectorElementType();
@@ -8614,7 +8603,7 @@ void SelectionDAGBuilder::visitVPScatter(
86148603
ST = DAG.getScatterVP(DAG.getVTList(MVT::Other), VT, DL,
86158604
{getMemoryRoot(), OpValues[0], Base, Index, Scale,
86168605
OpValues[2], OpValues[3]},
8617-
MMO, IndexType);
8606+
MMO, ISD::SIGNED_SCALED);
86188607
DAG.setRoot(ST);
86198608
setValue(&VPIntrin, ST);
86208609
}

0 commit comments

Comments
 (0)