@@ -4585,14 +4585,16 @@ void DAGTypeLegalizer::ExpandIntRes_ShiftThroughStack(SDNode *N, SDValue &Lo,
4585
4585
SDValue ShAmt = N->getOperand (1 );
4586
4586
EVT ShAmtVT = ShAmt.getValueType ();
4587
4587
4588
- EVT LoadStoreVT = VT;
4588
+ EVT LoadVT = VT;
4589
4589
do {
4590
- LoadStoreVT = TLI.getTypeToTransformTo (*DAG.getContext (), LoadStoreVT );
4591
- } while (!TLI.isTypeLegal (LoadStoreVT ));
4590
+ LoadVT = TLI.getTypeToTransformTo (*DAG.getContext (), LoadVT );
4591
+ } while (!TLI.isTypeLegal (LoadVT ));
4592
4592
4593
- const unsigned ShiftUnitInBits = LoadStoreVT.getStoreSize () * 8 ;
4593
+ const unsigned ShiftUnitInBits = LoadVT.getStoreSize () * 8 ;
4594
+ assert (ShiftUnitInBits <= VT.getScalarSizeInBits ());
4594
4595
assert (isPowerOf2_32 (ShiftUnitInBits) &&
4595
4596
" Shifting unit is not a a power of two!" );
4597
+
4596
4598
const bool IsOneStepShift =
4597
4599
DAG.computeKnownBits (ShAmt).countMinTrailingZeros () >=
4598
4600
Log2_32 (ShiftUnitInBits);
@@ -4613,7 +4615,11 @@ void DAGTypeLegalizer::ExpandIntRes_ShiftThroughStack(SDNode *N, SDValue &Lo,
4613
4615
4614
4616
// Get a temporary stack slot 2x the width of our VT.
4615
4617
// FIXME: reuse stack slots?
4616
- SDValue StackPtr = DAG.CreateStackTemporary (StackSlotVT);
4618
+ Align StackAlign = DAG.getReducedAlign (StackSlotVT, /* UseABI=*/ false );
4619
+ assert (DAG.getReducedAlign (LoadVT, /* UseABI=*/ false ) <= StackAlign);
4620
+
4621
+ SDValue StackPtr =
4622
+ DAG.CreateStackTemporary (StackSlotVT.getStoreSize (), StackAlign);
4617
4623
EVT PtrTy = StackPtr.getValueType ();
4618
4624
SDValue Ch = DAG.getEntryNode ();
4619
4625
@@ -4679,9 +4685,10 @@ void DAGTypeLegalizer::ExpandIntRes_ShiftThroughStack(SDNode *N, SDValue &Lo,
4679
4685
AdjStackPtr = DAG.getMemBasePlusOffset (AdjStackPtr, Offset, dl);
4680
4686
4681
4687
// And load it! While the load is not legal, legalizing it is obvious.
4682
- SDValue Res = DAG.getLoad (
4683
- VT, dl, Ch, AdjStackPtr,
4684
- MachinePointerInfo::getUnknownStack (DAG.getMachineFunction ()));
4688
+ SDValue Res =
4689
+ DAG.getLoad (VT, dl, Ch, AdjStackPtr,
4690
+ MachinePointerInfo::getUnknownStack (DAG.getMachineFunction ()),
4691
+ DAG.getReducedAlign (LoadVT, /* UseABI=*/ false ));
4685
4692
4686
4693
// If we may still have a remaining bits to shift by, do so now.
4687
4694
if (!IsOneStepShift) {
0 commit comments