@@ -4515,6 +4515,9 @@ void DAGTypeLegalizer::WidenVectorResult(SDNode *N, unsigned ResNo) {
45154515 break ;
45164516 case ISD::EXTRACT_SUBVECTOR: Res = WidenVecRes_EXTRACT_SUBVECTOR (N); break ;
45174517 case ISD::INSERT_VECTOR_ELT: Res = WidenVecRes_INSERT_VECTOR_ELT (N); break ;
4518+ case ISD::ATOMIC_LOAD:
4519+ Res = WidenVecRes_ATOMIC_LOAD (cast<AtomicSDNode>(N));
4520+ break ;
45184521 case ISD::LOAD: Res = WidenVecRes_LOAD (N); break ;
45194522 case ISD::STEP_VECTOR:
45204523 case ISD::SPLAT_VECTOR:
@@ -5901,6 +5904,30 @@ SDValue DAGTypeLegalizer::WidenVecRes_INSERT_VECTOR_ELT(SDNode *N) {
59015904 N->getOperand (1 ), N->getOperand (2 ));
59025905}
59035906
5907+ SDValue DAGTypeLegalizer::WidenVecRes_ATOMIC_LOAD (AtomicSDNode *N) {
5908+ SmallVector<SDValue, 16 > LdChain; // Chain for the series of load
5909+ SDValue Result = GenWidenVectorLoads (LdChain, N, true /* IsAtomic*/ );
5910+
5911+ if (Result) {
5912+ // If we generate a single load, we can use that for the chain. Otherwise,
5913+ // build a factor node to remember the multiple loads are independent and
5914+ // chain to that.
5915+ SDValue NewChain;
5916+ if (LdChain.size () == 1 )
5917+ NewChain = LdChain[0 ];
5918+ else
5919+ NewChain = DAG.getNode (ISD::TokenFactor, SDLoc (N), MVT::Other, LdChain);
5920+
5921+ // Modified the chain - switch anything that used the old chain to use
5922+ // the new one.
5923+ ReplaceValueWith (SDValue (N, 1 ), NewChain);
5924+
5925+ return Result;
5926+ }
5927+
5928+ report_fatal_error (" Unable to widen atomic vector load" );
5929+ }
5930+
59045931SDValue DAGTypeLegalizer::WidenVecRes_LOAD (SDNode *N) {
59055932 LoadSDNode *LD = cast<LoadSDNode>(N);
59065933 ISD::LoadExtType ExtType = LD->getExtensionType ();
@@ -7699,8 +7726,9 @@ static SDValue BuildVectorFromScalar(SelectionDAG& DAG, EVT VecTy,
76997726 return DAG.getNode (ISD::BITCAST, dl, VecTy, VecOp);
77007727}
77017728
7729+ template <typename T>
77027730SDValue DAGTypeLegalizer::GenWidenVectorLoads (SmallVectorImpl<SDValue> &LdChain,
7703- LoadSDNode *LD) {
7731+ T *LD, bool IsAtomic ) {
77047732 // The strategy assumes that we can efficiently load power-of-two widths.
77057733 // The routine chops the vector into the largest vector loads with the same
77067734 // element type or scalar loads and then recombines it to the widen vector
@@ -7757,8 +7785,13 @@ SDValue DAGTypeLegalizer::GenWidenVectorLoads(SmallVectorImpl<SDValue> &LdChain,
77577785 } while (TypeSize::isKnownGT (RemainingWidth, NewVTWidth));
77587786 }
77597787
7760- SDValue LdOp = DAG.getLoad (*FirstVT, dl, Chain, BasePtr, LD->getPointerInfo (),
7761- LD->getOriginalAlign (), MMOFlags, AAInfo);
7788+ SDValue LdOp;
7789+ if (IsAtomic)
7790+ LdOp = DAG.getAtomic (ISD::ATOMIC_LOAD, dl, *FirstVT, *FirstVT, Chain,
7791+ BasePtr, LD->getMemOperand ());
7792+ else
7793+ LdOp = DAG.getLoad (*FirstVT, dl, Chain, BasePtr, LD->getPointerInfo (),
7794+ LD->getOriginalAlign (), MMOFlags, AAInfo);
77627795 LdChain.push_back (LdOp.getValue (1 ));
77637796
77647797 // Check if we can load the element with one instruction.
0 commit comments