From e09584ca9581f78b968a30a09debe699286cace4 Mon Sep 17 00:00:00 2001 From: Simon Pilgrim Date: Sun, 10 May 2015 14:14:51 +0000 Subject: [PATCH] [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 --- llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index 1d8cdb60c92d..73fe19907110 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -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.