@@ -1358,9 +1358,9 @@ std::pair <SDValue, SDValue> DAGTypeLegalizer::ExpandAtomic(SDNode *Node) {
1358
1358
return ExpandChainLibCall (LC, Node, false );
1359
1359
}
1360
1360
1361
- // / ExpandShiftByConstant - N is a shift by a value that needs to be expanded,
1361
+ // / N is a shift by a value that needs to be expanded,
1362
1362
// / and the shift amount is a constant 'Amt'. Expand the operation.
1363
- void DAGTypeLegalizer::ExpandShiftByConstant (SDNode *N, unsigned Amt,
1363
+ void DAGTypeLegalizer::ExpandShiftByConstant (SDNode *N, const APInt & Amt,
1364
1364
SDValue &Lo, SDValue &Hi) {
1365
1365
SDLoc DL (N);
1366
1366
// Expand the incoming operand to be shifted, so that we have its parts
@@ -1381,12 +1381,12 @@ void DAGTypeLegalizer::ExpandShiftByConstant(SDNode *N, unsigned Amt,
1381
1381
EVT ShTy = N->getOperand (1 ).getValueType ();
1382
1382
1383
1383
if (N->getOpcode () == ISD::SHL) {
1384
- if (Amt > VTBits) {
1384
+ if (Amt. ugt ( VTBits) ) {
1385
1385
Lo = Hi = DAG.getConstant (0 , DL, NVT);
1386
- } else if (Amt > NVTBits) {
1386
+ } else if (Amt. ugt ( NVTBits) ) {
1387
1387
Lo = DAG.getConstant (0 , DL, NVT);
1388
1388
Hi = DAG.getNode (ISD::SHL, DL,
1389
- NVT, InL, DAG.getConstant (Amt - NVTBits, DL, ShTy));
1389
+ NVT, InL, DAG.getConstant (- Amt + NVTBits, DL, ShTy));
1390
1390
} else if (Amt == NVTBits) {
1391
1391
Lo = DAG.getConstant (0 , DL, NVT);
1392
1392
Hi = InL;
@@ -1405,16 +1405,15 @@ void DAGTypeLegalizer::ExpandShiftByConstant(SDNode *N, unsigned Amt,
1405
1405
DAG.getNode (ISD::SHL, DL, NVT, InH,
1406
1406
DAG.getConstant (Amt, DL, ShTy)),
1407
1407
DAG.getNode (ISD::SRL, DL, NVT, InL,
1408
- DAG.getConstant (NVTBits - Amt, DL, ShTy)));
1408
+ DAG.getConstant (- Amt + NVTBits , DL, ShTy)));
1409
1409
}
1410
1410
return ;
1411
1411
}
1412
1412
1413
1413
if (N->getOpcode () == ISD::SRL) {
1414
- if (Amt > VTBits) {
1415
- Lo = DAG.getConstant (0 , DL, NVT);
1416
- Hi = DAG.getConstant (0 , DL, NVT);
1417
- } else if (Amt > NVTBits) {
1414
+ if (Amt.ugt (VTBits)) {
1415
+ Lo = Hi = DAG.getConstant (0 , DL, NVT);
1416
+ } else if (Amt.ugt (NVTBits)) {
1418
1417
Lo = DAG.getNode (ISD::SRL, DL,
1419
1418
NVT, InH, DAG.getConstant (Amt - NVTBits, DL, ShTy));
1420
1419
Hi = DAG.getConstant (0 , DL, NVT);
@@ -1426,19 +1425,19 @@ void DAGTypeLegalizer::ExpandShiftByConstant(SDNode *N, unsigned Amt,
1426
1425
DAG.getNode (ISD::SRL, DL, NVT, InL,
1427
1426
DAG.getConstant (Amt, DL, ShTy)),
1428
1427
DAG.getNode (ISD::SHL, DL, NVT, InH,
1429
- DAG.getConstant (NVTBits - Amt, DL, ShTy)));
1428
+ DAG.getConstant (- Amt + NVTBits , DL, ShTy)));
1430
1429
Hi = DAG.getNode (ISD::SRL, DL, NVT, InH, DAG.getConstant (Amt, DL, ShTy));
1431
1430
}
1432
1431
return ;
1433
1432
}
1434
1433
1435
1434
assert (N->getOpcode () == ISD::SRA && " Unknown shift!" );
1436
- if (Amt > VTBits) {
1435
+ if (Amt. ugt ( VTBits) ) {
1437
1436
Hi = Lo = DAG.getNode (ISD::SRA, DL, NVT, InH,
1438
1437
DAG.getConstant (NVTBits - 1 , DL, ShTy));
1439
- } else if (Amt > NVTBits) {
1438
+ } else if (Amt. ugt ( NVTBits) ) {
1440
1439
Lo = DAG.getNode (ISD::SRA, DL, NVT, InH,
1441
- DAG.getConstant (Amt- NVTBits, DL, ShTy));
1440
+ DAG.getConstant (Amt - NVTBits, DL, ShTy));
1442
1441
Hi = DAG.getNode (ISD::SRA, DL, NVT, InH,
1443
1442
DAG.getConstant (NVTBits - 1 , DL, ShTy));
1444
1443
} else if (Amt == NVTBits) {
@@ -1450,7 +1449,7 @@ void DAGTypeLegalizer::ExpandShiftByConstant(SDNode *N, unsigned Amt,
1450
1449
DAG.getNode (ISD::SRL, DL, NVT, InL,
1451
1450
DAG.getConstant (Amt, DL, ShTy)),
1452
1451
DAG.getNode (ISD::SHL, DL, NVT, InH,
1453
- DAG.getConstant (NVTBits - Amt, DL, ShTy)));
1452
+ DAG.getConstant (- Amt + NVTBits , DL, ShTy)));
1454
1453
Hi = DAG.getNode (ISD::SRA, DL, NVT, InH, DAG.getConstant (Amt, DL, ShTy));
1455
1454
}
1456
1455
}
@@ -2178,7 +2177,7 @@ void DAGTypeLegalizer::ExpandIntRes_Shift(SDNode *N,
2178
2177
// If we can emit an efficient shift operation, do so now. Check to see if
2179
2178
// the RHS is a constant.
2180
2179
if (ConstantSDNode *CN = dyn_cast<ConstantSDNode>(N->getOperand (1 )))
2181
- return ExpandShiftByConstant (N, CN->getZExtValue (), Lo, Hi);
2180
+ return ExpandShiftByConstant (N, CN->getAPIntValue (), Lo, Hi);
2182
2181
2183
2182
// If we can determine that the high bit of the shift is zero or one, even if
2184
2183
// the low bits are variable, emit this shift in an optimized form.
0 commit comments