diff options
author | Chris Lattner <sabre@nondot.org> | 2008-10-05 02:13:19 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2008-10-05 02:13:19 +0000 |
commit | 8c34cd287a07d80491cde1e86da98568675dbe47 (patch) | |
tree | ad51896850efea222cb34d404df331635079ecd8 /test/Transforms/InstCombine/bswap.ll | |
parent | 8256d75f84b595dc29828819791b79d45fcaae81 (diff) | |
download | llvm-8c34cd287a07d80491cde1e86da98568675dbe47.tar.gz llvm-8c34cd287a07d80491cde1e86da98568675dbe47.tar.bz2 llvm-8c34cd287a07d80491cde1e86da98568675dbe47.tar.xz |
rewrite bswap matching to be more general, allowing arbitrary
shifting and masking inside a bswap expr. This allows it to handle
the cases from PR2842, which involve the intermediate 'or'
expressions being shifted, not just the input value.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@57095 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/InstCombine/bswap.ll')
-rw-r--r-- | test/Transforms/InstCombine/bswap.ll | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/test/Transforms/InstCombine/bswap.ll b/test/Transforms/InstCombine/bswap.ll index 5db4e73a54..2ba718e584 100644 --- a/test/Transforms/InstCombine/bswap.ll +++ b/test/Transforms/InstCombine/bswap.ll @@ -1,5 +1,5 @@ ; RUN: llvm-as < %s | opt -instcombine | llvm-dis | \ -; RUN: grep {call.*llvm.bswap} | count 5 +; RUN: grep {call.*llvm.bswap} | count 6 define i32 @test1(i32 %i) { %tmp1 = lshr i32 %i, 24 ; <i32> [#uses=1] @@ -55,3 +55,18 @@ define i16 @test5(i16 %a) { %retval = trunc i32 %tmp6.upgrd.4 to i16 ; <i16> [#uses=1] ret i16 %retval } + +; PR2842 +define i32 @test6(i32 %x) nounwind readnone { + %tmp = shl i32 %x, 16 ; <i32> [#uses=1] + %x.mask = and i32 %x, 65280 ; <i32> [#uses=1] + %tmp1 = lshr i32 %x, 16 ; <i32> [#uses=1] + %tmp2 = and i32 %tmp1, 255 ; <i32> [#uses=1] + %tmp3 = or i32 %x.mask, %tmp ; <i32> [#uses=1] + %tmp4 = or i32 %tmp3, %tmp2 ; <i32> [#uses=1] + %tmp5 = shl i32 %tmp4, 8 ; <i32> [#uses=1] + %tmp6 = lshr i32 %x, 24 ; <i32> [#uses=1] + %tmp7 = or i32 %tmp5, %tmp6 ; <i32> [#uses=1] + ret i32 %tmp7 +} + |