Reapply: [InstCombine] Fix visitSwitchInst to use right operand types for sub cstexpr
authorBruno Cardoso Lopes <bruno.cardoso@gmail.com>
Fri, 19 Dec 2014 17:12:35 +0000 (17:12 +0000)
committerBruno Cardoso Lopes <bruno.cardoso@gmail.com>
Fri, 19 Dec 2014 17:12:35 +0000 (17:12 +0000)
commit06833ca7c15feac86e32d1bc2f88bfbe22410f27
treeacb27ea6f9f917fe113981e2829c32fb61a52389
parentb8b0b8f0a836e951f0f1ebf790b65b4ec4c732c4
Reapply: [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. Also, fix code to also return the modified switch when only
the truncation is performed.

This fixes an assertion crash.

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

rdar://problem/19191835

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@224588 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstructionCombining.cpp
test/Transforms/InstCombine/narrow-switch.ll