Skip to content

Commit 5b44b41

Browse files
committed
DAG: Implement softening for fp atomic load
This will prevent SystemZ test regressions in a future change, tested by #90826
1 parent d9fc5ba commit 5b44b41

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ void DAGTypeLegalizer::SoftenFloatResult(SDNode *N, unsigned ResNo) {
134134
case ISD::STRICT_FTRUNC:
135135
case ISD::FTRUNC: R = SoftenFloatRes_FTRUNC(N); break;
136136
case ISD::LOAD: R = SoftenFloatRes_LOAD(N); break;
137+
case ISD::ATOMIC_LOAD: R = SoftenFloatRes_ATOMIC_LOAD(N); break;
137138
case ISD::ATOMIC_SWAP: R = BitcastToInt_ATOMIC_SWAP(N); break;
138139
case ISD::SELECT: R = SoftenFloatRes_SELECT(N); break;
139140
case ISD::SELECT_CC: R = SoftenFloatRes_SELECT_CC(N); break;
@@ -815,6 +816,26 @@ SDValue DAGTypeLegalizer::SoftenFloatRes_LOAD(SDNode *N) {
815816
return BitConvertToInteger(ExtendNode);
816817
}
817818

819+
SDValue DAGTypeLegalizer::SoftenFloatRes_ATOMIC_LOAD(SDNode *N) {
820+
AtomicSDNode *L = cast<AtomicSDNode>(N);
821+
EVT VT = N->getValueType(0);
822+
EVT NVT = TLI.getTypeToTransformTo(*DAG.getContext(), VT);
823+
SDLoc dl(N);
824+
825+
if (L->getExtensionType() == ISD::NON_EXTLOAD) {
826+
SDValue NewL =
827+
DAG.getAtomic(ISD::ATOMIC_LOAD, dl, NVT, DAG.getVTList(NVT, MVT::Other),
828+
{L->getChain(), L->getBasePtr()}, L->getMemOperand());
829+
830+
// Legalized the chain result - switch anything that used the old chain to
831+
// use the new one.
832+
ReplaceValueWith(SDValue(N, 1), NewL.getValue(1));
833+
return NewL;
834+
}
835+
836+
report_fatal_error("softening fp extending atomic load not handled");
837+
}
838+
818839
SDValue DAGTypeLegalizer::SoftenFloatRes_SELECT(SDNode *N) {
819840
SDValue LHS = GetSoftenedFloat(N->getOperand(1));
820841
SDValue RHS = GetSoftenedFloat(N->getOperand(2));

llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -569,6 +569,7 @@ class LLVM_LIBRARY_VISIBILITY DAGTypeLegalizer {
569569
SDValue SoftenFloatRes_FSUB(SDNode *N);
570570
SDValue SoftenFloatRes_FTRUNC(SDNode *N);
571571
SDValue SoftenFloatRes_LOAD(SDNode *N);
572+
SDValue SoftenFloatRes_ATOMIC_LOAD(SDNode *N);
572573
SDValue SoftenFloatRes_SELECT(SDNode *N);
573574
SDValue SoftenFloatRes_SELECT_CC(SDNode *N);
574575
SDValue SoftenFloatRes_UNDEF(SDNode *N);

0 commit comments

Comments
 (0)