diff options
| author | Chen Li <meloli87@gmail.com> | 2015-12-12 01:04:15 +0000 |
|---|---|---|
| committer | Chen Li <meloli87@gmail.com> | 2015-12-12 01:04:15 +0000 |
| commit | 1b26b9ec9dabb9d0a2fefbbfc3b10449f20d0dd1 (patch) | |
| tree | e09416c5dc802ade3fab3a91428f829f17ac5f92 /llvm/test | |
| parent | 4d3da9c29b46fd605706c69cb4cddf2ec786af84 (diff) | |
| download | bcm5719-llvm-1b26b9ec9dabb9d0a2fefbbfc3b10449f20d0dd1.tar.gz bcm5719-llvm-1b26b9ec9dabb9d0a2fefbbfc3b10449f20d0dd1.zip | |
[X86ISelLowering] Add additional support for multiplication-to-shift conversion.
Summary: This patch adds support of conversion (mul x, 2^N + 1) => (add (shl x, N), x) and (mul x, 2^N - 1) => (sub (shl x, N), x) if the multiplication can not be converted to LEA + SHL or LEA + LEA. LLVM has already supported this on ARM, and it should also be useful on X86. Note the patch currently only applies to cases where the constant operand is positive, and I am planing to add another patch to support negative cases after this.
Reviewers: craig.topper, RKSimon
Subscribers: aemerson, llvm-commits
Differential Revision: http://reviews.llvm.org/D14603
llvm-svn: 255415
Diffstat (limited to 'llvm/test')
| -rw-r--r-- | llvm/test/CodeGen/X86/imul.ll | 45 |
1 files changed, 45 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/X86/imul.ll b/llvm/test/CodeGen/X86/imul.ll index 99a4690a009..9d4d19332db 100644 --- a/llvm/test/CodeGen/X86/imul.ll +++ b/llvm/test/CodeGen/X86/imul.ll @@ -126,3 +126,48 @@ define i32 @mul40_32_minsize(i32 %A) minsize { %mul = mul i32 %A, 40 ret i32 %mul } + +define i32 @mul33_32(i32 %A) { +; X64-LABEL: mul33_32: +; X64: shll +; X64-NEXT: leal +; X86-LABEL: mul33_32: +; X86: shll +; X86-NEXT: addl + %mul = mul i32 %A, 33 + ret i32 %mul +} + +define i32 @mul31_32(i32 %A) { +; X64-LABEL: mul31_32: +; X64: shll +; X64-NEXT: subl +; X86-LABEL: mul31_32: +; X86: shll +; X86-NEXT: subl + %mul = mul i32 %A, 31 + ret i32 %mul +} + +define i32 @mul0_32(i32 %A) { +; X64-LABEL: mul0_32: +; X64: xorl %eax, %eax + %mul = mul i32 %A, 0 + ret i32 %mul +} + +define i32 @mul4294967295_32(i32 %A) { +; X64-LABEL: mul4294967295_32: +; X64: negl %edi +; X64-NEXT: movl %edi, %eax + %mul = mul i32 %A, 4294967295 + ret i32 %mul +} + +define i64 @mul18446744073709551615_64(i64 %A) { +; X64-LABEL: mul18446744073709551615_64: +; X64: negq %rdi +; X64-NEXT: movq %rdi, %rax + %mul = mul i64 %A, 18446744073709551615 + ret i64 %mul +} |

