1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+sse,+sse2,+slow-lea,+slow-3ops-lea | FileCheck %s --check-prefixes=ALL,X86,X86-SLOWLEA
3 ; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+sse,+sse2,-slow-lea,-slow-3ops-lea | FileCheck %s --check-prefixes=ALL,X86,X86-FASTLEA
4 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse,+sse2,+slow-lea,+slow-3ops-lea | FileCheck %s --check-prefixes=ALL,X64
5 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse,+sse2,-slow-lea,-slow-3ops-lea | FileCheck %s --check-prefixes=ALL,X64
7 ; These two forms are equivalent:
10 ; Some targets may prefer one to the other.
12 define i8 @scalar_i8(i8 %x, i8 %y) nounwind {
13 ; X86-LABEL: scalar_i8:
15 ; X86-NEXT: movzbl {{[0-9]+}}(%esp), %eax
16 ; X86-NEXT: addb {{[0-9]+}}(%esp), %al
20 ; X64-LABEL: scalar_i8:
22 ; X64-NEXT: # kill: def $esi killed $esi def $rsi
23 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
24 ; X64-NEXT: leal (%rdi,%rsi), %eax
26 ; X64-NEXT: # kill: def $al killed $al killed $eax
33 define i16 @scalar_i16(i16 %x, i16 %y) nounwind {
34 ; X86-LABEL: scalar_i16:
36 ; X86-NEXT: movzwl {{[0-9]+}}(%esp), %eax
37 ; X86-NEXT: addw {{[0-9]+}}(%esp), %ax
39 ; X86-NEXT: # kill: def $ax killed $ax killed $eax
42 ; X64-LABEL: scalar_i16:
44 ; X64-NEXT: # kill: def $esi killed $esi def $rsi
45 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
46 ; X64-NEXT: leal 1(%rdi,%rsi), %eax
47 ; X64-NEXT: # kill: def $ax killed $ax killed $eax
54 define i32 @scalar_i32(i32 %x, i32 %y) nounwind {
55 ; X86-SLOWLEA-LABEL: scalar_i32:
56 ; X86-SLOWLEA: # %bb.0:
57 ; X86-SLOWLEA-NEXT: movl {{[0-9]+}}(%esp), %eax
58 ; X86-SLOWLEA-NEXT: movl {{[0-9]+}}(%esp), %ecx
59 ; X86-SLOWLEA-NEXT: addl %ecx, %eax
60 ; X86-SLOWLEA-NEXT: addl $1, %eax
61 ; X86-SLOWLEA-NEXT: retl
63 ; X86-FASTLEA-LABEL: scalar_i32:
64 ; X86-FASTLEA: # %bb.0:
65 ; X86-FASTLEA-NEXT: movl {{[0-9]+}}(%esp), %eax
66 ; X86-FASTLEA-NEXT: movl {{[0-9]+}}(%esp), %ecx
67 ; X86-FASTLEA-NEXT: leal 1(%ecx,%eax), %eax
68 ; X86-FASTLEA-NEXT: retl
70 ; X64-LABEL: scalar_i32:
72 ; X64-NEXT: # kill: def $esi killed $esi def $rsi
73 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
74 ; X64-NEXT: leal 1(%rdi,%rsi), %eax
81 define i64 @scalar_i64(i64 %x, i64 %y) nounwind {
82 ; X86-LABEL: scalar_i64:
84 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
85 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
86 ; X86-NEXT: addl {{[0-9]+}}(%esp), %eax
87 ; X86-NEXT: adcl {{[0-9]+}}(%esp), %edx
88 ; X86-NEXT: addl $1, %eax
89 ; X86-NEXT: adcl $0, %edx
92 ; X64-LABEL: scalar_i64:
94 ; X64-NEXT: leaq 1(%rdi,%rsi), %rax
101 define <16 x i8> @vector_i128_i8(<16 x i8> %x, <16 x i8> %y) nounwind {
102 ; ALL-LABEL: vector_i128_i8:
104 ; ALL-NEXT: paddb %xmm1, %xmm0
105 ; ALL-NEXT: pcmpeqd %xmm1, %xmm1
106 ; ALL-NEXT: psubb %xmm1, %xmm0
107 ; ALL-NEXT: ret{{[l|q]}}
108 %t0 = add <16 x i8> %x, <i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1, i8 1>
109 %t1 = add <16 x i8> %y, %t0
113 define <8 x i16> @vector_i128_i16(<8 x i16> %x, <8 x i16> %y) nounwind {
114 ; ALL-LABEL: vector_i128_i16:
116 ; ALL-NEXT: paddw %xmm1, %xmm0
117 ; ALL-NEXT: pcmpeqd %xmm1, %xmm1
118 ; ALL-NEXT: psubw %xmm1, %xmm0
119 ; ALL-NEXT: ret{{[l|q]}}
120 %t0 = add <8 x i16> %x, <i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1, i16 1>
121 %t1 = add <8 x i16> %y, %t0
125 define <4 x i32> @vector_i128_i32(<4 x i32> %x, <4 x i32> %y) nounwind {
126 ; ALL-LABEL: vector_i128_i32:
128 ; ALL-NEXT: paddd %xmm1, %xmm0
129 ; ALL-NEXT: pcmpeqd %xmm1, %xmm1
130 ; ALL-NEXT: psubd %xmm1, %xmm0
131 ; ALL-NEXT: ret{{[l|q]}}
132 %t0 = add <4 x i32> %x, <i32 1, i32 1, i32 1, i32 1>
133 %t1 = add <4 x i32> %y, %t0
137 define <2 x i64> @vector_i128_i64(<2 x i64> %x, <2 x i64> %y) nounwind {
138 ; ALL-LABEL: vector_i128_i64:
140 ; ALL-NEXT: paddq %xmm1, %xmm0
141 ; ALL-NEXT: pcmpeqd %xmm1, %xmm1
142 ; ALL-NEXT: psubq %xmm1, %xmm0
143 ; ALL-NEXT: ret{{[l|q]}}
144 %t0 = add <2 x i64> %x, <i64 1, i64 1>
145 %t1 = add <2 x i64> %y, %t0