[InstCombine] Fix visitSwitchInst to use right operand types for sub cstexpr
authorBruno Cardoso Lopes <bruno.cardoso@gmail.com>
Fri, 19 Dec 2014 14:23:15 +0000 (14:23 +0000)
committerBruno Cardoso Lopes <bruno.cardoso@gmail.com>
Fri, 19 Dec 2014 14:23:15 +0000 (14:23 +0000)
commitc9005f2f2bb17a8388788cee847e642277141c9d
treee181eb0ca868d9b0785bfe44d2849f0c8d67ec13
parentb01eee941d9a596ed625c7245c955aa5f684dd01
[InstCombine] Fix visitSwitchInst to use right operand types for sub cstexpr

The visitSwitchInst generates SUB constant expressions to recompute the
switch condition. When truncating the condition to a smaller type, SUB
expressions should use the previous type (before trunc) for both
operands. This fixes an assertion crash.

Differential Revision: http://reviews.llvm.org/D6644

rdar://problem/19191835

llvm-svn: 224574
llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
llvm/test/Transforms/InstCombine/narrow-switch.ll