@@ -155,6 +155,7 @@ static const unsigned MaxParallelChains = 64;
155
155
static SDValue getCopyFromPartsVector (SelectionDAG &DAG, const SDLoc &DL,
156
156
const SDValue *Parts, unsigned NumParts,
157
157
MVT PartVT, EVT ValueVT, const Value *V,
158
+ SDValue InChain,
158
159
std::optional<CallingConv::ID> CC);
159
160
160
161
// / getCopyFromParts - Create a value that contains the specified legal parts
@@ -165,6 +166,7 @@ static SDValue getCopyFromPartsVector(SelectionDAG &DAG, const SDLoc &DL,
165
166
static SDValue
166
167
getCopyFromParts (SelectionDAG &DAG, const SDLoc &DL, const SDValue *Parts,
167
168
unsigned NumParts, MVT PartVT, EVT ValueVT, const Value *V,
169
+ SDValue InChain,
168
170
std::optional<CallingConv::ID> CC = std::nullopt,
169
171
std::optional<ISD::NodeType> AssertOp = std::nullopt) {
170
172
// Let the target assemble the parts if it wants to
@@ -175,7 +177,7 @@ getCopyFromParts(SelectionDAG &DAG, const SDLoc &DL, const SDValue *Parts,
175
177
176
178
if (ValueVT.isVector ())
177
179
return getCopyFromPartsVector (DAG, DL, Parts, NumParts, PartVT, ValueVT, V,
178
- CC);
180
+ InChain, CC);
179
181
180
182
assert (NumParts > 0 && " No parts to assemble!" );
181
183
SDValue Val = Parts[0 ];
@@ -196,10 +198,10 @@ getCopyFromParts(SelectionDAG &DAG, const SDLoc &DL, const SDValue *Parts,
196
198
EVT HalfVT = EVT::getIntegerVT (*DAG.getContext (), RoundBits/2 );
197
199
198
200
if (RoundParts > 2 ) {
199
- Lo = getCopyFromParts (DAG, DL, Parts, RoundParts / 2 ,
200
- PartVT, HalfVT, V );
201
- Hi = getCopyFromParts (DAG, DL, Parts + RoundParts / 2 ,
202
- RoundParts / 2 , PartVT, HalfVT, V);
201
+ Lo = getCopyFromParts (DAG, DL, Parts, RoundParts / 2 , PartVT, HalfVT, V,
202
+ InChain );
203
+ Hi = getCopyFromParts (DAG, DL, Parts + RoundParts / 2 , RoundParts / 2 ,
204
+ PartVT, HalfVT, V, InChain );
203
205
} else {
204
206
Lo = DAG.getNode (ISD::BITCAST, DL, HalfVT, Parts[0 ]);
205
207
Hi = DAG.getNode (ISD::BITCAST, DL, HalfVT, Parts[1 ]);
@@ -215,7 +217,7 @@ getCopyFromParts(SelectionDAG &DAG, const SDLoc &DL, const SDValue *Parts,
215
217
unsigned OddParts = NumParts - RoundParts;
216
218
EVT OddVT = EVT::getIntegerVT (*DAG.getContext (), OddParts * PartBits);
217
219
Hi = getCopyFromParts (DAG, DL, Parts + RoundParts, OddParts, PartVT,
218
- OddVT, V, CC);
220
+ OddVT, V, InChain, CC);
219
221
220
222
// Combine the round and odd parts.
221
223
Lo = Val;
@@ -245,7 +247,8 @@ getCopyFromParts(SelectionDAG &DAG, const SDLoc &DL, const SDValue *Parts,
245
247
assert (ValueVT.isFloatingPoint () && PartVT.isInteger () &&
246
248
!PartVT.isVector () && " Unexpected split" );
247
249
EVT IntVT = EVT::getIntegerVT (*DAG.getContext (), ValueVT.getSizeInBits ());
248
- Val = getCopyFromParts (DAG, DL, Parts, NumParts, PartVT, IntVT, V, CC);
250
+ Val = getCopyFromParts (DAG, DL, Parts, NumParts, PartVT, IntVT, V,
251
+ InChain, CC);
249
252
}
250
253
}
251
254
@@ -285,10 +288,20 @@ getCopyFromParts(SelectionDAG &DAG, const SDLoc &DL, const SDValue *Parts,
285
288
286
289
if (PartEVT.isFloatingPoint () && ValueVT.isFloatingPoint ()) {
287
290
// FP_ROUND's are always exact here.
288
- if (ValueVT.bitsLT (Val.getValueType ()))
289
- return DAG.getNode (
290
- ISD::FP_ROUND, DL, ValueVT, Val,
291
- DAG.getTargetConstant (1 , DL, TLI.getPointerTy (DAG.getDataLayout ())));
291
+ if (ValueVT.bitsLT (Val.getValueType ())) {
292
+
293
+ SDValue NoChange =
294
+ DAG.getTargetConstant (1 , DL, TLI.getPointerTy (DAG.getDataLayout ()));
295
+
296
+ if (DAG.getMachineFunction ().getFunction ().getAttributes ().hasFnAttr (
297
+ llvm::Attribute::StrictFP)) {
298
+ return DAG.getNode (ISD::STRICT_FP_ROUND, DL,
299
+ DAG.getVTList (ValueVT, MVT::Other), InChain, Val,
300
+ NoChange);
301
+ }
302
+
303
+ return DAG.getNode (ISD::FP_ROUND, DL, ValueVT, Val, NoChange);
304
+ }
292
305
293
306
return DAG.getNode (ISD::FP_EXTEND, DL, ValueVT, Val);
294
307
}
@@ -326,6 +339,7 @@ static void diagnosePossiblyInvalidConstraint(LLVMContext &Ctx, const Value *V,
326
339
static SDValue getCopyFromPartsVector (SelectionDAG &DAG, const SDLoc &DL,
327
340
const SDValue *Parts, unsigned NumParts,
328
341
MVT PartVT, EVT ValueVT, const Value *V,
342
+ SDValue InChain,
329
343
std::optional<CallingConv::ID> CallConv) {
330
344
assert (ValueVT.isVector () && " Not a vector value" );
331
345
assert (NumParts > 0 && " No parts to assemble!" );
@@ -364,17 +378,17 @@ static SDValue getCopyFromPartsVector(SelectionDAG &DAG, const SDLoc &DL,
364
378
// If the register was not expanded, truncate or copy the value,
365
379
// as appropriate.
366
380
for (unsigned i = 0 ; i != NumParts; ++i)
367
- Ops[i] = getCopyFromParts (DAG, DL, &Parts[i], 1 ,
368
- PartVT, IntermediateVT, V , CallConv);
381
+ Ops[i] = getCopyFromParts (DAG, DL, &Parts[i], 1 , PartVT, IntermediateVT,
382
+ V, InChain , CallConv);
369
383
} else if (NumParts > 0 ) {
370
384
// If the intermediate type was expanded, build the intermediate
371
385
// operands from the parts.
372
386
assert (NumParts % NumIntermediates == 0 &&
373
387
" Must expand into a divisible number of parts!" );
374
388
unsigned Factor = NumParts / NumIntermediates;
375
389
for (unsigned i = 0 ; i != NumIntermediates; ++i)
376
- Ops[i] = getCopyFromParts (DAG, DL, &Parts[i * Factor], Factor,
377
- PartVT, IntermediateVT, V, CallConv);
390
+ Ops[i] = getCopyFromParts (DAG, DL, &Parts[i * Factor], Factor, PartVT,
391
+ IntermediateVT, V, InChain , CallConv);
378
392
}
379
393
380
394
// Build a vector with BUILD_VECTOR or CONCAT_VECTORS from the
@@ -928,7 +942,7 @@ SDValue RegsForValue::getCopyFromRegs(SelectionDAG &DAG,
928
942
}
929
943
930
944
Values[Value] = getCopyFromParts (DAG, dl, Parts.begin (), NumRegs,
931
- RegisterVT, ValueVT, V, CallConv);
945
+ RegisterVT, ValueVT, V, Chain, CallConv);
932
946
Part += NumRegs;
933
947
Parts.clear ();
934
948
}
@@ -10700,9 +10714,9 @@ TargetLowering::LowerCallTo(TargetLowering::CallLoweringInfo &CLI) const {
10700
10714
unsigned NumRegs = getNumRegistersForCallingConv (CLI.RetTy ->getContext (),
10701
10715
CLI.CallConv , VT);
10702
10716
10703
- ReturnValues.push_back (getCopyFromParts (CLI. DAG , CLI. DL , &InVals[CurReg],
10704
- NumRegs, RegisterVT, VT, nullptr ,
10705
- CLI.CallConv , AssertOp));
10717
+ ReturnValues.push_back (getCopyFromParts (
10718
+ CLI. DAG , CLI. DL , &InVals[CurReg], NumRegs, RegisterVT, VT, nullptr ,
10719
+ CLI. Chain , CLI.CallConv , AssertOp));
10706
10720
CurReg += NumRegs;
10707
10721
}
10708
10722
@@ -11181,8 +11195,9 @@ void SelectionDAGISel::LowerArguments(const Function &F) {
11181
11195
MVT VT = ValueVTs[0 ].getSimpleVT ();
11182
11196
MVT RegVT = TLI->getRegisterType (*CurDAG->getContext (), VT);
11183
11197
std::optional<ISD::NodeType> AssertOp;
11184
- SDValue ArgValue = getCopyFromParts (DAG, dl, &InVals[0 ], 1 , RegVT, VT,
11185
- nullptr , F.getCallingConv (), AssertOp);
11198
+ SDValue ArgValue =
11199
+ getCopyFromParts (DAG, dl, &InVals[0 ], 1 , RegVT, VT, nullptr , NewRoot,
11200
+ F.getCallingConv (), AssertOp);
11186
11201
11187
11202
MachineFunction& MF = SDB->DAG .getMachineFunction ();
11188
11203
MachineRegisterInfo& RegInfo = MF.getRegInfo ();
@@ -11254,7 +11269,7 @@ void SelectionDAGISel::LowerArguments(const Function &F) {
11254
11269
AssertOp = ISD::AssertZext;
11255
11270
11256
11271
ArgValues.push_back (getCopyFromParts (DAG, dl, &InVals[i], NumParts,
11257
- PartVT, VT, nullptr ,
11272
+ PartVT, VT, nullptr , NewRoot,
11258
11273
F.getCallingConv (), AssertOp));
11259
11274
}
11260
11275
0 commit comments