forked from OSchip/llvm-project
Fix a crash in InstCombine where we could try to truncate a switch comparison to zero width.
llvm-svn: 231761
This commit is contained in:
parent
e90f992b21
commit
58364dc4da
|
@ -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);
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
; RUN: opt -instcombine < %s
|
||||
|
||||
define void @test() {
|
||||
switch i32 0, label %out [i32 0, label %out]
|
||||
out:
|
||||
ret void
|
||||
}
|
Loading…
Reference in New Issue