1; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 | FileCheck %s
2
3declare <2 x i64> @llvm.cttz.v2i64(<2 x i64>, i1)
4declare <2 x i64> @llvm.ctlz.v2i64(<2 x i64>, i1)
5declare <2 x i64> @llvm.ctpop.v2i64(<2 x i64>)
6
7define <2 x i64> @footz(<2 x i64> %a) nounwind {
8  %c = call <2 x i64> @llvm.cttz.v2i64(<2 x i64> %a, i1 true)
9  ret <2 x i64> %c
10
11; CHECK-LABEL: footz
12; CHECK: bsfq
13; CHECK: bsfq
14}
15define <2 x i64> @foolz(<2 x i64> %a) nounwind {
16  %c = call <2 x i64> @llvm.ctlz.v2i64(<2 x i64> %a, i1 true)
17  ret <2 x i64> %c
18
19; CHECK-LABEL: foolz
20; CHECK: bsrq
21; CHECK: xorq $63
22; CHECK: bsrq
23; CHECK: xorq $63
24}
25
26define <2 x i64> @foopop(<2 x i64> %a) nounwind {
27  %c = call <2 x i64> @llvm.ctpop.v2i64(<2 x i64> %a)
28  ret <2 x i64> %c
29}
30
31declare <2 x i32> @llvm.cttz.v2i32(<2 x i32>, i1)
32declare <2 x i32> @llvm.ctlz.v2i32(<2 x i32>, i1)
33declare <2 x i32> @llvm.ctpop.v2i32(<2 x i32>)
34
35define <2 x i32> @promtz(<2 x i32> %a) nounwind {
36  %c = call <2 x i32> @llvm.cttz.v2i32(<2 x i32> %a, i1 false)
37  ret <2 x i32> %c
38
39; CHECK: .quad 4294967296
40; CHECK: .quad 4294967296
41; CHECK-LABEL: promtz
42; CHECK: bsfq
43; CHECK: cmov
44; CHECK: bsfq
45; CHECK: cmov
46}
47define <2 x i32> @promlz(<2 x i32> %a) nounwind {
48  %c = call <2 x i32> @llvm.ctlz.v2i32(<2 x i32> %a, i1 false)
49  ret <2 x i32> %c
50
51; CHECK: .quad 4294967295
52; CHECK: .quad 4294967295
53; CHECK: .quad 32
54; CHECK: .quad 32
55; CHECK-LABEL: promlz
56; CHECK: pand
57; CHECK: bsrq
58; CHECK: xorq $63
59; CHECK: bsrq
60; CHECK: xorq $63
61; CHECK: psub
62}
63
64define <2 x i32> @prompop(<2 x i32> %a) nounwind {
65  %c = call <2 x i32> @llvm.ctpop.v2i32(<2 x i32> %a)
66  ret <2 x i32> %c
67}
68