@@ -4517,6 +4517,9 @@ void DAGTypeLegalizer::WidenVectorResult(SDNode *N, unsigned ResNo) {
45174517 break ;
45184518 case ISD ::EXTRACT_SUBVECTOR : Res = WidenVecRes_EXTRACT_SUBVECTOR (N); break ;
45194519 case ISD ::INSERT_VECTOR_ELT : Res = WidenVecRes_INSERT_VECTOR_ELT (N); break ;
4520+ case ISD ::ATOMIC_LOAD :
4521+ Res = WidenVecRes_ATOMIC_LOAD (cast<AtomicSDNode>(N));
4522+ break ;
45204523 case ISD ::LOAD : Res = WidenVecRes_LOAD (N); break ;
45214524 case ISD ::STEP_VECTOR :
45224525 case ISD ::SPLAT_VECTOR :
@@ -5903,6 +5906,30 @@ SDValue DAGTypeLegalizer::WidenVecRes_INSERT_VECTOR_ELT(SDNode *N) {
59035906 N->getOperand (1 ), N->getOperand (2 ));
59045907}
59055908
5909+ SDValue DAGTypeLegalizer::WidenVecRes_ATOMIC_LOAD (AtomicSDNode *N) {
5910+ SmallVector<SDValue, 16 > LdChain; // Chain for the series of load
5911+ SDValue Result = GenWidenVectorLoads (LdChain, N, true /* IsAtomic*/ );
5912+
5913+ if (Result) {
5914+ // If we generate a single load, we can use that for the chain. Otherwise,
5915+ // build a factor node to remember the multiple loads are independent and
5916+ // chain to that.
5917+ SDValue NewChain;
5918+ if (LdChain.size () == 1 )
5919+ NewChain = LdChain[0 ];
5920+ else
5921+ NewChain = DAG .getNode (ISD ::TokenFactor, SDLoc (N), MVT ::Other, LdChain);
5922+
5923+ // Modified the chain - switch anything that used the old chain to use
5924+ // the new one.
5925+ ReplaceValueWith (SDValue (N, 1 ), NewChain);
5926+
5927+ return Result;
5928+ }
5929+
5930+ report_fatal_error (" Unable to widen atomic vector load" );
5931+ }
5932+
59065933SDValue DAGTypeLegalizer::WidenVecRes_LOAD (SDNode *N) {
59075934 LoadSDNode *LD = cast<LoadSDNode>(N);
59085935 ISD ::LoadExtType ExtType = LD ->getExtensionType ();
@@ -7701,8 +7728,9 @@ static SDValue BuildVectorFromScalar(SelectionDAG& DAG, EVT VecTy,
77017728 return DAG .getNode (ISD ::BITCAST , dl, VecTy, VecOp);
77027729}
77037730
7731+ template <typename T>
77047732SDValue DAGTypeLegalizer::GenWidenVectorLoads (SmallVectorImpl<SDValue> &LdChain,
7705- LoadSDNode *LD ) {
7733+ T *LD , bool IsAtomic ) {
77067734 // The strategy assumes that we can efficiently load power-of-two widths.
77077735 // The routine chops the vector into the largest vector loads with the same
77087736 // element type or scalar loads and then recombines it to the widen vector
@@ -7759,8 +7787,13 @@ SDValue DAGTypeLegalizer::GenWidenVectorLoads(SmallVectorImpl<SDValue> &LdChain,
77597787 } while (TypeSize::isKnownGT (RemainingWidth, NewVTWidth));
77607788 }
77617789
7762- SDValue LdOp = DAG .getLoad (*FirstVT, dl, Chain, BasePtr, LD ->getPointerInfo (),
7763- LD ->getOriginalAlign (), MMOFlags, AAInfo);
7790+ SDValue LdOp;
7791+ if (IsAtomic)
7792+ LdOp = DAG .getAtomic (ISD ::ATOMIC_LOAD , dl, *FirstVT, *FirstVT, Chain,
7793+ BasePtr, LD ->getMemOperand ());
7794+ else
7795+ LdOp = DAG .getLoad (*FirstVT, dl, Chain, BasePtr, LD ->getPointerInfo (),
7796+ LD ->getOriginalAlign (), MMOFlags, AAInfo);
77647797 LdChain.push_back (LdOp.getValue (1 ));
77657798
77667799 // Check if we can load the element with one instruction.
0 commit comments