summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen/X86/machine-combiner-int.ll
diff options
context:
space:
mode:
authorSanjay Patel <spatel@rotateright.com>2015-07-31 16:21:55 +0000
committerSanjay Patel <spatel@rotateright.com>2015-07-31 16:21:55 +0000
commit9ff4626028a1cea315a8105c170262ff8638ef9a (patch)
treee941a611ca95bc6b1fb4215f0c7b1ac580f965e1 /llvm/test/CodeGen/X86/machine-combiner-int.ll
parent47ea9ece1a17735d4f57f3dd84d86b9102b752cf (diff)
downloadbcm5719-llvm-9ff4626028a1cea315a8105c170262ff8638ef9a.tar.gz
bcm5719-llvm-9ff4626028a1cea315a8105c170262ff8638ef9a.zip
[x86] reassociate integer multiplies using machine combiner pass
Add i16, i32, i64 imul machine instructions to the list of reassociation candidates. A new bit of logic is needed to handle integer instructions: they have an implicit EFLAGS operand, so we have to make sure it's dead in order to do any reassociation with integer ops. Differential Revision: http://reviews.llvm.org/D11660 llvm-svn: 243756
Diffstat (limited to 'llvm/test/CodeGen/X86/machine-combiner-int.ll')
-rw-r--r--llvm/test/CodeGen/X86/machine-combiner-int.ll43
1 files changed, 43 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/X86/machine-combiner-int.ll b/llvm/test/CodeGen/X86/machine-combiner-int.ll
new file mode 100644
index 00000000000..2f3944f98b0
--- /dev/null
+++ b/llvm/test/CodeGen/X86/machine-combiner-int.ll
@@ -0,0 +1,43 @@
+; RUN: llc -mtriple=x86_64-unknown-unknown -mcpu=x86-64 < %s | FileCheck %s
+
+; Verify that integer multiplies are reassociated. The first multiply in
+; each test should be independent of the result of the preceding add (lea).
+
+define i16 @reassociate_muls_i16(i16 %x0, i16 %x1, i16 %x2, i16 %x3) {
+; CHECK-LABEL: reassociate_muls_i16:
+; CHECK: # BB#0:
+; CHECK-NEXT: leal (%rdi,%rsi), %eax
+; CHECK-NEXT: imull %ecx, %edx
+; CHECK-NEXT: imull %edx, %eax
+; CHECK-NEXT: retq
+ %t0 = add i16 %x0, %x1
+ %t1 = mul i16 %x2, %t0
+ %t2 = mul i16 %x3, %t1
+ ret i16 %t2
+}
+
+define i32 @reassociate_muls_i32(i32 %x0, i32 %x1, i32 %x2, i32 %x3) {
+; CHECK-LABEL: reassociate_muls_i32:
+; CHECK: # BB#0:
+; CHECK-NEXT: leal (%rdi,%rsi), %eax
+; CHECK-NEXT: imull %ecx, %edx
+; CHECK-NEXT: imull %edx, %eax
+; CHECK-NEXT: retq
+ %t0 = add i32 %x0, %x1
+ %t1 = mul i32 %x2, %t0
+ %t2 = mul i32 %x3, %t1
+ ret i32 %t2
+}
+
+define i64 @reassociate_muls_i64(i64 %x0, i64 %x1, i64 %x2, i64 %x3) {
+; CHECK-LABEL: reassociate_muls_i64:
+; CHECK: # BB#0:
+; CHECK-NEXT: leaq (%rdi,%rsi), %rax
+; CHECK-NEXT: imulq %rcx, %rdx
+; CHECK-NEXT: imulq %rdx, %rax
+; CHECK-NEXT: retq
+ %t0 = add i64 %x0, %x1
+ %t1 = mul i64 %x2, %t0
+ %t2 = mul i64 %x3, %t1
+ ret i64 %t2
+}
OpenPOWER on IntegriCloud