1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc < %s -mtriple=i686-unknown -mattr=+sse2 | FileCheck %s --check-prefix=X86
3 ; RUN: llc < %s -mtriple=x86_64-unknown -mattr=+avx2 | FileCheck %s --check-prefix=X64
5 define i32 @test1(i32 %x) {
8 ; X86-NEXT: imull $-1030792151, {{[0-9]+}}(%esp), %eax # imm = 0xC28F5C29
13 ; X64-NEXT: imull $-1030792151, %edi, %eax # imm = 0xC28F5C29
15 %div = sdiv exact i32 %x, 25
19 define i32 @test2(i32 %x) {
22 ; X86-NEXT: movl {{[0-9]+}}(%esp), %eax
23 ; X86-NEXT: sarl $3, %eax
24 ; X86-NEXT: imull $-1431655765, %eax, %eax # imm = 0xAAAAAAAB
29 ; X64-NEXT: sarl $3, %edi
30 ; X64-NEXT: imull $-1431655765, %edi, %eax # imm = 0xAAAAAAAB
32 %div = sdiv exact i32 %x, 24
36 define <4 x i32> @test3(<4 x i32> %x) {
39 ; X86-NEXT: psrad $3, %xmm0
40 ; X86-NEXT: movdqa {{.*#+}} xmm1 = [2863311531,2863311531,2863311531,2863311531]
41 ; X86-NEXT: pshufd {{.*#+}} xmm2 = xmm0[1,1,3,3]
42 ; X86-NEXT: pmuludq %xmm1, %xmm0
43 ; X86-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,2,3]
44 ; X86-NEXT: pmuludq %xmm1, %xmm2
45 ; X86-NEXT: pshufd {{.*#+}} xmm1 = xmm2[0,2,2,3]
46 ; X86-NEXT: punpckldq {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
51 ; X64-NEXT: vpsrad $3, %xmm0, %xmm0
52 ; X64-NEXT: vpbroadcastd {{.*#+}} xmm1 = [2863311531,2863311531,2863311531,2863311531]
53 ; X64-NEXT: vpmulld %xmm1, %xmm0, %xmm0
55 %div = sdiv exact <4 x i32> %x, <i32 24, i32 24, i32 24, i32 24>
59 define <4 x i32> @test4(<4 x i32> %x) {
62 ; X86-NEXT: movdqa {{.*#+}} xmm1 = [3264175145,3264175145,3264175145,3264175145]
63 ; X86-NEXT: pshufd {{.*#+}} xmm2 = xmm0[1,1,3,3]
64 ; X86-NEXT: pmuludq %xmm1, %xmm0
65 ; X86-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,2,3]
66 ; X86-NEXT: pmuludq %xmm1, %xmm2
67 ; X86-NEXT: pshufd {{.*#+}} xmm1 = xmm2[0,2,2,3]
68 ; X86-NEXT: punpckldq {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
73 ; X64-NEXT: vpbroadcastd {{.*#+}} xmm1 = [3264175145,3264175145,3264175145,3264175145]
74 ; X64-NEXT: vpmulld %xmm1, %xmm0, %xmm0
76 %div = sdiv exact <4 x i32> %x, <i32 25, i32 25, i32 25, i32 25>
80 define <4 x i32> @test5(<4 x i32> %x) {
83 ; X86-NEXT: movdqa %xmm0, %xmm1
84 ; X86-NEXT: psrad $3, %xmm1
85 ; X86-NEXT: shufps {{.*#+}} xmm1 = xmm1[0,1],xmm0[2,3]
86 ; X86-NEXT: movdqa {{.*#+}} xmm2 = [2863311531,2863311531,3264175145,3264175145]
87 ; X86-NEXT: movaps %xmm1, %xmm0
88 ; X86-NEXT: pmuludq %xmm2, %xmm0
89 ; X86-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,2,3]
90 ; X86-NEXT: shufps {{.*#+}} xmm1 = xmm1[1,1,3,3]
91 ; X86-NEXT: pshufd {{.*#+}} xmm2 = xmm2[1,1,3,3]
92 ; X86-NEXT: pmuludq %xmm1, %xmm2
93 ; X86-NEXT: pshufd {{.*#+}} xmm1 = xmm2[0,2,2,3]
94 ; X86-NEXT: punpckldq {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
99 ; X64-NEXT: vpsravd {{.*}}(%rip), %xmm0, %xmm0
100 ; X64-NEXT: vpmulld {{.*}}(%rip), %xmm0, %xmm0
102 %div = sdiv exact <4 x i32> %x, <i32 24, i32 24, i32 25, i32 25>
106 define <4 x i32> @test6(<4 x i32> %x) {
109 ; X86-NEXT: movdqa %xmm0, %xmm1
110 ; X86-NEXT: psrad $3, %xmm1
111 ; X86-NEXT: psrad $1, %xmm0
112 ; X86-NEXT: movsd {{.*#+}} xmm0 = xmm1[0],xmm0[1]
113 ; X86-NEXT: movdqa {{.*#+}} xmm2 = [2863311531,2863311531,3303820997,3303820997]
114 ; X86-NEXT: movapd %xmm0, %xmm1
115 ; X86-NEXT: pmuludq %xmm2, %xmm1
116 ; X86-NEXT: pshufd {{.*#+}} xmm1 = xmm1[0,2,2,3]
117 ; X86-NEXT: shufps {{.*#+}} xmm0 = xmm0[1,1,3,3]
118 ; X86-NEXT: pshufd {{.*#+}} xmm2 = xmm2[1,1,3,3]
119 ; X86-NEXT: pmuludq %xmm0, %xmm2
120 ; X86-NEXT: pshufd {{.*#+}} xmm0 = xmm2[0,2,2,3]
121 ; X86-NEXT: punpckldq {{.*#+}} xmm1 = xmm1[0],xmm0[0],xmm1[1],xmm0[1]
122 ; X86-NEXT: movdqa %xmm1, %xmm0
127 ; X64-NEXT: vpsravd {{.*}}(%rip), %xmm0, %xmm0
128 ; X64-NEXT: vpmulld {{.*}}(%rip), %xmm0, %xmm0
130 %div = sdiv exact <4 x i32> %x, <i32 24, i32 24, i32 26, i32 26>
134 define <4 x i32> @test7(<4 x i32> %x) {
137 ; X86-NEXT: movdqa {{.*#+}} xmm1 = [3264175145,3264175145,1749801491,1749801491]
138 ; X86-NEXT: pshufd {{.*#+}} xmm2 = xmm0[1,1,3,3]
139 ; X86-NEXT: pmuludq %xmm1, %xmm0
140 ; X86-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,2,3]
141 ; X86-NEXT: pshufd {{.*#+}} xmm1 = xmm1[1,1,3,3]
142 ; X86-NEXT: pmuludq %xmm2, %xmm1
143 ; X86-NEXT: pshufd {{.*#+}} xmm1 = xmm1[0,2,2,3]
144 ; X86-NEXT: punpckldq {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
149 ; X64-NEXT: vpmulld {{.*}}(%rip), %xmm0, %xmm0
151 %div = sdiv exact <4 x i32> %x, <i32 25, i32 25, i32 27, i32 27>
155 define <4 x i32> @test8(<4 x i32> %x) {
158 ; X86-NEXT: movdqa %xmm0, %xmm1
159 ; X86-NEXT: psrad $3, %xmm1
160 ; X86-NEXT: movsd {{.*#+}} xmm1 = xmm0[0],xmm1[1]
161 ; X86-NEXT: movdqa {{.*#+}} xmm2 = [1,1,2863311531,2863311531]
162 ; X86-NEXT: movapd %xmm1, %xmm0
163 ; X86-NEXT: pmuludq %xmm2, %xmm0
164 ; X86-NEXT: pshufd {{.*#+}} xmm0 = xmm0[0,2,2,3]
165 ; X86-NEXT: shufps {{.*#+}} xmm1 = xmm1[1,1,3,3]
166 ; X86-NEXT: pshufd {{.*#+}} xmm2 = xmm2[1,1,3,3]
167 ; X86-NEXT: pmuludq %xmm1, %xmm2
168 ; X86-NEXT: pshufd {{.*#+}} xmm1 = xmm2[0,2,2,3]
169 ; X86-NEXT: punpckldq {{.*#+}} xmm0 = xmm0[0],xmm1[0],xmm0[1],xmm1[1]
174 ; X64-NEXT: vpsravd {{.*}}(%rip), %xmm0, %xmm0
175 ; X64-NEXT: vpmulld {{.*}}(%rip), %xmm0, %xmm0
177 %div = sdiv exact <4 x i32> %x, <i32 1, i32 1, i32 24, i32 24>