@@ -4377,7 +4377,7 @@ void SelectionDAGBuilder::visitMaskedStore(const CallInst &I,
4377
4377
// are looking for. If first operand of the GEP is a splat vector - we
4378
4378
// extract the splat value and use it as a uniform base.
4379
4379
// In all other cases the function returns 'false'.
4380
- static bool getUniformBase (const Value *& Ptr, SDValue &Base, SDValue &Index,
4380
+ static bool getUniformBase (const Value *Ptr, SDValue &Base, SDValue &Index,
4381
4381
ISD::MemIndexType &IndexType, SDValue &Scale,
4382
4382
SelectionDAGBuilder *SDB) {
4383
4383
SelectionDAG& DAG = SDB->DAG ;
@@ -4388,11 +4388,12 @@ static bool getUniformBase(const Value *&Ptr, SDValue &Base, SDValue &Index,
4388
4388
if (!GEP)
4389
4389
return false ;
4390
4390
4391
- const Value *GEPPtr = GEP->getPointerOperand ();
4392
- if (!GEPPtr->getType ()->isVectorTy ())
4393
- Ptr = GEPPtr;
4394
- else if (!(Ptr = getSplatValue (GEPPtr)))
4395
- return false ;
4391
+ const Value *BasePtr = GEP->getPointerOperand ();
4392
+ if (BasePtr->getType ()->isVectorTy ()) {
4393
+ BasePtr = getSplatValue (BasePtr);
4394
+ if (!BasePtr)
4395
+ return false ;
4396
+ }
4396
4397
4397
4398
unsigned FinalIndex = GEP->getNumOperands () - 1 ;
4398
4399
Value *IndexVal = GEP->getOperand (FinalIndex);
@@ -4412,7 +4413,7 @@ static bool getUniformBase(const Value *&Ptr, SDValue &Base, SDValue &Index,
4412
4413
4413
4414
// The operands of the GEP may be defined in another basic block.
4414
4415
// In this case we'll not find nodes for the operands.
4415
- if (!SDB->findValue (Ptr ))
4416
+ if (!SDB->findValue (BasePtr ))
4416
4417
return false ;
4417
4418
Constant *C = dyn_cast<Constant>(IndexVal);
4418
4419
if (!C && !SDB->findValue (IndexVal))
@@ -4434,7 +4435,7 @@ static bool getUniformBase(const Value *&Ptr, SDValue &Base, SDValue &Index,
4434
4435
SDB->getCurSDLoc (), TLI.getPointerTy (DL));
4435
4436
Index = SDB->getValue (IndexVal);
4436
4437
}
4437
- Base = SDB->getValue (Ptr );
4438
+ Base = SDB->getValue (BasePtr );
4438
4439
IndexType = ISD::SIGNED_SCALED;
4439
4440
4440
4441
if (STy || !Index.getValueType ().isVector ()) {
@@ -4465,17 +4466,15 @@ void SelectionDAGBuilder::visitMaskedScatter(const CallInst &I) {
4465
4466
SDValue Index;
4466
4467
ISD::MemIndexType IndexType;
4467
4468
SDValue Scale;
4468
- const Value *BasePtr = Ptr;
4469
- bool UniformBase = getUniformBase (BasePtr, Base, Index, IndexType, Scale,
4470
- this );
4469
+ bool UniformBase = getUniformBase (Ptr, Base, Index, IndexType, Scale, this );
4471
4470
4472
- const Value *MemOpBasePtr = UniformBase ? BasePtr : nullptr ;
4471
+ unsigned AS = Ptr-> getType ()-> getScalarType ()-> getPointerAddressSpace () ;
4473
4472
MachineMemOperand *MMO = DAG.getMachineFunction ().
4474
- getMachineMemOperand (MachinePointerInfo (MemOpBasePtr ),
4473
+ getMachineMemOperand (MachinePointerInfo (AS ),
4475
4474
MachineMemOperand::MOStore,
4476
4475
// TODO: Make MachineMemOperands aware of scalable
4477
4476
// vectors.
4478
- VT. getStoreSize (). getKnownMinSize () ,
4477
+ MemoryLocation::UnknownSize ,
4479
4478
Alignment, AAInfo);
4480
4479
if (!UniformBase) {
4481
4480
Base = DAG.getConstant (0 , sdl, TLI.getPointerTy (DAG.getDataLayout ()));
@@ -4582,28 +4581,15 @@ void SelectionDAGBuilder::visitMaskedGather(const CallInst &I) {
4582
4581
SDValue Index;
4583
4582
ISD::MemIndexType IndexType;
4584
4583
SDValue Scale;
4585
- const Value *BasePtr = Ptr;
4586
- bool UniformBase = getUniformBase (BasePtr, Base, Index, IndexType, Scale,
4587
- this );
4588
- bool ConstantMemory = false ;
4589
- if (UniformBase && AA &&
4590
- AA->pointsToConstantMemory (
4591
- MemoryLocation (BasePtr,
4592
- LocationSize::precise (
4593
- DAG.getDataLayout ().getTypeStoreSize (I.getType ())),
4594
- AAInfo))) {
4595
- // Do not serialize (non-volatile) loads of constant memory with anything.
4596
- Root = DAG.getEntryNode ();
4597
- ConstantMemory = true ;
4598
- }
4599
-
4584
+ bool UniformBase = getUniformBase (Ptr, Base, Index, IndexType, Scale, this );
4585
+ unsigned AS = Ptr->getType ()->getScalarType ()->getPointerAddressSpace ();
4600
4586
MachineMemOperand *MMO =
4601
4587
DAG.getMachineFunction ().
4602
- getMachineMemOperand (MachinePointerInfo (UniformBase ? BasePtr : nullptr ),
4588
+ getMachineMemOperand (MachinePointerInfo (AS ),
4603
4589
MachineMemOperand::MOLoad,
4604
4590
// TODO: Make MachineMemOperands aware of scalable
4605
4591
// vectors.
4606
- VT. getStoreSize (). getKnownMinSize () ,
4592
+ MemoryLocation::UnknownSize ,
4607
4593
Alignment, AAInfo, Ranges);
4608
4594
4609
4595
if (!UniformBase) {
@@ -4616,9 +4602,7 @@ void SelectionDAGBuilder::visitMaskedGather(const CallInst &I) {
4616
4602
SDValue Gather = DAG.getMaskedGather (DAG.getVTList (VT, MVT::Other), VT, sdl,
4617
4603
Ops, MMO, IndexType);
4618
4604
4619
- SDValue OutChain = Gather.getValue (1 );
4620
- if (!ConstantMemory)
4621
- PendingLoads.push_back (OutChain);
4605
+ PendingLoads.push_back (Gather.getValue (1 ));
4622
4606
setValue (&I, Gather);
4623
4607
}
4624
4608
0 commit comments