@@ -2897,6 +2897,8 @@ void DAGTypeLegalizer::ExpandShiftByConstant(SDNode *N, const APInt &Amt,
2897
2897
// / shift amount.
2898
2898
bool DAGTypeLegalizer::
2899
2899
ExpandShiftWithKnownAmountBit (SDNode *N, SDValue &Lo, SDValue &Hi) {
2900
+ unsigned Opc = N->getOpcode ();
2901
+ SDValue In = N->getOperand (0 );
2900
2902
SDValue Amt = N->getOperand (1 );
2901
2903
EVT NVT = TLI.getTypeToTransformTo (*DAG.getContext (), N->getValueType (0 ));
2902
2904
EVT ShTy = Amt.getValueType ();
@@ -2907,15 +2909,15 @@ ExpandShiftWithKnownAmountBit(SDNode *N, SDValue &Lo, SDValue &Hi) {
2907
2909
SDLoc dl (N);
2908
2910
2909
2911
APInt HighBitMask = APInt::getHighBitsSet (ShBits, ShBits - Log2_32 (NVTBits));
2910
- KnownBits Known = DAG.computeKnownBits (N-> getOperand ( 1 ) );
2912
+ KnownBits Known = DAG.computeKnownBits (Amt );
2911
2913
2912
2914
// If we don't know anything about the high bits, exit.
2913
- if (((Known.Zero | Known.One ) & HighBitMask) == 0 )
2915
+ if (((Known.Zero | Known.One ) & HighBitMask) == 0 )
2914
2916
return false ;
2915
2917
2916
2918
// Get the incoming operand to be shifted.
2917
2919
SDValue InL, InH;
2918
- GetExpandedInteger (N-> getOperand ( 0 ) , InL, InH);
2920
+ GetExpandedInteger (In , InL, InH);
2919
2921
2920
2922
// If we know that any of the high bits of the shift amount are one, then we
2921
2923
// can do this as a couple of simple shifts.
@@ -2924,7 +2926,7 @@ ExpandShiftWithKnownAmountBit(SDNode *N, SDValue &Lo, SDValue &Hi) {
2924
2926
Amt = DAG.getNode (ISD::AND, dl, ShTy, Amt,
2925
2927
DAG.getConstant (~HighBitMask, dl, ShTy));
2926
2928
2927
- switch (N-> getOpcode () ) {
2929
+ switch (Opc ) {
2928
2930
default : llvm_unreachable (" Unknown shift" );
2929
2931
case ISD::SHL:
2930
2932
Lo = DAG.getConstant (0 , dl, NVT); // Low part is zero.
@@ -2952,15 +2954,15 @@ ExpandShiftWithKnownAmountBit(SDNode *N, SDValue &Lo, SDValue &Hi) {
2952
2954
DAG.getConstant (NVTBits - 1 , dl, ShTy));
2953
2955
2954
2956
unsigned Op1, Op2;
2955
- switch (N-> getOpcode () ) {
2957
+ switch (Opc ) {
2956
2958
default : llvm_unreachable (" Unknown shift" );
2957
2959
case ISD::SHL: Op1 = ISD::SHL; Op2 = ISD::SRL; break ;
2958
2960
case ISD::SRL:
2959
2961
case ISD::SRA: Op1 = ISD::SRL; Op2 = ISD::SHL; break ;
2960
2962
}
2961
2963
2962
2964
// When shifting right the arithmetic for Lo and Hi is swapped.
2963
- if (N-> getOpcode () != ISD::SHL)
2965
+ if (Opc != ISD::SHL)
2964
2966
std::swap (InL, InH);
2965
2967
2966
2968
// Use a little trick to get the bits that move from Lo to Hi. First
@@ -2969,10 +2971,10 @@ ExpandShiftWithKnownAmountBit(SDNode *N, SDValue &Lo, SDValue &Hi) {
2969
2971
// Then compute the remaining shift with amount-1.
2970
2972
SDValue Sh2 = DAG.getNode (Op2, dl, NVT, Sh1, Amt2);
2971
2973
2972
- Lo = DAG.getNode (N-> getOpcode () , dl, NVT, InL, Amt);
2974
+ Lo = DAG.getNode (Opc , dl, NVT, InL, Amt);
2973
2975
Hi = DAG.getNode (ISD::OR, dl, NVT, DAG.getNode (Op1, dl, NVT, InH, Amt),Sh2);
2974
2976
2975
- if (N-> getOpcode () != ISD::SHL)
2977
+ if (Opc != ISD::SHL)
2976
2978
std::swap (Hi, Lo);
2977
2979
return true ;
2978
2980
}
0 commit comments