[SelectionDAG] Fixed constant folding issue when legalised types are smaller then the folded type.

Found when testing with llvm-stress on i686 targets.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@236954 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Simon Pilgrim 2015-05-10 14:14:51 +00:00
parent 6c318f59b1
commit a0adcdb9ce

View File

@ -2872,11 +2872,12 @@ SDValue SelectionDAG::getNode(unsigned Opcode, SDLoc DL,
EVT InVT = BV->getValueType(0);
EVT InSVT = InVT.getScalarType();
// Find legal integer scalar type for constant promotion.
// Find legal integer scalar type for constant promotion and
// ensure that its scalar size is at least as large as source.
EVT LegalSVT = SVT;
if (SVT.isInteger()) {
LegalSVT = TLI->getTypeToTransformTo(*getContext(), SVT);
assert(LegalSVT.bitsGE(SVT) && "Unexpected legal scalar type size");
if (LegalSVT.bitsLT(SVT)) break;
}
// Let the above scalar folding handle the folding of each element.