@@ -295,6 +295,7 @@ SystemZTargetLowering::SystemZTargetLowering(const TargetMachine &TM,
295
295
setOperationAction (ISD::ATOMIC_LOAD, MVT::i128 , Custom);
296
296
setOperationAction (ISD::ATOMIC_STORE, MVT::i128 , Custom);
297
297
setOperationAction (ISD::ATOMIC_LOAD, MVT::f128 , Custom);
298
+ setOperationAction (ISD::ATOMIC_STORE, MVT::f128 , Custom);
298
299
299
300
// Mark sign/zero extending atomic loads as legal, which will make
300
301
// DAGCombiner fold extensions into atomic loads if possible.
@@ -941,9 +942,6 @@ SystemZTargetLowering::shouldCastAtomicLoadInIR(LoadInst *LI) const {
941
942
942
943
TargetLowering::AtomicExpansionKind
943
944
SystemZTargetLowering::shouldCastAtomicStoreInIR (StoreInst *SI) const {
944
- // Lower fp128 the same way as i128.
945
- if (SI->getValueOperand ()->getType ()->isFP128Ty ())
946
- return AtomicExpansionKind::CastToInteger;
947
945
return AtomicExpansionKind::None;
948
946
}
949
947
@@ -6269,6 +6267,26 @@ static SDValue expandBitCastI128ToF128(SelectionDAG &DAG, SDValue Src,
6269
6267
return SDValue (Pair, 0 );
6270
6268
}
6271
6269
6270
+ static std::pair<SDValue, SDValue>
6271
+ expandBitCastF128ToI128Parts (SelectionDAG &DAG, SDValue Src, const SDLoc &SL) {
6272
+ SDValue LoFP =
6273
+ DAG.getTargetExtractSubreg (SystemZ::subreg_l64, SL, MVT::f64 , Src);
6274
+ SDValue HiFP =
6275
+ DAG.getTargetExtractSubreg (SystemZ::subreg_h64, SL, MVT::f64 , Src);
6276
+ SDValue Lo = DAG.getNode (ISD::BITCAST, SL, MVT::i64 , LoFP);
6277
+ SDValue Hi = DAG.getNode (ISD::BITCAST, SL, MVT::i64 , HiFP);
6278
+
6279
+ return {Hi, Lo};
6280
+ }
6281
+
6282
+ static SDValue expandBitCastF128ToI128 (SelectionDAG &DAG, SDValue Src,
6283
+ const SDLoc &SL) {
6284
+
6285
+ auto [Hi, Lo] = expandBitCastF128ToI128Parts (DAG, Src, SL);
6286
+ SDNode *Pair = DAG.getMachineNode (SystemZ::PAIR128, SL, MVT::Untyped, Hi, Lo);
6287
+ return SDValue (Pair, 0 );
6288
+ }
6289
+
6272
6290
// Lower operations with invalid operand or result types (currently used
6273
6291
// only for 128-bit integer types).
6274
6292
void
@@ -6307,8 +6325,17 @@ SystemZTargetLowering::LowerOperationWrapper(SDNode *N,
6307
6325
case ISD::ATOMIC_STORE: {
6308
6326
SDLoc DL (N);
6309
6327
SDVTList Tys = DAG.getVTList (MVT::Other);
6310
- SDValue Ops[] = {N->getOperand (0 ), lowerI128ToGR128 (DAG, N->getOperand (1 )),
6311
- N->getOperand (2 )};
6328
+ SDValue Val = N->getOperand (1 );
6329
+ EVT VT = Val.getValueType ();
6330
+
6331
+ if (VT == MVT::i128 || isTypeLegal (MVT::i128 )) {
6332
+ Val = DAG.getBitcast (MVT::i128 , Val);
6333
+ Val = lowerI128ToGR128 (DAG, Val);
6334
+ } else {
6335
+ Val = expandBitCastF128ToI128 (DAG, Val, DL);
6336
+ }
6337
+
6338
+ SDValue Ops[] = {N->getOperand (0 ), Val, N->getOperand (2 )};
6312
6339
MachineMemOperand *MMO = cast<AtomicSDNode>(N)->getMemOperand ();
6313
6340
SDValue Res = DAG.getMemIntrinsicNode (SystemZISD::ATOMIC_STORE_128,
6314
6341
DL, Tys, Ops, MVT::i128 , MMO);
@@ -6351,15 +6378,12 @@ SystemZTargetLowering::LowerOperationWrapper(SDNode *N,
6351
6378
Hi = DAG.getNode (ISD::EXTRACT_VECTOR_ELT, DL, MVT::i64 , VecBC,
6352
6379
DAG.getConstant (0 , DL, MVT::i32 ));
6353
6380
} else {
6381
+ // FIXME: Assert should be moved into expandBitCastF128ToI128Parts
6354
6382
assert (getRepRegClassFor (MVT::f128 ) == &SystemZ::FP128BitRegClass &&
6355
6383
" Unrecognized register class for f128." );
6356
- SDValue LoFP = DAG.getTargetExtractSubreg (SystemZ::subreg_l64,
6357
- DL, MVT::f64 , Src);
6358
- SDValue HiFP = DAG.getTargetExtractSubreg (SystemZ::subreg_h64,
6359
- DL, MVT::f64 , Src);
6360
- Lo = DAG.getNode (ISD::BITCAST, DL, MVT::i64 , LoFP);
6361
- Hi = DAG.getNode (ISD::BITCAST, DL, MVT::i64 , HiFP);
6384
+ std::tie (Hi, Lo) = expandBitCastF128ToI128Parts (DAG, Src, DL);
6362
6385
}
6386
+
6363
6387
Results.push_back (DAG.getNode (ISD::BUILD_PAIR, DL, MVT::i128 , Lo, Hi));
6364
6388
}
6365
6389
break ;
0 commit comments