• 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 -print-schedule -mcpu=x86-64 -mattr=+popcnt | FileCheck %s --check-prefix=CHECK --check-prefix=GENERIC
3; RUN: llc < %s -mtriple=x86_64-unknown-unknown -print-schedule -mcpu=slm         | FileCheck %s --check-prefix=CHECK --check-prefix=SLM
4; RUN: llc < %s -mtriple=x86_64-unknown-unknown -print-schedule -mcpu=goldmont    | FileCheck %s --check-prefix=CHECK --check-prefix=SLM
5; RUN: llc < %s -mtriple=x86_64-unknown-unknown -print-schedule -mcpu=sandybridge | FileCheck %s --check-prefix=CHECK --check-prefix=SANDY
6; RUN: llc < %s -mtriple=x86_64-unknown-unknown -print-schedule -mcpu=ivybridge   | FileCheck %s --check-prefix=CHECK --check-prefix=SANDY
7; RUN: llc < %s -mtriple=x86_64-unknown-unknown -print-schedule -mcpu=haswell     | FileCheck %s --check-prefix=CHECK --check-prefix=HASWELL
8; RUN: llc < %s -mtriple=x86_64-unknown-unknown -print-schedule -mcpu=broadwell   | FileCheck %s --check-prefix=CHECK --check-prefix=BROADWELL
9; RUN: llc < %s -mtriple=x86_64-unknown-unknown -print-schedule -mcpu=skylake     | FileCheck %s --check-prefix=CHECK --check-prefix=SKYLAKE
10; RUN: llc < %s -mtriple=x86_64-unknown-unknown -print-schedule -mcpu=knl         | FileCheck %s --check-prefix=CHECK --check-prefix=HASWELL
11; RUN: llc < %s -mtriple=x86_64-unknown-unknown -print-schedule -mcpu=btver2      | FileCheck %s --check-prefix=CHECK --check-prefix=BTVER2
12; RUN: llc < %s -mtriple=x86_64-unknown-unknown -print-schedule -mcpu=znver1      | FileCheck %s --check-prefix=CHECK --check-prefix=ZNVER1
13
14define i16 @test_ctpop_i16(i16 zeroext %a0, i16 *%a1) {
15; GENERIC-LABEL: test_ctpop_i16:
16; GENERIC:       # %bb.0:
17; GENERIC-NEXT:    popcntw (%rsi), %cx # sched: [9:1.00]
18; GENERIC-NEXT:    popcntw %di, %ax # sched: [3:1.00]
19; GENERIC-NEXT:    orl %ecx, %eax # sched: [1:0.33]
20; GENERIC-NEXT:    # kill: def $ax killed $ax killed $eax
21; GENERIC-NEXT:    retq # sched: [1:1.00]
22;
23; SLM-LABEL: test_ctpop_i16:
24; SLM:       # %bb.0:
25; SLM-NEXT:    popcntw (%rsi), %cx # sched: [6:1.00]
26; SLM-NEXT:    popcntw %di, %ax # sched: [3:1.00]
27; SLM-NEXT:    orl %ecx, %eax # sched: [1:0.50]
28; SLM-NEXT:    # kill: def $ax killed $ax killed $eax
29; SLM-NEXT:    retq # sched: [4:1.00]
30;
31; SANDY-LABEL: test_ctpop_i16:
32; SANDY:       # %bb.0:
33; SANDY-NEXT:    popcntw (%rsi), %cx # sched: [9:1.00]
34; SANDY-NEXT:    popcntw %di, %ax # sched: [3:1.00]
35; SANDY-NEXT:    orl %ecx, %eax # sched: [1:0.33]
36; SANDY-NEXT:    # kill: def $ax killed $ax killed $eax
37; SANDY-NEXT:    retq # sched: [1:1.00]
38;
39; HASWELL-LABEL: test_ctpop_i16:
40; HASWELL:       # %bb.0:
41; HASWELL-NEXT:    popcntw (%rsi), %cx # sched: [8:1.00]
42; HASWELL-NEXT:    popcntw %di, %ax # sched: [3:1.00]
43; HASWELL-NEXT:    orl %ecx, %eax # sched: [1:0.25]
44; HASWELL-NEXT:    # kill: def $ax killed $ax killed $eax
45; HASWELL-NEXT:    retq # sched: [7:1.00]
46;
47; BROADWELL-LABEL: test_ctpop_i16:
48; BROADWELL:       # %bb.0:
49; BROADWELL-NEXT:    popcntw (%rsi), %cx # sched: [8:1.00]
50; BROADWELL-NEXT:    popcntw %di, %ax # sched: [3:1.00]
51; BROADWELL-NEXT:    orl %ecx, %eax # sched: [1:0.25]
52; BROADWELL-NEXT:    # kill: def $ax killed $ax killed $eax
53; BROADWELL-NEXT:    retq # sched: [7:1.00]
54;
55; SKYLAKE-LABEL: test_ctpop_i16:
56; SKYLAKE:       # %bb.0:
57; SKYLAKE-NEXT:    popcntw (%rsi), %cx # sched: [8:1.00]
58; SKYLAKE-NEXT:    popcntw %di, %ax # sched: [3:1.00]
59; SKYLAKE-NEXT:    orl %ecx, %eax # sched: [1:0.25]
60; SKYLAKE-NEXT:    # kill: def $ax killed $ax killed $eax
61; SKYLAKE-NEXT:    retq # sched: [7:1.00]
62;
63; BTVER2-LABEL: test_ctpop_i16:
64; BTVER2:       # %bb.0:
65; BTVER2-NEXT:    popcntw (%rsi), %cx # sched: [4:1.00]
66; BTVER2-NEXT:    popcntw %di, %ax # sched: [1:0.50]
67; BTVER2-NEXT:    orl %ecx, %eax # sched: [1:0.50]
68; BTVER2-NEXT:    # kill: def $ax killed $ax killed $eax
69; BTVER2-NEXT:    retq # sched: [4:1.00]
70;
71; ZNVER1-LABEL: test_ctpop_i16:
72; ZNVER1:       # %bb.0:
73; ZNVER1-NEXT:    popcntw (%rsi), %cx # sched: [5:0.50]
74; ZNVER1-NEXT:    popcntw %di, %ax # sched: [1:0.25]
75; ZNVER1-NEXT:    orl %ecx, %eax # sched: [1:0.25]
76; ZNVER1-NEXT:    # kill: def $ax killed $ax killed $eax
77; ZNVER1-NEXT:    retq # sched: [1:0.50]
78  %1 = load i16, i16 *%a1
79  %2 = tail call i16 @llvm.ctpop.i16( i16 %1 )
80  %3 = tail call i16 @llvm.ctpop.i16( i16 %a0 )
81  %4 = or i16 %2, %3
82  ret i16 %4
83}
84declare i16 @llvm.ctpop.i16(i16)
85
86define i32 @test_ctpop_i32(i32 %a0, i32 *%a1) {
87; GENERIC-LABEL: test_ctpop_i32:
88; GENERIC:       # %bb.0:
89; GENERIC-NEXT:    popcntl (%rsi), %ecx # sched: [9:1.00]
90; GENERIC-NEXT:    popcntl %edi, %eax # sched: [3:1.00]
91; GENERIC-NEXT:    orl %ecx, %eax # sched: [1:0.33]
92; GENERIC-NEXT:    retq # sched: [1:1.00]
93;
94; SLM-LABEL: test_ctpop_i32:
95; SLM:       # %bb.0:
96; SLM-NEXT:    popcntl (%rsi), %ecx # sched: [6:1.00]
97; SLM-NEXT:    popcntl %edi, %eax # sched: [3:1.00]
98; SLM-NEXT:    orl %ecx, %eax # sched: [1:0.50]
99; SLM-NEXT:    retq # sched: [4:1.00]
100;
101; SANDY-LABEL: test_ctpop_i32:
102; SANDY:       # %bb.0:
103; SANDY-NEXT:    popcntl (%rsi), %ecx # sched: [9:1.00]
104; SANDY-NEXT:    popcntl %edi, %eax # sched: [3:1.00]
105; SANDY-NEXT:    orl %ecx, %eax # sched: [1:0.33]
106; SANDY-NEXT:    retq # sched: [1:1.00]
107;
108; HASWELL-LABEL: test_ctpop_i32:
109; HASWELL:       # %bb.0:
110; HASWELL-NEXT:    popcntl (%rsi), %ecx # sched: [8:1.00]
111; HASWELL-NEXT:    popcntl %edi, %eax # sched: [3:1.00]
112; HASWELL-NEXT:    orl %ecx, %eax # sched: [1:0.25]
113; HASWELL-NEXT:    retq # sched: [7:1.00]
114;
115; BROADWELL-LABEL: test_ctpop_i32:
116; BROADWELL:       # %bb.0:
117; BROADWELL-NEXT:    popcntl (%rsi), %ecx # sched: [8:1.00]
118; BROADWELL-NEXT:    popcntl %edi, %eax # sched: [3:1.00]
119; BROADWELL-NEXT:    orl %ecx, %eax # sched: [1:0.25]
120; BROADWELL-NEXT:    retq # sched: [7:1.00]
121;
122; SKYLAKE-LABEL: test_ctpop_i32:
123; SKYLAKE:       # %bb.0:
124; SKYLAKE-NEXT:    popcntl (%rsi), %ecx # sched: [8:1.00]
125; SKYLAKE-NEXT:    popcntl %edi, %eax # sched: [3:1.00]
126; SKYLAKE-NEXT:    orl %ecx, %eax # sched: [1:0.25]
127; SKYLAKE-NEXT:    retq # sched: [7:1.00]
128;
129; BTVER2-LABEL: test_ctpop_i32:
130; BTVER2:       # %bb.0:
131; BTVER2-NEXT:    popcntl (%rsi), %ecx # sched: [4:1.00]
132; BTVER2-NEXT:    popcntl %edi, %eax # sched: [1:0.50]
133; BTVER2-NEXT:    orl %ecx, %eax # sched: [1:0.50]
134; BTVER2-NEXT:    retq # sched: [4:1.00]
135;
136; ZNVER1-LABEL: test_ctpop_i32:
137; ZNVER1:       # %bb.0:
138; ZNVER1-NEXT:    popcntl (%rsi), %ecx # sched: [5:0.50]
139; ZNVER1-NEXT:    popcntl %edi, %eax # sched: [1:0.25]
140; ZNVER1-NEXT:    orl %ecx, %eax # sched: [1:0.25]
141; ZNVER1-NEXT:    retq # sched: [1:0.50]
142  %1 = load i32, i32 *%a1
143  %2 = tail call i32 @llvm.ctpop.i32( i32 %1 )
144  %3 = tail call i32 @llvm.ctpop.i32( i32 %a0 )
145  %4 = or i32 %2, %3
146  ret i32 %4
147}
148declare i32 @llvm.ctpop.i32(i32)
149
150define i64 @test_ctpop_i64(i64 %a0, i64 *%a1) {
151; GENERIC-LABEL: test_ctpop_i64:
152; GENERIC:       # %bb.0:
153; GENERIC-NEXT:    popcntq (%rsi), %rcx # sched: [9:1.00]
154; GENERIC-NEXT:    popcntq %rdi, %rax # sched: [3:1.00]
155; GENERIC-NEXT:    orq %rcx, %rax # sched: [1:0.33]
156; GENERIC-NEXT:    retq # sched: [1:1.00]
157;
158; SLM-LABEL: test_ctpop_i64:
159; SLM:       # %bb.0:
160; SLM-NEXT:    popcntq (%rsi), %rcx # sched: [6:1.00]
161; SLM-NEXT:    popcntq %rdi, %rax # sched: [3:1.00]
162; SLM-NEXT:    orq %rcx, %rax # sched: [1:0.50]
163; SLM-NEXT:    retq # sched: [4:1.00]
164;
165; SANDY-LABEL: test_ctpop_i64:
166; SANDY:       # %bb.0:
167; SANDY-NEXT:    popcntq (%rsi), %rcx # sched: [9:1.00]
168; SANDY-NEXT:    popcntq %rdi, %rax # sched: [3:1.00]
169; SANDY-NEXT:    orq %rcx, %rax # sched: [1:0.33]
170; SANDY-NEXT:    retq # sched: [1:1.00]
171;
172; HASWELL-LABEL: test_ctpop_i64:
173; HASWELL:       # %bb.0:
174; HASWELL-NEXT:    popcntq (%rsi), %rcx # sched: [8:1.00]
175; HASWELL-NEXT:    popcntq %rdi, %rax # sched: [3:1.00]
176; HASWELL-NEXT:    orq %rcx, %rax # sched: [1:0.25]
177; HASWELL-NEXT:    retq # sched: [7:1.00]
178;
179; BROADWELL-LABEL: test_ctpop_i64:
180; BROADWELL:       # %bb.0:
181; BROADWELL-NEXT:    popcntq (%rsi), %rcx # sched: [8:1.00]
182; BROADWELL-NEXT:    popcntq %rdi, %rax # sched: [3:1.00]
183; BROADWELL-NEXT:    orq %rcx, %rax # sched: [1:0.25]
184; BROADWELL-NEXT:    retq # sched: [7:1.00]
185;
186; SKYLAKE-LABEL: test_ctpop_i64:
187; SKYLAKE:       # %bb.0:
188; SKYLAKE-NEXT:    popcntq (%rsi), %rcx # sched: [8:1.00]
189; SKYLAKE-NEXT:    popcntq %rdi, %rax # sched: [3:1.00]
190; SKYLAKE-NEXT:    orq %rcx, %rax # sched: [1:0.25]
191; SKYLAKE-NEXT:    retq # sched: [7:1.00]
192;
193; BTVER2-LABEL: test_ctpop_i64:
194; BTVER2:       # %bb.0:
195; BTVER2-NEXT:    popcntq (%rsi), %rcx # sched: [4:1.00]
196; BTVER2-NEXT:    popcntq %rdi, %rax # sched: [1:0.50]
197; BTVER2-NEXT:    orq %rcx, %rax # sched: [1:0.50]
198; BTVER2-NEXT:    retq # sched: [4:1.00]
199;
200; ZNVER1-LABEL: test_ctpop_i64:
201; ZNVER1:       # %bb.0:
202; ZNVER1-NEXT:    popcntq (%rsi), %rcx # sched: [5:0.50]
203; ZNVER1-NEXT:    popcntq %rdi, %rax # sched: [1:0.25]
204; ZNVER1-NEXT:    orq %rcx, %rax # sched: [1:0.25]
205; ZNVER1-NEXT:    retq # sched: [1:0.50]
206  %1 = load i64, i64 *%a1
207  %2 = tail call i64 @llvm.ctpop.i64( i64 %1 )
208  %3 = tail call i64 @llvm.ctpop.i64( i64 %a0 )
209  %4 = or i64 %2, %3
210  ret i64 %4
211}
212declare i64 @llvm.ctpop.i64(i64)
213