diff options
author | Evan Cheng <evan.cheng@apple.com> | 2008-08-30 02:03:58 +0000 |
---|---|---|
committer | Evan Cheng <evan.cheng@apple.com> | 2008-08-30 02:03:58 +0000 |
commit | eb9f89287e8ff3daeb9191ecd0cc3241a4f4137d (patch) | |
tree | 87faea68b182e4ad706a5115bc95457bf923685d /test/CodeGen | |
parent | dcf114e8610784e15c89eed2ad3ca930fa0634ed (diff) | |
download | external_llvm-eb9f89287e8ff3daeb9191ecd0cc3241a4f4137d.zip external_llvm-eb9f89287e8ff3daeb9191ecd0cc3241a4f4137d.tar.gz external_llvm-eb9f89287e8ff3daeb9191ecd0cc3241a4f4137d.tar.bz2 |
Transform (x << (y&31)) -> (x << y). This takes advantage of the fact x86 shift instructions 2nd operand (shift count) is limited to 0 to 31 (or 63 in the x86-64 case).
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55558 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen')
-rw-r--r-- | test/CodeGen/X86/shift-and.ll | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/CodeGen/X86/shift-and.ll b/test/CodeGen/X86/shift-and.ll new file mode 100644 index 0000000..b6d78a4 --- /dev/null +++ b/test/CodeGen/X86/shift-and.ll @@ -0,0 +1,24 @@ +; RUN: llvm-as < %s | llc -march=x86 | grep and | count 1 +; RUN: llvm-as < %s | llc -march=x86-64 | not grep and + +define i32 @t1(i32 %t, i32 %val) nounwind { + %shamt = and i32 %t, 31 + %res = shl i32 %val, %shamt + ret i32 %res +} + +@X = internal global i16 0 + +define void @t2(i16 %t) nounwind { + %shamt = and i16 %t, 31 + %tmp = load i16* @X + %tmp1 = ashr i16 %tmp, %shamt + store i16 %tmp1, i16* @X + ret void +} + +define i64 @t3(i64 %t, i64 %val) nounwind { + %shamt = and i64 %t, 63 + %res = lshr i64 %val, %shamt + ret i64 %res +} |