@@ -365,15 +365,15 @@ SDValue DAGTypeLegalizer::PromoteIntRes_BITCAST(SDNode *N) {
365
365
CreateStackStoreLoad (InOp, OutVT));
366
366
}
367
367
368
- // Helper for BSWAP/BITREVERSE promotion to ensure we can fit the shift amount
368
+ // Helper for BSWAP/BITREVERSE promotion to ensure we can fit any shift amount
369
369
// in the VT returned by getShiftAmountTy and to return a safe VT if we can't.
370
- static EVT getShiftAmountTyForConstant (unsigned Val, EVT VT,
371
- const TargetLowering &TLI,
370
+ static EVT getShiftAmountTyForConstant (EVT VT, const TargetLowering &TLI,
372
371
SelectionDAG &DAG) {
373
372
EVT ShiftVT = TLI.getShiftAmountTy (VT, DAG.getDataLayout ());
374
- // If the value won't fit in the prefered type, just use something safe. It
375
- // will be legalized when the shift is expanded.
376
- if ((Log2_32 (Val) + 1 ) > ShiftVT.getScalarSizeInBits ())
373
+ // If any possible shift value won't fit in the prefered type, just use
374
+ // something safe. It will be legalized when the shift is expanded.
375
+ if (!ShiftVT.isVector () &&
376
+ ShiftVT.getSizeInBits () < Log2_32_Ceil (VT.getSizeInBits ()))
377
377
ShiftVT = MVT::i32 ;
378
378
return ShiftVT;
379
379
}
@@ -385,7 +385,7 @@ SDValue DAGTypeLegalizer::PromoteIntRes_BSWAP(SDNode *N) {
385
385
SDLoc dl (N);
386
386
387
387
unsigned DiffBits = NVT.getScalarSizeInBits () - OVT.getScalarSizeInBits ();
388
- EVT ShiftVT = getShiftAmountTyForConstant (DiffBits, NVT, TLI, DAG);
388
+ EVT ShiftVT = getShiftAmountTyForConstant (NVT, TLI, DAG);
389
389
return DAG.getNode (ISD::SRL, dl, NVT, DAG.getNode (ISD::BSWAP, dl, NVT, Op),
390
390
DAG.getConstant (DiffBits, dl, ShiftVT));
391
391
}
@@ -397,7 +397,7 @@ SDValue DAGTypeLegalizer::PromoteIntRes_BITREVERSE(SDNode *N) {
397
397
SDLoc dl (N);
398
398
399
399
unsigned DiffBits = NVT.getScalarSizeInBits () - OVT.getScalarSizeInBits ();
400
- EVT ShiftVT = getShiftAmountTyForConstant (DiffBits, NVT, TLI, DAG);
400
+ EVT ShiftVT = getShiftAmountTyForConstant (NVT, TLI, DAG);
401
401
return DAG.getNode (ISD::SRL, dl, NVT,
402
402
DAG.getNode (ISD::BITREVERSE, dl, NVT, Op),
403
403
DAG.getConstant (DiffBits, dl, ShiftVT));
@@ -1058,8 +1058,7 @@ SDValue DAGTypeLegalizer::PromoteIntRes_XMULO(SDNode *N, unsigned ResNo) {
1058
1058
if (N->getOpcode () == ISD::UMULO) {
1059
1059
// Unsigned overflow occurred if the high part is non-zero.
1060
1060
unsigned Shift = SmallVT.getScalarSizeInBits ();
1061
- EVT ShiftTy = getShiftAmountTyForConstant (Shift, Mul.getValueType (),
1062
- TLI, DAG);
1061
+ EVT ShiftTy = getShiftAmountTyForConstant (Mul.getValueType (), TLI, DAG);
1063
1062
SDValue Hi = DAG.getNode (ISD::SRL, DL, Mul.getValueType (), Mul,
1064
1063
DAG.getConstant (Shift, DL, ShiftTy));
1065
1064
Overflow = DAG.getSetCC (DL, N->getValueType (1 ), Hi,
0 commit comments