1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=x86_64-- -mattr=+slow-3ops-lea | FileCheck %s -check-prefixes=CHECK,SLOW
3 ; RUN: llc < %s -mtriple=x86_64-- -mattr=-slow-3ops-lea | FileCheck %s -check-prefixes=CHECK,FAST
5 define i16 @and_i8_zext_shl_add_i16(i16 %t0, i8 %t1) {
6 ; CHECK-LABEL: and_i8_zext_shl_add_i16:
8 ; CHECK-NEXT: # kill: def $esi killed $esi def $rsi
9 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
10 ; CHECK-NEXT: andl $8, %esi
11 ; CHECK-NEXT: leal (%rdi,%rsi,4), %eax
12 ; CHECK-NEXT: # kill: def $ax killed $ax killed $eax
15 %t5 = zext i8 %t4 to i16
17 %t6 = add i16 %sh, %t0
21 define i16 @and_i8_shl_zext_add_i16(i16 %t0, i8 %t1) {
22 ; CHECK-LABEL: and_i8_shl_zext_add_i16:
24 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
25 ; CHECK-NEXT: andb $8, %sil
26 ; CHECK-NEXT: movzbl %sil, %eax
27 ; CHECK-NEXT: leal (%rdi,%rax,4), %eax
28 ; CHECK-NEXT: # kill: def $ax killed $ax killed $eax
32 %t5 = zext i8 %sh to i16
33 %t6 = add i16 %t5, %t0
37 define i32 @and_i8_zext_shl_add_i32(i32 %t0, i8 %t1) {
38 ; CHECK-LABEL: and_i8_zext_shl_add_i32:
40 ; CHECK-NEXT: # kill: def $esi killed $esi def $rsi
41 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
42 ; CHECK-NEXT: andl $8, %esi
43 ; CHECK-NEXT: leal (%rdi,%rsi,8), %eax
46 %t5 = zext i8 %t4 to i32
48 %t6 = add i32 %sh, %t0
52 define i32 @and_i8_shl_zext_add_i32(i32 %t0, i8 %t1) {
53 ; CHECK-LABEL: and_i8_shl_zext_add_i32:
55 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
56 ; CHECK-NEXT: andb $8, %sil
57 ; CHECK-NEXT: movzbl %sil, %eax
58 ; CHECK-NEXT: leal (%rdi,%rax,8), %eax
62 %t5 = zext i8 %sh to i32
63 %t6 = add i32 %t5, %t0
67 define i32 @and_i16_zext_shl_add_i32(i32 %t0, i16 %t1) {
68 ; CHECK-LABEL: and_i16_zext_shl_add_i32:
70 ; CHECK-NEXT: # kill: def $esi killed $esi def $rsi
71 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
72 ; CHECK-NEXT: andl $8, %esi
73 ; CHECK-NEXT: leal (%rdi,%rsi,4), %eax
76 %t5 = zext i16 %t4 to i32
78 %t6 = add i32 %sh, %t0
82 define i32 @and_i16_shl_zext_add_i32(i32 %t0, i16 %t1) {
83 ; CHECK-LABEL: and_i16_shl_zext_add_i32:
85 ; CHECK-NEXT: # kill: def $esi killed $esi def $rsi
86 ; CHECK-NEXT: # kill: def $edi killed $edi def $rdi
87 ; CHECK-NEXT: andl $8, %esi
88 ; CHECK-NEXT: leal (%rdi,%rsi,4), %eax
92 %t5 = zext i16 %sh to i32
93 %t6 = add i32 %t5, %t0
97 define i64 @and_i8_zext_shl_add_i64(i64 %t0, i8 %t1) {
98 ; CHECK-LABEL: and_i8_zext_shl_add_i64:
100 ; CHECK-NEXT: # kill: def $esi killed $esi def $rsi
101 ; CHECK-NEXT: andl $8, %esi
102 ; CHECK-NEXT: leaq (%rdi,%rsi,2), %rax
105 %t5 = zext i8 %t4 to i64
107 %t6 = add i64 %sh, %t0
111 define i64 @and_i8_shl_zext_add_i64(i64 %t0, i8 %t1) {
112 ; CHECK-LABEL: and_i8_shl_zext_add_i64:
114 ; CHECK-NEXT: andb $8, %sil
115 ; CHECK-NEXT: movzbl %sil, %eax
116 ; CHECK-NEXT: leaq (%rdi,%rax,2), %rax
120 %t5 = zext i8 %sh to i64
121 %t6 = add i64 %t5, %t0
125 define i64 @and_i32_zext_shl_add_i64(i64 %t0, i32 %t1) {
126 ; CHECK-LABEL: and_i32_zext_shl_add_i64:
128 ; CHECK-NEXT: # kill: def $esi killed $esi def $rsi
129 ; CHECK-NEXT: andl $8, %esi
130 ; CHECK-NEXT: leaq (%rdi,%rsi,8), %rax
133 %t5 = zext i32 %t4 to i64
135 %t6 = add i64 %sh, %t0
139 define i64 @and_i32_shl_zext_add_i64(i64 %t0, i32 %t1) {
140 ; CHECK-LABEL: and_i32_shl_zext_add_i64:
142 ; CHECK-NEXT: # kill: def $esi killed $esi def $rsi
143 ; CHECK-NEXT: andl $8, %esi
144 ; CHECK-NEXT: leaq (%rdi,%rsi,8), %rax
148 %t5 = zext i32 %sh to i64
149 %t6 = add i64 %t5, %t0
153 ; Negative test - shift can't be converted to scale factor.
155 define i64 @and_i32_zext_shl_add_i64_overshift(i64 %t0, i32 %t1) {
156 ; CHECK-LABEL: and_i32_zext_shl_add_i64_overshift:
158 ; CHECK-NEXT: # kill: def $esi killed $esi def $rsi
159 ; CHECK-NEXT: andl $8, %esi
160 ; CHECK-NEXT: shlq $4, %rsi
161 ; CHECK-NEXT: leaq (%rsi,%rdi), %rax
164 %t5 = zext i32 %t4 to i64
166 %t6 = add i64 %sh, %t0
170 define i64 @and_i32_shl_zext_add_i64_overshift(i64 %t0, i32 %t1) {
171 ; CHECK-LABEL: and_i32_shl_zext_add_i64_overshift:
173 ; CHECK-NEXT: # kill: def $esi killed $esi def $rsi
174 ; CHECK-NEXT: andl $8, %esi
175 ; CHECK-NEXT: shll $4, %esi
176 ; CHECK-NEXT: leaq (%rsi,%rdi), %rax
180 %t5 = zext i32 %sh to i64
181 %t6 = add i64 %t5, %t0