1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+bmi,+bmi2 | FileCheck %s --check-prefixes=CHECK,X86
3 ; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+bmi,+bmi2 | FileCheck %s --check-prefixes=CHECK,X64
5 define i32 @bzhi32(i32 %x, i32 %y) {
8 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
9 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
10 ; X86-NEXT: addl %ecx, %ecx
11 ; X86-NEXT: bzhil %eax, %ecx, %eax
16 ; X64-NEXT: addl %edi, %edi
17 ; X64-NEXT: bzhil %esi, %edi, %eax
20 %tmp = tail call i32 @llvm.x86.bmi.bzhi.32(i32 %x1, i32 %y)
24 define i32 @bzhi32_load(i32* %x, i32 %y) {
25 ; X86-LABEL: bzhi32_load:
27 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
28 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
29 ; X86-NEXT: bzhil %eax, (%ecx), %eax
32 ; X64-LABEL: bzhi32_load:
34 ; X64-NEXT: bzhil %esi, (%rdi), %eax
36 %x1 = load i32, i32* %x
37 %tmp = tail call i32 @llvm.x86.bmi.bzhi.32(i32 %x1, i32 %y)
41 declare i32 @llvm.x86.bmi.bzhi.32(i32, i32)
43 define i32 @pdep32(i32 %x, i32 %y) {
46 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
47 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
48 ; X86-NEXT: addl %ecx, %ecx
49 ; X86-NEXT: pdepl %ecx, %eax, %eax
54 ; X64-NEXT: addl %esi, %esi
55 ; X64-NEXT: pdepl %esi, %edi, %eax
58 %tmp = tail call i32 @llvm.x86.bmi.pdep.32(i32 %x, i32 %y1)
62 define i32 @pdep32_load(i32 %x, i32* %y) {
63 ; X86-LABEL: pdep32_load:
65 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
66 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
67 ; X86-NEXT: pdepl (%eax), %ecx, %eax
70 ; X64-LABEL: pdep32_load:
72 ; X64-NEXT: pdepl (%rsi), %edi, %eax
74 %y1 = load i32, i32* %y
75 %tmp = tail call i32 @llvm.x86.bmi.pdep.32(i32 %x, i32 %y1)
79 declare i32 @llvm.x86.bmi.pdep.32(i32, i32)
81 define i32 @pext32(i32 %x, i32 %y) {
84 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
85 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
86 ; X86-NEXT: addl %ecx, %ecx
87 ; X86-NEXT: pextl %ecx, %eax, %eax
92 ; X64-NEXT: addl %esi, %esi
93 ; X64-NEXT: pextl %esi, %edi, %eax
96 %tmp = tail call i32 @llvm.x86.bmi.pext.32(i32 %x, i32 %y1)
100 define i32 @pext32_load(i32 %x, i32* %y) {
101 ; X86-LABEL: pext32_load:
103 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
104 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
105 ; X86-NEXT: pextl (%eax), %ecx, %eax
108 ; X64-LABEL: pext32_load:
110 ; X64-NEXT: pextl (%rsi), %edi, %eax
112 %y1 = load i32, i32* %y
113 %tmp = tail call i32 @llvm.x86.bmi.pext.32(i32 %x, i32 %y1)
117 declare i32 @llvm.x86.bmi.pext.32(i32, i32)
119 define i32 @mulx32(i32 %x, i32 %y, i32* %p) {
122 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
123 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
124 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
125 ; X86-NEXT: addl %eax, %eax
126 ; X86-NEXT: addl %edx, %edx
127 ; X86-NEXT: mull %edx
128 ; X86-NEXT: movl %edx, (%ecx)
133 ; X64-NEXT: movl %esi, %eax
134 ; X64-NEXT: # kill: def $edi killed $edi def $rdi
135 ; X64-NEXT: addl %edi, %edi
136 ; X64-NEXT: addl %eax, %eax
137 ; X64-NEXT: imulq %rdi, %rax
138 ; X64-NEXT: movq %rax, %rcx
139 ; X64-NEXT: shrq $32, %rcx
140 ; X64-NEXT: movl %ecx, (%rdx)
141 ; X64-NEXT: # kill: def $eax killed $eax killed $rax
145 %x2 = zext i32 %x1 to i64
146 %y2 = zext i32 %y1 to i64
147 %r1 = mul i64 %x2, %y2
148 %h1 = lshr i64 %r1, 32
149 %h = trunc i64 %h1 to i32
150 %l = trunc i64 %r1 to i32
151 store i32 %h, i32* %p
155 define i32 @mulx32_load(i32 %x, i32* %y, i32* %p) {
156 ; X86-LABEL: mulx32_load:
158 ; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx
159 ; X86-NEXT: movl {{[0-9]+}}(%esp), %edx
160 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
161 ; X86-NEXT: addl %eax, %eax
162 ; X86-NEXT: mull (%edx)
163 ; X86-NEXT: movl %edx, (%ecx)
166 ; X64-LABEL: mulx32_load:
168 ; X64-NEXT: movl %edi, %eax
169 ; X64-NEXT: addl %eax, %eax
170 ; X64-NEXT: movl (%rsi), %ecx
171 ; X64-NEXT: imulq %rcx, %rax
172 ; X64-NEXT: movq %rax, %rcx
173 ; X64-NEXT: shrq $32, %rcx
174 ; X64-NEXT: movl %ecx, (%rdx)
175 ; X64-NEXT: # kill: def $eax killed $eax killed $rax
178 %y1 = load i32, i32* %y
179 %x2 = zext i32 %x1 to i64
180 %y2 = zext i32 %y1 to i64
181 %r1 = mul i64 %x2, %y2
182 %h1 = lshr i64 %r1, 32
183 %h = trunc i64 %h1 to i32
184 %l = trunc i64 %r1 to i32
185 store i32 %h, i32* %p