Skip to content

Commit d9fc5ba

Browse files
authored
DAG: Implement softening for fp atomic store (#90840)
This will prevent SystemZ test regressions in a future change, tested by #90826
1 parent 175d297 commit d9fc5ba

File tree

2 files changed

+19
-0
lines changed

2 files changed

+19
-0
lines changed

llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -946,6 +946,9 @@ bool DAGTypeLegalizer::SoftenFloatOperand(SDNode *N, unsigned OpNo) {
946946
case ISD::STRICT_FSETCCS:
947947
case ISD::SETCC: Res = SoftenFloatOp_SETCC(N); break;
948948
case ISD::STORE: Res = SoftenFloatOp_STORE(N, OpNo); break;
949+
case ISD::ATOMIC_STORE:
950+
Res = SoftenFloatOp_ATOMIC_STORE(N, OpNo);
951+
break;
949952
case ISD::FCOPYSIGN: Res = SoftenFloatOp_FCOPYSIGN(N); break;
950953
}
951954

@@ -1172,6 +1175,21 @@ SDValue DAGTypeLegalizer::SoftenFloatOp_STORE(SDNode *N, unsigned OpNo) {
11721175
ST->getMemOperand());
11731176
}
11741177

1178+
SDValue DAGTypeLegalizer::SoftenFloatOp_ATOMIC_STORE(SDNode *N, unsigned OpNo) {
1179+
assert(ISD::isUNINDEXEDStore(N) && "Indexed store during type legalization!");
1180+
assert(OpNo == 1 && "Can only soften the stored value!");
1181+
AtomicSDNode *ST = cast<AtomicSDNode>(N);
1182+
SDValue Val = ST->getVal();
1183+
EVT VT = Val.getValueType();
1184+
SDLoc dl(N);
1185+
1186+
assert(ST->getMemoryVT() == VT && "truncating atomic store not handled");
1187+
1188+
SDValue NewVal = GetSoftenedFloat(Val);
1189+
return DAG.getAtomic(ISD::ATOMIC_STORE, dl, VT, ST->getChain(), NewVal,
1190+
ST->getBasePtr(), ST->getMemOperand());
1191+
}
1192+
11751193
SDValue DAGTypeLegalizer::SoftenFloatOp_FCOPYSIGN(SDNode *N) {
11761194
SDValue LHS = N->getOperand(0);
11771195
SDValue RHS = BitConvertToInteger(N->getOperand(1));

llvm/lib/CodeGen/SelectionDAG/LegalizeTypes.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,7 @@ class LLVM_LIBRARY_VISIBILITY DAGTypeLegalizer {
592592
SDValue SoftenFloatOp_SELECT_CC(SDNode *N);
593593
SDValue SoftenFloatOp_SETCC(SDNode *N);
594594
SDValue SoftenFloatOp_STORE(SDNode *N, unsigned OpNo);
595+
SDValue SoftenFloatOp_ATOMIC_STORE(SDNode *N, unsigned OpNo);
595596
SDValue SoftenFloatOp_FCOPYSIGN(SDNode *N);
596597

597598
//===--------------------------------------------------------------------===//

0 commit comments

Comments
 (0)