diff options
| author | Davide Italiano <davide@freebsd.org> | 2017-05-21 20:30:27 +0000 |
|---|---|---|
| committer | Davide Italiano <davide@freebsd.org> | 2017-05-21 20:30:27 +0000 |
| commit | 21a49dcdf19e9df75015d2618400e9fde2e579fc (patch) | |
| tree | d06ec7d98363ba7e5b965cd08d5b2c256db49368 /llvm/test/Transforms/InstCombine | |
| parent | a3f75469311c68b3d0d4b79df6cac5941c6a9202 (diff) | |
| download | bcm5719-llvm-21a49dcdf19e9df75015d2618400e9fde2e579fc.tar.gz bcm5719-llvm-21a49dcdf19e9df75015d2618400e9fde2e579fc.zip | |
[InstCombine] Take in account the size in sext->lshr->trunc patterns.
Otherwise we end up miscompiling, transforming:
define i8 @tinky() {
%sext = sext i1 1 to i16
%hibit = lshr i16 %sext, 15
%tr = trunc i16 %hibit to i8
ret i8 %tr
}
into:
%sext = sext i1 1 to i8
ret i8 %sext
and the first get folded to ret i8 1, while the second gets folded
to ret i8 -1.
Eventually we should get rid of this transform entirely, but for now,
this at least fixes a know correctness bug.
Differential Revision: https://reviews.llvm.org/D33338
llvm-svn: 303513
Diffstat (limited to 'llvm/test/Transforms/InstCombine')
| -rw-r--r-- | llvm/test/Transforms/InstCombine/cast.ll | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/llvm/test/Transforms/InstCombine/cast.ll b/llvm/test/Transforms/InstCombine/cast.ll index 2f15617e065..486a617097e 100644 --- a/llvm/test/Transforms/InstCombine/cast.ll +++ b/llvm/test/Transforms/InstCombine/cast.ll @@ -1513,8 +1513,9 @@ define i4 @pr33078_3(i8 %A) { define i8 @pr33078_4(i3 %x) { ; Don't turn this in an `ashr`. This was getting miscompiled ; CHECK-LABEL: @pr33078_4( -; CHECK-NEXT: [[C:%.*]] = ashr i3 %x, 2 -; CHECK-NEXT: [[B:%.*]] = sext i3 [[C]] to i8 +; CHECK-NEXT: [[B:%.*]] = sext i3 %x to i16 +; CHECK-NEXT: [[C:%.*]] = lshr i16 [[B]], 13 +; CHECK-NEXT: [[D:%.*]] = trunc i16 [[C]] to i8 ; CHECK-NEXT: ret i8 [[D]] %B = sext i3 %x to i16 %C = lshr i16 %B, 13 |

