[DAGCombiner] Prevent the combine added in r367710 from creating illegal types after type legalization.

This is further fix for PR42880.

Sanjay already disabled the X86 TLI hook for non-simple types,
but we should really call isTypeLegal here if we're after type
legalization.

llvm-svn: 367768
This commit is contained in:
Craig Topper 2019-08-03 23:09:13 +00:00
parent fe37499207
commit 2edeb8a11a

View File

@ -7631,7 +7631,7 @@ SDValue DAGCombiner::visitSRA(SDNode *N) {
EVT TruncVT = EVT::getIntegerVT(Ctx, OpSizeInBits - ShiftAmt);
if (VT.isVector())
TruncVT = EVT::getVectorVT(Ctx, TruncVT, VT.getVectorNumElements());
if (TLI.isTruncateFree(VT, TruncVT)) {
if (isTypeLegal(TruncVT) && TLI.isTruncateFree(VT, TruncVT)) {
SDLoc DL(N);
SDValue Trunc = DAG.getZExtOrTrunc(Shl.getOperand(0), DL, TruncVT);
SDValue ShiftC = DAG.getConstant(AddC->getAPIntValue().lshr(ShiftAmt).