@@ -2824,25 +2824,26 @@ void DAGTypeLegalizer::ExpandShiftByConstant(SDNode *N, const APInt &Amt,
2824
2824
EVT NVT = InL.getValueType ();
2825
2825
unsigned VTBits = N->getValueType (0 ).getSizeInBits ();
2826
2826
unsigned NVTBits = NVT.getSizeInBits ();
2827
- EVT ShTy = N->getOperand (1 ).getValueType ();
2828
2827
2829
2828
if (N->getOpcode () == ISD::SHL) {
2830
2829
if (Amt.uge (VTBits)) {
2831
2830
Lo = Hi = DAG.getConstant (0 , DL, NVT);
2832
2831
} else if (Amt.ugt (NVTBits)) {
2833
2832
Lo = DAG.getConstant (0 , DL, NVT);
2834
- Hi = DAG.getNode (ISD::SHL, DL,
2835
- NVT, InL, DAG.getConstant (Amt - NVTBits, DL, ShTy ));
2833
+ Hi = DAG.getNode (ISD::SHL, DL, NVT, InL,
2834
+ DAG.getShiftAmountConstant (Amt - NVTBits, NVT, DL ));
2836
2835
} else if (Amt == NVTBits) {
2837
2836
Lo = DAG.getConstant (0 , DL, NVT);
2838
2837
Hi = InL;
2839
2838
} else {
2840
- Lo = DAG.getNode (ISD::SHL, DL, NVT, InL, DAG.getConstant (Amt, DL, ShTy));
2841
- Hi = DAG.getNode (ISD::OR, DL, NVT,
2842
- DAG.getNode (ISD::SHL, DL, NVT, InH,
2843
- DAG.getConstant (Amt, DL, ShTy)),
2844
- DAG.getNode (ISD::SRL, DL, NVT, InL,
2845
- DAG.getConstant (-Amt + NVTBits, DL, ShTy)));
2839
+ Lo = DAG.getNode (ISD::SHL, DL, NVT, InL,
2840
+ DAG.getShiftAmountConstant (Amt, NVT, DL));
2841
+ Hi = DAG.getNode (
2842
+ ISD::OR, DL, NVT,
2843
+ DAG.getNode (ISD::SHL, DL, NVT, InH,
2844
+ DAG.getShiftAmountConstant (Amt, NVT, DL)),
2845
+ DAG.getNode (ISD::SRL, DL, NVT, InL,
2846
+ DAG.getShiftAmountConstant (-Amt + NVTBits, NVT, DL)));
2846
2847
}
2847
2848
return ;
2848
2849
}
@@ -2851,43 +2852,47 @@ void DAGTypeLegalizer::ExpandShiftByConstant(SDNode *N, const APInt &Amt,
2851
2852
if (Amt.uge (VTBits)) {
2852
2853
Lo = Hi = DAG.getConstant (0 , DL, NVT);
2853
2854
} else if (Amt.ugt (NVTBits)) {
2854
- Lo = DAG.getNode (ISD::SRL, DL,
2855
- NVT, InH, DAG.getConstant (Amt - NVTBits, DL, ShTy ));
2855
+ Lo = DAG.getNode (ISD::SRL, DL, NVT, InH,
2856
+ DAG.getShiftAmountConstant (Amt - NVTBits, NVT, DL ));
2856
2857
Hi = DAG.getConstant (0 , DL, NVT);
2857
2858
} else if (Amt == NVTBits) {
2858
2859
Lo = InH;
2859
2860
Hi = DAG.getConstant (0 , DL, NVT);
2860
2861
} else {
2861
- Lo = DAG.getNode (ISD::OR, DL, NVT,
2862
- DAG.getNode (ISD::SRL, DL, NVT, InL,
2863
- DAG.getConstant (Amt, DL, ShTy)),
2864
- DAG.getNode (ISD::SHL, DL, NVT, InH,
2865
- DAG.getConstant (-Amt + NVTBits, DL, ShTy)));
2866
- Hi = DAG.getNode (ISD::SRL, DL, NVT, InH, DAG.getConstant (Amt, DL, ShTy));
2862
+ Lo = DAG.getNode (
2863
+ ISD::OR, DL, NVT,
2864
+ DAG.getNode (ISD::SRL, DL, NVT, InL,
2865
+ DAG.getShiftAmountConstant (Amt, NVT, DL)),
2866
+ DAG.getNode (ISD::SHL, DL, NVT, InH,
2867
+ DAG.getShiftAmountConstant (-Amt + NVTBits, NVT, DL)));
2868
+ Hi = DAG.getNode (ISD::SRL, DL, NVT, InH,
2869
+ DAG.getShiftAmountConstant (Amt, NVT, DL));
2867
2870
}
2868
2871
return ;
2869
2872
}
2870
2873
2871
2874
assert (N->getOpcode () == ISD::SRA && " Unknown shift!" );
2872
2875
if (Amt.uge (VTBits)) {
2873
2876
Hi = Lo = DAG.getNode (ISD::SRA, DL, NVT, InH,
2874
- DAG.getConstant (NVTBits - 1 , DL, ShTy ));
2877
+ DAG.getShiftAmountConstant (NVTBits - 1 , NVT, DL ));
2875
2878
} else if (Amt.ugt (NVTBits)) {
2876
2879
Lo = DAG.getNode (ISD::SRA, DL, NVT, InH,
2877
- DAG.getConstant (Amt - NVTBits, DL, ShTy ));
2880
+ DAG.getShiftAmountConstant (Amt - NVTBits, NVT, DL ));
2878
2881
Hi = DAG.getNode (ISD::SRA, DL, NVT, InH,
2879
- DAG.getConstant (NVTBits - 1 , DL, ShTy ));
2882
+ DAG.getShiftAmountConstant (NVTBits - 1 , NVT, DL ));
2880
2883
} else if (Amt == NVTBits) {
2881
2884
Lo = InH;
2882
2885
Hi = DAG.getNode (ISD::SRA, DL, NVT, InH,
2883
- DAG.getConstant (NVTBits - 1 , DL, ShTy ));
2886
+ DAG.getShiftAmountConstant (NVTBits - 1 , NVT, DL ));
2884
2887
} else {
2885
- Lo = DAG.getNode (ISD::OR, DL, NVT,
2886
- DAG.getNode (ISD::SRL, DL, NVT, InL,
2887
- DAG.getConstant (Amt, DL, ShTy)),
2888
- DAG.getNode (ISD::SHL, DL, NVT, InH,
2889
- DAG.getConstant (-Amt + NVTBits, DL, ShTy)));
2890
- Hi = DAG.getNode (ISD::SRA, DL, NVT, InH, DAG.getConstant (Amt, DL, ShTy));
2888
+ Lo = DAG.getNode (
2889
+ ISD::OR, DL, NVT,
2890
+ DAG.getNode (ISD::SRL, DL, NVT, InL,
2891
+ DAG.getShiftAmountConstant (Amt, NVT, DL)),
2892
+ DAG.getNode (ISD::SHL, DL, NVT, InH,
2893
+ DAG.getShiftAmountConstant (-Amt + NVTBits, NVT, DL)));
2894
+ Hi = DAG.getNode (ISD::SRA, DL, NVT, InH,
2895
+ DAG.getShiftAmountConstant (Amt, NVT, DL));
2891
2896
}
2892
2897
}
2893
2898
0 commit comments