Fix a crash in InstCombine where we could try to truncate a switch comparison to zero width.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@231761 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
Owen Anderson 2015-03-10 06:51:39 +00:00
parent bb6a88c25d
commit 3a3665fd38
2 changed files with 9 additions and 1 deletions

View File

@ -2060,7 +2060,8 @@ Instruction *InstCombiner::visitSwitchInst(SwitchInst &SI) {
// x86 generates redundant zero-extenstion instructions if the operand is
// truncated to i8 or i16.
bool TruncCond = false;
if (BitWidth > NewWidth && NewWidth >= DL.getLargestLegalIntTypeSize()) {
if (NewWidth > 0 && BitWidth > NewWidth &&
NewWidth >= DL.getLargestLegalIntTypeSize()) {
TruncCond = true;
IntegerType *Ty = IntegerType::get(SI.getContext(), NewWidth);
Builder->SetInsertPoint(&SI);

View File

@ -0,0 +1,7 @@
; RUN: opt -instcombine < %s
define void @test() {
switch i32 0, label %out [i32 0, label %out]
out:
ret void
}