summaryrefslogtreecommitdiffstats
path: root/llvm/test/CodeGen
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@intel.com>2018-07-25 01:15:35 +0000
committerCraig Topper <craig.topper@intel.com>2018-07-25 01:15:35 +0000
commit5be253d9886479f158904feeeebdce62a34019d4 (patch)
tree3f3fd9c9e5d3593311a7f5bfbbe389f0d46f6d09 /llvm/test/CodeGen
parentbae7367cd9942e832eaffe105ea42c170a0ed810 (diff)
downloadbcm5719-llvm-5be253d9886479f158904feeeebdce62a34019d4.tar.gz
bcm5719-llvm-5be253d9886479f158904feeeebdce62a34019d4.zip
[X86] Expand mul by pow2 + 2 using a shift and two adds similar to what we do for pow2 - 2.
llvm-svn: 337874
Diffstat (limited to 'llvm/test/CodeGen')
-rw-r--r--llvm/test/CodeGen/X86/mul-constant-i16.ll24
-rw-r--r--llvm/test/CodeGen/X86/mul-constant-i32.ll60
-rw-r--r--llvm/test/CodeGen/X86/mul-constant-i64.ll63
3 files changed, 147 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/X86/mul-constant-i16.ll b/llvm/test/CodeGen/X86/mul-constant-i16.ll
index d02086fe4f6..305867c8ad8 100644
--- a/llvm/test/CodeGen/X86/mul-constant-i16.ll
+++ b/llvm/test/CodeGen/X86/mul-constant-i16.ll
@@ -702,6 +702,30 @@ define i16 @test_mul_by_62(i16 %x) {
ret i16 %mul
}
+define i16 @test_mul_by_66(i16 %x) {
+; X86-LABEL: test_mul_by_66:
+; X86: # %bb.0:
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %ecx, %eax
+; X86-NEXT: shll $6, %eax
+; X86-NEXT: addl %ecx, %eax
+; X86-NEXT: addl %ecx, %eax
+; X86-NEXT: # kill: def $ax killed $ax killed $eax
+; X86-NEXT: retl
+;
+; X64-LABEL: test_mul_by_66:
+; X64: # %bb.0:
+; X64-NEXT: # kill: def $edi killed $edi def $rdi
+; X64-NEXT: movl %edi, %eax
+; X64-NEXT: shll $6, %eax
+; X64-NEXT: leal (%rax,%rdi), %eax
+; X64-NEXT: addl %edi, %eax
+; X64-NEXT: # kill: def $ax killed $ax killed $eax
+; X64-NEXT: retq
+ %mul = mul nsw i16 %x, 66
+ ret i16 %mul
+}
+
define i16 @test_mul_by_73(i16 %x) {
; X86-LABEL: test_mul_by_73:
; X86: # %bb.0:
diff --git a/llvm/test/CodeGen/X86/mul-constant-i32.ll b/llvm/test/CodeGen/X86/mul-constant-i32.ll
index 3c0c6c83392..658a6538bbd 100644
--- a/llvm/test/CodeGen/X86/mul-constant-i32.ll
+++ b/llvm/test/CodeGen/X86/mul-constant-i32.ll
@@ -1833,6 +1833,66 @@ define i32 @test_mul_by_62(i32 %x) {
ret i32 %mul
}
+define i32 @test_mul_by_66(i32 %x) {
+; X86-LABEL: test_mul_by_66:
+; X86: # %bb.0:
+; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
+; X86-NEXT: movl %ecx, %eax
+; X86-NEXT: shll $6, %eax
+; X86-NEXT: addl %ecx, %eax
+; X86-NEXT: addl %ecx, %eax
+; X86-NEXT: retl
+;
+; X64-HSW-LABEL: test_mul_by_66:
+; X64-HSW: # %bb.0:
+; X64-HSW-NEXT: # kill: def $edi killed $edi def $rdi
+; X64-HSW-NEXT: movl %edi, %eax # sched: [1:0.25]
+; X64-HSW-NEXT: shll $6, %eax # sched: [1:0.50]
+; X64-HSW-NEXT: leal (%rax,%rdi), %eax # sched: [1:0.50]
+; X64-HSW-NEXT: addl %edi, %eax # sched: [1:0.25]
+; X64-HSW-NEXT: retq # sched: [7:1.00]
+;
+; X64-JAG-LABEL: test_mul_by_66:
+; X64-JAG: # %bb.0:
+; X64-JAG-NEXT: # kill: def $edi killed $edi def $rdi
+; X64-JAG-NEXT: movl %edi, %eax # sched: [1:0.50]
+; X64-JAG-NEXT: shll $6, %eax # sched: [1:0.50]
+; X64-JAG-NEXT: leal (%rax,%rdi), %eax # sched: [1:0.50]
+; X64-JAG-NEXT: addl %edi, %eax # sched: [1:0.50]
+; X64-JAG-NEXT: retq # sched: [4:1.00]
+;
+; X86-NOOPT-LABEL: test_mul_by_66:
+; X86-NOOPT: # %bb.0:
+; X86-NOOPT-NEXT: imull $66, {{[0-9]+}}(%esp), %eax
+; X86-NOOPT-NEXT: retl
+;
+; HSW-NOOPT-LABEL: test_mul_by_66:
+; HSW-NOOPT: # %bb.0:
+; HSW-NOOPT-NEXT: imull $66, %edi, %eax # sched: [3:1.00]
+; HSW-NOOPT-NEXT: retq # sched: [7:1.00]
+;
+; JAG-NOOPT-LABEL: test_mul_by_66:
+; JAG-NOOPT: # %bb.0:
+; JAG-NOOPT-NEXT: imull $66, %edi, %eax # sched: [3:1.00]
+; JAG-NOOPT-NEXT: retq # sched: [4:1.00]
+;
+; X64-SLM-LABEL: test_mul_by_66:
+; X64-SLM: # %bb.0:
+; X64-SLM-NEXT: # kill: def $edi killed $edi def $rdi
+; X64-SLM-NEXT: movl %edi, %eax # sched: [1:0.50]
+; X64-SLM-NEXT: shll $6, %eax # sched: [1:1.00]
+; X64-SLM-NEXT: leal (%rax,%rdi), %eax # sched: [1:1.00]
+; X64-SLM-NEXT: addl %edi, %eax # sched: [1:0.50]
+; X64-SLM-NEXT: retq # sched: [4:1.00]
+;
+; SLM-NOOPT-LABEL: test_mul_by_66:
+; SLM-NOOPT: # %bb.0:
+; SLM-NOOPT-NEXT: imull $66, %edi, %eax # sched: [3:1.00]
+; SLM-NOOPT-NEXT: retq # sched: [4:1.00]
+ %mul = mul nsw i32 %x, 66
+ ret i32 %mul
+}
+
define i32 @test_mul_by_73(i32 %x) {
; X86-LABEL: test_mul_by_73:
; X86: # %bb.0:
diff --git a/llvm/test/CodeGen/X86/mul-constant-i64.ll b/llvm/test/CodeGen/X86/mul-constant-i64.ll
index d6e4ad35ac5..e0793380ab9 100644
--- a/llvm/test/CodeGen/X86/mul-constant-i64.ll
+++ b/llvm/test/CodeGen/X86/mul-constant-i64.ll
@@ -1932,6 +1932,69 @@ define i64 @test_mul_by_62(i64 %x) {
ret i64 %mul
}
+define i64 @test_mul_by_66(i64 %x) {
+; X86-LABEL: test_mul_by_66:
+; X86: # %bb.0:
+; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
+; X86-NEXT: movl %eax, %ecx
+; X86-NEXT: shll $6, %ecx
+; X86-NEXT: addl %eax, %ecx
+; X86-NEXT: addl %eax, %ecx
+; X86-NEXT: movl $66, %eax
+; X86-NEXT: mull {{[0-9]+}}(%esp)
+; X86-NEXT: addl %ecx, %edx
+; X86-NEXT: retl
+;
+; X64-HSW-LABEL: test_mul_by_66:
+; X64-HSW: # %bb.0:
+; X64-HSW-NEXT: movq %rdi, %rax # sched: [1:0.25]
+; X64-HSW-NEXT: shlq $6, %rax # sched: [1:0.50]
+; X64-HSW-NEXT: leaq (%rax,%rdi), %rax # sched: [1:0.50]
+; X64-HSW-NEXT: addq %rdi, %rax # sched: [1:0.25]
+; X64-HSW-NEXT: retq # sched: [7:1.00]
+;
+; X64-JAG-LABEL: test_mul_by_66:
+; X64-JAG: # %bb.0:
+; X64-JAG-NEXT: movq %rdi, %rax # sched: [1:0.50]
+; X64-JAG-NEXT: shlq $6, %rax # sched: [1:0.50]
+; X64-JAG-NEXT: leaq (%rax,%rdi), %rax # sched: [1:0.50]
+; X64-JAG-NEXT: addq %rdi, %rax # sched: [1:0.50]
+; X64-JAG-NEXT: retq # sched: [4:1.00]
+;
+; X86-NOOPT-LABEL: test_mul_by_66:
+; X86-NOOPT: # %bb.0:
+; X86-NOOPT-NEXT: movl $66, %eax
+; X86-NOOPT-NEXT: mull {{[0-9]+}}(%esp)
+; X86-NOOPT-NEXT: imull $66, {{[0-9]+}}(%esp), %ecx
+; X86-NOOPT-NEXT: addl %ecx, %edx
+; X86-NOOPT-NEXT: retl
+;
+; HSW-NOOPT-LABEL: test_mul_by_66:
+; HSW-NOOPT: # %bb.0:
+; HSW-NOOPT-NEXT: imulq $66, %rdi, %rax # sched: [3:1.00]
+; HSW-NOOPT-NEXT: retq # sched: [7:1.00]
+;
+; JAG-NOOPT-LABEL: test_mul_by_66:
+; JAG-NOOPT: # %bb.0:
+; JAG-NOOPT-NEXT: imulq $66, %rdi, %rax # sched: [6:4.00]
+; JAG-NOOPT-NEXT: retq # sched: [4:1.00]
+;
+; X64-SLM-LABEL: test_mul_by_66:
+; X64-SLM: # %bb.0:
+; X64-SLM-NEXT: movq %rdi, %rax # sched: [1:0.50]
+; X64-SLM-NEXT: shlq $6, %rax # sched: [1:1.00]
+; X64-SLM-NEXT: addq %rdi, %rax # sched: [1:0.50]
+; X64-SLM-NEXT: addq %rdi, %rax # sched: [1:0.50]
+; X64-SLM-NEXT: retq # sched: [4:1.00]
+;
+; SLM-NOOPT-LABEL: test_mul_by_66:
+; SLM-NOOPT: # %bb.0:
+; SLM-NOOPT-NEXT: imulq $66, %rdi, %rax # sched: [3:1.00]
+; SLM-NOOPT-NEXT: retq # sched: [4:1.00]
+ %mul = mul nsw i64 %x, 66
+ ret i64 %mul
+}
+
define i64 @test_mul_by_73(i64 %x) {
; X86-LABEL: test_mul_by_73:
; X86: # %bb.0:
OpenPOWER on IntegriCloud