|
@@ -4658,9 +4658,26 @@ void SelectionDAGBuilder::visitAtomicLoad(const LoadInst &I) {
|
|
|
AAMDNodes(), nullptr, SSID, Order);
|
|
|
|
|
|
InChain = TLI.prepareVolatileOrAtomicLoad(InChain, dl, DAG);
|
|
|
- SDValue L =
|
|
|
- DAG.getAtomic(ISD::ATOMIC_LOAD, dl, MemVT, MemVT, InChain,
|
|
|
- getValue(I.getPointerOperand()), MMO);
|
|
|
+
|
|
|
+ SDValue Ptr = getValue(I.getPointerOperand());
|
|
|
+
|
|
|
+ if (TLI.lowerAtomicLoadAsLoadSDNode(I)) {
|
|
|
+ // TODO: Once this is better exercised by tests, it should be merged with
|
|
|
+ // the normal path for loads to prevent future divergence.
|
|
|
+ SDValue L = DAG.getLoad(MemVT, dl, InChain, Ptr, MMO);
|
|
|
+ if (MemVT != VT)
|
|
|
+ L = DAG.getPtrExtOrTrunc(L, dl, VT);
|
|
|
+
|
|
|
+ setValue(&I, L);
|
|
|
+ if (!I.isUnordered()) {
|
|
|
+ SDValue OutChain = L.getValue(1);
|
|
|
+ DAG.setRoot(OutChain);
|
|
|
+ }
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ SDValue L = DAG.getAtomic(ISD::ATOMIC_LOAD, dl, MemVT, MemVT, InChain,
|
|
|
+ Ptr, MMO);
|
|
|
|
|
|
SDValue OutChain = L.getValue(1);
|
|
|
if (MemVT != VT)
|
|
@@ -4699,9 +4716,17 @@ void SelectionDAGBuilder::visitAtomicStore(const StoreInst &I) {
|
|
|
SDValue Val = getValue(I.getValueOperand());
|
|
|
if (Val.getValueType() != MemVT)
|
|
|
Val = DAG.getPtrExtOrTrunc(Val, dl, MemVT);
|
|
|
+ SDValue Ptr = getValue(I.getPointerOperand());
|
|
|
|
|
|
+ if (TLI.lowerAtomicStoreAsStoreSDNode(I)) {
|
|
|
+ // TODO: Once this is better exercised by tests, it should be merged with
|
|
|
+ // the normal path for stores to prevent future divergence.
|
|
|
+ SDValue S = DAG.getStore(InChain, dl, Val, Ptr, MMO);
|
|
|
+ DAG.setRoot(S);
|
|
|
+ return;
|
|
|
+ }
|
|
|
SDValue OutChain = DAG.getAtomic(ISD::ATOMIC_STORE, dl, MemVT, InChain,
|
|
|
- getValue(I.getPointerOperand()), Val, MMO);
|
|
|
+ Ptr, Val, MMO);
|
|
|
|
|
|
|
|
|
DAG.setRoot(OutChain);
|