diff options
author | Chris Lattner <sabre@nondot.org> | 2003-11-03 05:42:50 +0000 |
---|---|---|
committer | Chris Lattner <sabre@nondot.org> | 2003-11-03 05:42:50 +0000 |
commit | 5fecdecda49e85050333683f8d08db98f264e352 (patch) | |
tree | 61dd7371c97cfff7a2b5795a5df7d4eea4bacf62 /test/Transforms/InstCombine/bit-tracking.ll | |
parent | 4d3ba7397f8289e70caa8c462a2b214f89293c45 (diff) | |
download | external_llvm-5fecdecda49e85050333683f8d08db98f264e352.zip external_llvm-5fecdecda49e85050333683f8d08db98f264e352.tar.gz external_llvm-5fecdecda49e85050333683f8d08db98f264e352.tar.bz2 |
More testcases
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@9675 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/InstCombine/bit-tracking.ll')
-rw-r--r-- | test/Transforms/InstCombine/bit-tracking.ll | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/test/Transforms/InstCombine/bit-tracking.ll b/test/Transforms/InstCombine/bit-tracking.ll index 10d1cc2..06cf65c 100644 --- a/test/Transforms/InstCombine/bit-tracking.ll +++ b/test/Transforms/InstCombine/bit-tracking.ll @@ -16,3 +16,32 @@ bool %test1(int %A, int %B) { ret bool %ELIM3 } +; See if we can eliminate the shifts... +int %test2(int %B) { + %ELIM1 = shl int %B, ubyte 31 + %ELIM2 = shr int %ELIM1, ubyte 31 + %inc = add int %ELIM2, 1 ; == xor int %B, 1 + ret int %inc +} + +; Reduce down to a single XOR +int %test3(int %B) { + %ELIMinc = and int %B, 1 + %tmp.5 = xor int %ELIMinc, 1 + %ELIM7 = and int %B, -2 + %tmp.8 = or int %tmp.5, %ELIM7 + ret int %tmp.8 +} + +; Finally, a bigger case where we chain things together. This corresponds to +; incrementing a single-bit bitfield, which should become just an xor. +int %test4(int %B) { + %ELIM3 = shl int %B, ubyte 31 + %ELIM4 = shr int %ELIM3, ubyte 31 + %inc = add int %ELIM4, 1 + %ELIM5 = and int %inc, 1 + %ELIM7 = and int %B, -2 + %tmp.8 = or int %ELIM5, %ELIM7 + ret int %tmp.8 +} + |