[X86] Add some broadcast-from-memory tests.
[oota-llvm.git] / test / CodeGen / X86 / machine-combiner-int.ll
1 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mcpu=x86-64 | FileCheck %s
2 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mcpu=x86-64 -stop-after machine-combiner -o /dev/null 2>&1 | FileCheck %s --check-prefix=DEAD
3
4 ; Verify that integer multiplies are reassociated. The first multiply in 
5 ; each test should be independent of the result of the preceding add (lea).
6
7 define i16 @reassociate_muls_i16(i16 %x0, i16 %x1, i16 %x2, i16 %x3) {
8 ; CHECK-LABEL: reassociate_muls_i16:
9 ; CHECK:       # BB#0:
10 ; CHECK-NEXT:    leal   (%rdi,%rsi), %eax
11 ; CHECK-NEXT:    imull  %ecx, %edx
12 ; CHECK-NEXT:    imull  %edx, %eax
13 ; CHECK-NEXT:    retq
14   %t0 = add i16 %x0, %x1
15   %t1 = mul i16 %x2, %t0
16   %t2 = mul i16 %x3, %t1
17   ret i16 %t2
18 }
19
20 define i32 @reassociate_muls_i32(i32 %x0, i32 %x1, i32 %x2, i32 %x3) {
21 ; CHECK-LABEL: reassociate_muls_i32:
22 ; CHECK:       # BB#0:
23 ; CHECK-NEXT:    leal   (%rdi,%rsi), %eax
24 ; CHECK-NEXT:    imull  %ecx, %edx
25 ; CHECK-NEXT:    imull  %edx, %eax
26 ; CHECK-NEXT:    retq
27
28 ; DEAD:       ADD32rr
29 ; DEAD-NEXT:  IMUL32rr{{.*}}implicit-def dead %eflags
30 ; DEAD-NEXT:  IMUL32rr{{.*}}implicit-def dead %eflags
31
32   %t0 = add i32 %x0, %x1
33   %t1 = mul i32 %x2, %t0
34   %t2 = mul i32 %x3, %t1
35   ret i32 %t2
36 }
37
38 define i64 @reassociate_muls_i64(i64 %x0, i64 %x1, i64 %x2, i64 %x3) {
39 ; CHECK-LABEL: reassociate_muls_i64:
40 ; CHECK:       # BB#0:
41 ; CHECK-NEXT:    leaq   (%rdi,%rsi), %rax
42 ; CHECK-NEXT:    imulq  %rcx, %rdx
43 ; CHECK-NEXT:    imulq  %rdx, %rax
44 ; CHECK-NEXT:    retq
45   %t0 = add i64 %x0, %x1
46   %t1 = mul i64 %x2, %t0
47   %t2 = mul i64 %x3, %t1
48   ret i64 %t2
49 }