• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 | FileCheck %s
3
4declare <2 x i64> @llvm.cttz.v2i64(<2 x i64>, i1)
5declare <2 x i64> @llvm.ctlz.v2i64(<2 x i64>, i1)
6declare <2 x i64> @llvm.ctpop.v2i64(<2 x i64>)
7
8define <2 x i64> @footz(<2 x i64> %a) nounwind {
9; CHECK-LABEL: footz:
10; CHECK:       # BB#0:
11; CHECK-NEXT:    movd %xmm0, %rax
12; CHECK-NEXT:    bsfq %rax, %rax
13; CHECK-NEXT:    movd %rax, %xmm1
14; CHECK-NEXT:    pshufd {{.*#+}} xmm0 = xmm0[2,3,0,1]
15; CHECK-NEXT:    movd %xmm0, %rax
16; CHECK-NEXT:    bsfq %rax, %rax
17; CHECK-NEXT:    movd %rax, %xmm0
18; CHECK-NEXT:    punpcklqdq {{.*#+}} xmm1 = xmm1[0],xmm0[0]
19; CHECK-NEXT:    movdqa %xmm1, %xmm0
20; CHECK-NEXT:    retq
21  %c = call <2 x i64> @llvm.cttz.v2i64(<2 x i64> %a, i1 true)
22  ret <2 x i64> %c
23
24}
25define <2 x i64> @foolz(<2 x i64> %a) nounwind {
26; CHECK-LABEL: foolz:
27; CHECK:       # BB#0:
28; CHECK-NEXT:    movd %xmm0, %rax
29; CHECK-NEXT:    bsrq %rax, %rax
30; CHECK-NEXT:    xorq $63, %rax
31; CHECK-NEXT:    movd %rax, %xmm1
32; CHECK-NEXT:    pshufd {{.*#+}} xmm0 = xmm0[2,3,0,1]
33; CHECK-NEXT:    movd %xmm0, %rax
34; CHECK-NEXT:    bsrq %rax, %rax
35; CHECK-NEXT:    xorq $63, %rax
36; CHECK-NEXT:    movd %rax, %xmm0
37; CHECK-NEXT:    punpcklqdq {{.*#+}} xmm1 = xmm1[0],xmm0[0]
38; CHECK-NEXT:    movdqa %xmm1, %xmm0
39; CHECK-NEXT:    retq
40  %c = call <2 x i64> @llvm.ctlz.v2i64(<2 x i64> %a, i1 true)
41  ret <2 x i64> %c
42
43}
44
45define <2 x i64> @foopop(<2 x i64> %a) nounwind {
46; CHECK-LABEL: foopop:
47; CHECK:       # BB#0:
48; CHECK-NEXT:    movdqa %xmm0, %xmm1
49; CHECK-NEXT:    psrlq $1, %xmm1
50; CHECK-NEXT:    pand {{.*}}(%rip), %xmm1
51; CHECK-NEXT:    psubq %xmm1, %xmm0
52; CHECK-NEXT:    movdqa {{.*#+}} xmm1 = [3689348814741910323,3689348814741910323]
53; CHECK-NEXT:    movdqa %xmm0, %xmm2
54; CHECK-NEXT:    pand %xmm1, %xmm2
55; CHECK-NEXT:    psrlq $2, %xmm0
56; CHECK-NEXT:    pand %xmm1, %xmm0
57; CHECK-NEXT:    paddq %xmm2, %xmm0
58; CHECK-NEXT:    movdqa %xmm0, %xmm1
59; CHECK-NEXT:    psrlq $4, %xmm1
60; CHECK-NEXT:    paddq %xmm0, %xmm1
61; CHECK-NEXT:    pand {{.*}}(%rip), %xmm1
62; CHECK-NEXT:    pxor %xmm0, %xmm0
63; CHECK-NEXT:    psadbw %xmm0, %xmm1
64; CHECK-NEXT:    movdqa %xmm1, %xmm0
65; CHECK-NEXT:    retq
66  %c = call <2 x i64> @llvm.ctpop.v2i64(<2 x i64> %a)
67  ret <2 x i64> %c
68}
69
70declare <2 x i32> @llvm.cttz.v2i32(<2 x i32>, i1)
71declare <2 x i32> @llvm.ctlz.v2i32(<2 x i32>, i1)
72declare <2 x i32> @llvm.ctpop.v2i32(<2 x i32>)
73
74define <2 x i32> @promtz(<2 x i32> %a) nounwind {
75; CHECK-LABEL: promtz:
76; CHECK:       # BB#0:
77; CHECK-NEXT:    por {{.*}}(%rip), %xmm0
78; CHECK-NEXT:    movd %xmm0, %rax
79; CHECK-NEXT:    bsfq %rax, %rax
80; CHECK-NEXT:    movl $64, %ecx
81; CHECK-NEXT:    cmoveq %rcx, %rax
82; CHECK-NEXT:    movd %rax, %xmm1
83; CHECK-NEXT:    pshufd {{.*#+}} xmm0 = xmm0[2,3,0,1]
84; CHECK-NEXT:    movd %xmm0, %rax
85; CHECK-NEXT:    bsfq %rax, %rax
86; CHECK-NEXT:    cmoveq %rcx, %rax
87; CHECK-NEXT:    movd %rax, %xmm0
88; CHECK-NEXT:    punpcklqdq {{.*#+}} xmm1 = xmm1[0],xmm0[0]
89; CHECK-NEXT:    movdqa %xmm1, %xmm0
90; CHECK-NEXT:    retq
91  %c = call <2 x i32> @llvm.cttz.v2i32(<2 x i32> %a, i1 false)
92  ret <2 x i32> %c
93
94}
95define <2 x i32> @promlz(<2 x i32> %a) nounwind {
96; CHECK-LABEL: promlz:
97; CHECK:       # BB#0:
98; CHECK-NEXT:    pand {{.*}}(%rip), %xmm0
99; CHECK-NEXT:    movd %xmm0, %rax
100; CHECK-NEXT:    bsrq %rax, %rax
101; CHECK-NEXT:    movl $127, %ecx
102; CHECK-NEXT:    cmoveq %rcx, %rax
103; CHECK-NEXT:    xorq $63, %rax
104; CHECK-NEXT:    movd %rax, %xmm1
105; CHECK-NEXT:    pshufd {{.*#+}} xmm0 = xmm0[2,3,0,1]
106; CHECK-NEXT:    movd %xmm0, %rax
107; CHECK-NEXT:    bsrq %rax, %rax
108; CHECK-NEXT:    cmoveq %rcx, %rax
109; CHECK-NEXT:    xorq $63, %rax
110; CHECK-NEXT:    movd %rax, %xmm0
111; CHECK-NEXT:    punpcklqdq {{.*#+}} xmm1 = xmm1[0],xmm0[0]
112; CHECK-NEXT:    psubq {{.*}}(%rip), %xmm1
113; CHECK-NEXT:    movdqa %xmm1, %xmm0
114; CHECK-NEXT:    retq
115  %c = call <2 x i32> @llvm.ctlz.v2i32(<2 x i32> %a, i1 false)
116  ret <2 x i32> %c
117
118}
119
120define <2 x i32> @prompop(<2 x i32> %a) nounwind {
121; CHECK-LABEL: prompop:
122; CHECK:       # BB#0:
123; CHECK-NEXT:    pand {{.*}}(%rip), %xmm0
124; CHECK-NEXT:    pxor %xmm2, %xmm2
125; CHECK-NEXT:    movdqa %xmm0, %xmm1
126; CHECK-NEXT:    psrlq $1, %xmm1
127; CHECK-NEXT:    pand {{.*}}(%rip), %xmm1
128; CHECK-NEXT:    psubq %xmm1, %xmm0
129; CHECK-NEXT:    movdqa {{.*#+}} xmm1 = [3689348814741910323,3689348814741910323]
130; CHECK-NEXT:    movdqa %xmm0, %xmm3
131; CHECK-NEXT:    pand %xmm1, %xmm3
132; CHECK-NEXT:    psrlq $2, %xmm0
133; CHECK-NEXT:    pand %xmm1, %xmm0
134; CHECK-NEXT:    paddq %xmm3, %xmm0
135; CHECK-NEXT:    movdqa %xmm0, %xmm1
136; CHECK-NEXT:    psrlq $4, %xmm1
137; CHECK-NEXT:    paddq %xmm0, %xmm1
138; CHECK-NEXT:    pand {{.*}}(%rip), %xmm1
139; CHECK-NEXT:    psadbw %xmm2, %xmm1
140; CHECK-NEXT:    movdqa %xmm1, %xmm0
141; CHECK-NEXT:    retq
142  %c = call <2 x i32> @llvm.ctpop.v2i32(<2 x i32> %a)
143  ret <2 x i32> %c
144}
145