1 # NOTE: Assertions have been autogenerated by utils/update_mir_test_checks.py UTC_ARGS: --version 2
2 # RUN: llc -mtriple=x86_64-linux-gnu -run-pass=legalizer %s -o - | FileCheck %s --check-prefixes=CHECK,X64
3 # RUN: llc -mtriple=i386-linux-gnu -run-pass=legalizer %s -o - | FileCheck %s --check-prefixes=CHECK,X86
5 # test count trailing zeros for s16, s32, and s64
11 regBankSelected: false
13 - { id: 0, class: _, preferred-register: '' }
16 ; X64-LABEL: name: test_cttz35
17 ; X64: [[COPY:%[0-9]+]]:_(s64) = COPY $rdx
18 ; X64-NEXT: [[C:%[0-9]+]]:_(s64) = G_CONSTANT i64 34359738368
19 ; X64-NEXT: [[OR:%[0-9]+]]:_(s64) = G_OR [[COPY]], [[C]]
20 ; X64-NEXT: [[CTTZ_ZERO_UNDEF:%[0-9]+]]:_(s64) = G_CTTZ_ZERO_UNDEF [[OR]](s64)
21 ; X64-NEXT: [[C1:%[0-9]+]]:_(s64) = G_CONSTANT i64 34359738367
22 ; X64-NEXT: [[AND:%[0-9]+]]:_(s64) = G_AND [[CTTZ_ZERO_UNDEF]], [[C1]]
23 ; X64-NEXT: RET 0, implicit [[AND]](s64)
24 ; X86-LABEL: name: test_cttz35
25 ; X86: [[COPY:%[0-9]+]]:_(s64) = COPY $rdx
26 ; X86-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
27 ; X86-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 8
28 ; X86-NEXT: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[COPY]](s64)
29 ; X86-NEXT: [[OR:%[0-9]+]]:_(s32) = G_OR [[UV]], [[C]]
30 ; X86-NEXT: [[OR1:%[0-9]+]]:_(s32) = G_OR [[UV1]], [[C1]]
31 ; X86-NEXT: [[ICMP:%[0-9]+]]:_(s8) = G_ICMP intpred(eq), [[OR]](s32), [[C]]
32 ; X86-NEXT: [[CTTZ_ZERO_UNDEF:%[0-9]+]]:_(s32) = G_CTTZ_ZERO_UNDEF [[OR1]](s32)
33 ; X86-NEXT: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 32
34 ; X86-NEXT: [[UADDO:%[0-9]+]]:_(s32), [[UADDO1:%[0-9]+]]:_(s1) = G_UADDO [[CTTZ_ZERO_UNDEF]], [[C2]]
35 ; X86-NEXT: [[UADDE:%[0-9]+]]:_(s32), [[UADDE1:%[0-9]+]]:_(s1) = G_UADDE [[C]], [[C]], [[UADDO1]]
36 ; X86-NEXT: [[CTTZ_ZERO_UNDEF1:%[0-9]+]]:_(s32) = G_CTTZ_ZERO_UNDEF [[OR]](s32)
37 ; X86-NEXT: [[C3:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
38 ; X86-NEXT: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[ICMP]](s8)
39 ; X86-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C3]]
40 ; X86-NEXT: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[AND]](s32), [[UADDO]], [[CTTZ_ZERO_UNDEF1]]
41 ; X86-NEXT: [[SELECT1:%[0-9]+]]:_(s32) = G_SELECT [[AND]](s32), [[UADDE]], [[C]]
42 ; X86-NEXT: [[C4:%[0-9]+]]:_(s32) = G_CONSTANT i32 -1
43 ; X86-NEXT: [[C5:%[0-9]+]]:_(s32) = G_CONSTANT i32 7
44 ; X86-NEXT: [[AND1:%[0-9]+]]:_(s32) = G_AND [[SELECT]], [[C4]]
45 ; X86-NEXT: [[AND2:%[0-9]+]]:_(s32) = G_AND [[SELECT1]], [[C5]]
46 ; X86-NEXT: [[MV:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[AND1]](s32), [[AND2]](s32)
47 ; X86-NEXT: RET 0, implicit [[MV]](s64)
49 %1:_(s35) = G_TRUNC %0(s64)
58 regBankSelected: false
60 - { id: 0, class: _, preferred-register: '' }
61 - { id: 1, class: _, preferred-register: '' }
64 ; CHECK-LABEL: name: test_cttz8
65 ; CHECK: [[DEF:%[0-9]+]]:_(s8) = IMPLICIT_DEF
66 ; CHECK-NEXT: [[ANYEXT:%[0-9]+]]:_(s16) = G_ANYEXT [[DEF]](s8)
67 ; CHECK-NEXT: [[CTTZ_ZERO_UNDEF:%[0-9]+]]:_(s16) = G_CTTZ_ZERO_UNDEF [[ANYEXT]](s16)
68 ; CHECK-NEXT: [[TRUNC:%[0-9]+]]:_(s8) = G_TRUNC [[CTTZ_ZERO_UNDEF]](s16)
69 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s8) = COPY [[TRUNC]](s8)
70 ; CHECK-NEXT: RET 0, implicit [[COPY]](s8)
71 %0:_(s8) = IMPLICIT_DEF
72 %1:_(s8) = G_CTTZ_ZERO_UNDEF %0
73 %2:_(s8) = COPY %1(s8)
80 regBankSelected: false
82 - { id: 0, class: _, preferred-register: '' }
83 - { id: 1, class: _, preferred-register: '' }
86 ; X64-LABEL: name: test_cttz64
87 ; X64: [[DEF:%[0-9]+]]:_(s64) = IMPLICIT_DEF
88 ; X64-NEXT: [[CTTZ_ZERO_UNDEF:%[0-9]+]]:_(s64) = G_CTTZ_ZERO_UNDEF [[DEF]](s64)
89 ; X64-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY [[CTTZ_ZERO_UNDEF]](s64)
90 ; X64-NEXT: RET 0, implicit [[COPY]](s64)
91 ; X86-LABEL: name: test_cttz64
92 ; X86: [[DEF:%[0-9]+]]:_(s64) = IMPLICIT_DEF
93 ; X86-NEXT: [[UV:%[0-9]+]]:_(s32), [[UV1:%[0-9]+]]:_(s32) = G_UNMERGE_VALUES [[DEF]](s64)
94 ; X86-NEXT: [[C:%[0-9]+]]:_(s32) = G_CONSTANT i32 0
95 ; X86-NEXT: [[ICMP:%[0-9]+]]:_(s8) = G_ICMP intpred(eq), [[UV]](s32), [[C]]
96 ; X86-NEXT: [[CTTZ_ZERO_UNDEF:%[0-9]+]]:_(s32) = G_CTTZ_ZERO_UNDEF [[UV1]](s32)
97 ; X86-NEXT: [[C1:%[0-9]+]]:_(s32) = G_CONSTANT i32 32
98 ; X86-NEXT: [[UADDO:%[0-9]+]]:_(s32), [[UADDO1:%[0-9]+]]:_(s1) = G_UADDO [[CTTZ_ZERO_UNDEF]], [[C1]]
99 ; X86-NEXT: [[UADDE:%[0-9]+]]:_(s32), [[UADDE1:%[0-9]+]]:_(s1) = G_UADDE [[C]], [[C]], [[UADDO1]]
100 ; X86-NEXT: [[CTTZ_ZERO_UNDEF1:%[0-9]+]]:_(s32) = G_CTTZ_ZERO_UNDEF [[UV]](s32)
101 ; X86-NEXT: [[C2:%[0-9]+]]:_(s32) = G_CONSTANT i32 1
102 ; X86-NEXT: [[ANYEXT:%[0-9]+]]:_(s32) = G_ANYEXT [[ICMP]](s8)
103 ; X86-NEXT: [[AND:%[0-9]+]]:_(s32) = G_AND [[ANYEXT]], [[C2]]
104 ; X86-NEXT: [[SELECT:%[0-9]+]]:_(s32) = G_SELECT [[AND]](s32), [[UADDO]], [[CTTZ_ZERO_UNDEF1]]
105 ; X86-NEXT: [[SELECT1:%[0-9]+]]:_(s32) = G_SELECT [[AND]](s32), [[UADDE]], [[C]]
106 ; X86-NEXT: [[MV:%[0-9]+]]:_(s64) = G_MERGE_VALUES [[SELECT]](s32), [[SELECT1]](s32)
107 ; X86-NEXT: [[COPY:%[0-9]+]]:_(s64) = COPY [[MV]](s64)
108 ; X86-NEXT: RET 0, implicit [[COPY]](s64)
109 %0:_(s64) = IMPLICIT_DEF
110 %1:_(s64) = G_CTTZ_ZERO_UNDEF %0
111 %2:_(s64) = COPY %1(s64)
118 regBankSelected: false
120 - { id: 0, class: _, preferred-register: '' }
121 - { id: 1, class: _, preferred-register: '' }
124 ; CHECK-LABEL: name: test_cttz32
125 ; CHECK: [[DEF:%[0-9]+]]:_(s32) = IMPLICIT_DEF
126 ; CHECK-NEXT: [[CTTZ_ZERO_UNDEF:%[0-9]+]]:_(s32) = G_CTTZ_ZERO_UNDEF [[DEF]](s32)
127 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s32) = COPY [[CTTZ_ZERO_UNDEF]](s32)
128 ; CHECK-NEXT: RET 0, implicit [[COPY]](s32)
129 %0:_(s32) = IMPLICIT_DEF
130 %1:_(s32) = G_CTTZ_ZERO_UNDEF %0
131 %2:_(s32) = COPY %1(s32)
138 regBankSelected: false
140 - { id: 0, class: _, preferred-register: '' }
141 - { id: 1, class: _, preferred-register: '' }
144 ; CHECK-LABEL: name: test_cttz16
145 ; CHECK: [[DEF:%[0-9]+]]:_(s16) = IMPLICIT_DEF
146 ; CHECK-NEXT: [[CTTZ_ZERO_UNDEF:%[0-9]+]]:_(s16) = G_CTTZ_ZERO_UNDEF [[DEF]](s16)
147 ; CHECK-NEXT: [[COPY:%[0-9]+]]:_(s16) = COPY [[CTTZ_ZERO_UNDEF]](s16)
148 ; CHECK-NEXT: RET 0, implicit [[COPY]](s16)
149 %0:_(s16) = IMPLICIT_DEF
150 %1:_(s16) = G_CTTZ_ZERO_UNDEF %0
151 %2:_(s16) = COPY %1(s16)