summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
diff options
context:
space:
mode:
authorOwen Anderson <resistor@mac.com>2015-03-10 06:51:39 +0000
committerOwen Anderson <resistor@mac.com>2015-03-10 06:51:39 +0000
commit58364dc4dac58fbf0a3bb7cbf54d9bc9dfed550c (patch)
tree0c50a71ffc75b1339b101bdd7a1aa0a52fed39f5 /llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
parente90f992b219850f06ea6c236e73de4c6725a3dd7 (diff)
downloadbcm5719-llvm-58364dc4dac58fbf0a3bb7cbf54d9bc9dfed550c.tar.gz
bcm5719-llvm-58364dc4dac58fbf0a3bb7cbf54d9bc9dfed550c.zip
Fix a crash in InstCombine where we could try to truncate a switch comparison to zero width.
llvm-svn: 231761
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstructionCombining.cpp')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstructionCombining.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index 9e8b5774517..1fe036b5fbb 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -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);
OpenPOWER on IntegriCloud