diff options
author | Sanjay Patel <spatel@rotateright.com> | 2016-12-12 16:13:52 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2016-12-12 16:13:52 +0000 |
commit | e730ce87a50c1fbfc1a6a0828e472b0b2f67beab (patch) | |
tree | 4dfe3733aef71cb7b8d95cb494855856d1d66e73 /llvm/test/Transforms | |
parent | 040cc168355ab839053710f35fb039b4391ec5ec (diff) | |
download | bcm5719-llvm-e730ce87a50c1fbfc1a6a0828e472b0b2f67beab.tar.gz bcm5719-llvm-e730ce87a50c1fbfc1a6a0828e472b0b2f67beab.zip |
[InstCombine] fix bug when offsetting case values of a switch (PR31260)
We could truncate the condition and then try to fold the add into the
original condition value causing wrong case constants to be used.
Move the offset transform ahead of the truncate transform and return
after each transform, so there's no chance of getting confused values.
Fix for:
https://llvm.org/bugs/show_bug.cgi?id=31260
llvm-svn: 289442
Diffstat (limited to 'llvm/test/Transforms')
-rw-r--r-- | llvm/test/Transforms/InstCombine/narrow-switch.ll | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/llvm/test/Transforms/InstCombine/narrow-switch.ll b/llvm/test/Transforms/InstCombine/narrow-switch.ll index e58b4956568..8f4c24b9deb 100644 --- a/llvm/test/Transforms/InstCombine/narrow-switch.ll +++ b/llvm/test/Transforms/InstCombine/narrow-switch.ll @@ -135,10 +135,11 @@ sw.default: define i8 @PR31260(i8 %x) { ; ALL-LABEL: @PR31260( ; ALL-NEXT: entry: -; ALL-NEXT: [[T4:%.*]] = and i8 %x, 2 -; ALL-NEXT: switch i8 [[T4]], label %exit [ -; ALL-NEXT: i8 -128, label %case126 -; ALL-NEXT: i8 -126, label %case124 +; ALL-NEXT: [[TMP0:%.*]] = trunc i8 %x to i2 +; ALL-NEXT: [[TRUNC:%.*]] = and i2 [[TMP0]], -2 +; ALL-NEXT: switch i2 [[TRUNC]], label %exit [ +; ALL-NEXT: i2 0, label %case126 +; ALL-NEXT: i2 -2, label %case124 ; ALL-NEXT: ] ; ALL: exit: ; ALL-NEXT: ret i8 1 |