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

Found when testing with llvm-stress on i686 targets.

llvm-svn: 236954
This commit is contained in:
Simon Pilgrim 2015-05-10 14:14:51 +00:00
parent c34f847b80
commit e09584ca95
1 changed files with 3 additions and 2 deletions

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.