1 ; RUN: opt -S -codegenprepare -mtriple=r600-unknown-unknown -mcpu=SI < %s | FileCheck -check-prefix=SI -check-prefix=ALL %s
2 ; RUN: opt -S -codegenprepare -mtriple=r600-unknown-unknown -mcpu=tonga < %s | FileCheck -check-prefix=SI -check-prefix=ALL %s
5 define i64 @test1(i64 %A) {
7 ; SI: [[CTLZ:%[A-Za-z0-9]+]] = call i64 @llvm.ctlz.i64(i64 %A, i1 false)
8 ; SI-NEXT: ret i64 [[CTLZ]]
10 %tobool = icmp eq i64 %A, 0
11 br i1 %tobool, label %cond.end, label %cond.true
13 cond.true: ; preds = %entry
14 %0 = tail call i64 @llvm.ctlz.i64(i64 %A, i1 true)
17 cond.end: ; preds = %entry, %cond.true
18 %cond = phi i64 [ %0, %cond.true ], [ 64, %entry ]
23 define i32 @test2(i32 %A) {
25 ; SI: [[CTLZ:%[A-Za-z0-9]+]] = call i32 @llvm.ctlz.i32(i32 %A, i1 false)
26 ; SI-NEXT: ret i32 [[CTLZ]]
28 %tobool = icmp eq i32 %A, 0
29 br i1 %tobool, label %cond.end, label %cond.true
31 cond.true: ; preds = %entry
32 %0 = tail call i32 @llvm.ctlz.i32(i32 %A, i1 true)
35 cond.end: ; preds = %entry, %cond.true
36 %cond = phi i32 [ %0, %cond.true ], [ 32, %entry ]
41 define signext i16 @test3(i16 signext %A) {
43 ; SI: [[CTLZ:%[A-Za-z0-9]+]] = call i16 @llvm.ctlz.i16(i16 %A, i1 false)
44 ; SI-NEXT: ret i16 [[CTLZ]]
46 %tobool = icmp eq i16 %A, 0
47 br i1 %tobool, label %cond.end, label %cond.true
49 cond.true: ; preds = %entry
50 %0 = tail call i16 @llvm.ctlz.i16(i16 %A, i1 true)
53 cond.end: ; preds = %entry, %cond.true
54 %cond = phi i16 [ %0, %cond.true ], [ 16, %entry ]
59 define i64 @test1b(i64 %A) {
61 ; SI: [[CTTZ:%[A-Za-z0-9]+]] = call i64 @llvm.cttz.i64(i64 %A, i1 false)
62 ; SI-NEXT: ret i64 [[CTTZ]]
64 %tobool = icmp eq i64 %A, 0
65 br i1 %tobool, label %cond.end, label %cond.true
67 cond.true: ; preds = %entry
68 %0 = tail call i64 @llvm.cttz.i64(i64 %A, i1 true)
71 cond.end: ; preds = %entry, %cond.true
72 %cond = phi i64 [ %0, %cond.true ], [ 64, %entry ]
77 define i32 @test2b(i32 %A) {
79 ; SI: [[CTTZ:%[A-Za-z0-9]+]] = call i32 @llvm.cttz.i32(i32 %A, i1 false)
80 ; SI-NEXT: ret i32 [[CTTZ]]
82 %tobool = icmp eq i32 %A, 0
83 br i1 %tobool, label %cond.end, label %cond.true
85 cond.true: ; preds = %entry
86 %0 = tail call i32 @llvm.cttz.i32(i32 %A, i1 true)
89 cond.end: ; preds = %entry, %cond.true
90 %cond = phi i32 [ %0, %cond.true ], [ 32, %entry ]
95 define signext i16 @test3b(i16 signext %A) {
97 ; SI: [[CTTZ:%[A-Za-z0-9]+]] = call i16 @llvm.cttz.i16(i16 %A, i1 false)
98 ; SI-NEXT: ret i16 [[CTTZ]]
100 %tobool = icmp eq i16 %A, 0
101 br i1 %tobool, label %cond.end, label %cond.true
103 cond.true: ; preds = %entry
104 %0 = tail call i16 @llvm.cttz.i16(i16 %A, i1 true)
107 cond.end: ; preds = %entry, %cond.true
108 %cond = phi i16 [ %0, %cond.true ], [ 16, %entry ]
113 define i64 @test1c(i64 %A) {
114 ; ALL-LABEL: @test1c(
115 ; ALL: icmp eq i64 %A, 0
116 ; ALL: call i64 @llvm.ctlz.i64(i64 %A, i1 true)
118 %tobool = icmp eq i64 %A, 0
119 br i1 %tobool, label %cond.end, label %cond.true
121 cond.true: ; preds = %entry
122 %0 = tail call i64 @llvm.ctlz.i64(i64 %A, i1 true)
125 cond.end: ; preds = %entry, %cond.true
126 %cond = phi i64 [ %0, %cond.true ], [ 63, %entry ]
130 define i32 @test2c(i32 %A) {
131 ; ALL-LABEL: @test2c(
132 ; ALL: icmp eq i32 %A, 0
133 ; ALL: call i32 @llvm.ctlz.i32(i32 %A, i1 true)
135 %tobool = icmp eq i32 %A, 0
136 br i1 %tobool, label %cond.end, label %cond.true
138 cond.true: ; preds = %entry
139 %0 = tail call i32 @llvm.ctlz.i32(i32 %A, i1 true)
142 cond.end: ; preds = %entry, %cond.true
143 %cond = phi i32 [ %0, %cond.true ], [ 31, %entry ]
148 define signext i16 @test3c(i16 signext %A) {
149 ; ALL-LABEL: @test3c(
150 ; ALL: icmp eq i16 %A, 0
151 ; ALL: call i16 @llvm.ctlz.i16(i16 %A, i1 true)
153 %tobool = icmp eq i16 %A, 0
154 br i1 %tobool, label %cond.end, label %cond.true
156 cond.true: ; preds = %entry
157 %0 = tail call i16 @llvm.ctlz.i16(i16 %A, i1 true)
160 cond.end: ; preds = %entry, %cond.true
161 %cond = phi i16 [ %0, %cond.true ], [ 15, %entry ]
166 define i64 @test1d(i64 %A) {
167 ; ALL-LABEL: @test1d(
168 ; ALL: icmp eq i64 %A, 0
169 ; ALL: call i64 @llvm.cttz.i64(i64 %A, i1 true)
171 %tobool = icmp eq i64 %A, 0
172 br i1 %tobool, label %cond.end, label %cond.true
174 cond.true: ; preds = %entry
175 %0 = tail call i64 @llvm.cttz.i64(i64 %A, i1 true)
178 cond.end: ; preds = %entry, %cond.true
179 %cond = phi i64 [ %0, %cond.true ], [ 63, %entry ]
184 define i32 @test2d(i32 %A) {
185 ; ALL-LABEL: @test2d(
186 ; ALL: icmp eq i32 %A, 0
187 ; ALL: call i32 @llvm.cttz.i32(i32 %A, i1 true)
189 %tobool = icmp eq i32 %A, 0
190 br i1 %tobool, label %cond.end, label %cond.true
192 cond.true: ; preds = %entry
193 %0 = tail call i32 @llvm.cttz.i32(i32 %A, i1 true)
196 cond.end: ; preds = %entry, %cond.true
197 %cond = phi i32 [ %0, %cond.true ], [ 31, %entry ]
202 define signext i16 @test3d(i16 signext %A) {
203 ; ALL-LABEL: @test3d(
204 ; ALL: icmp eq i16 %A, 0
205 ; ALL: call i16 @llvm.cttz.i16(i16 %A, i1 true)
207 %tobool = icmp eq i16 %A, 0
208 br i1 %tobool, label %cond.end, label %cond.true
210 cond.true: ; preds = %entry
211 %0 = tail call i16 @llvm.cttz.i16(i16 %A, i1 true)
214 cond.end: ; preds = %entry, %cond.true
215 %cond = phi i16 [ %0, %cond.true ], [ 15, %entry ]
220 declare i64 @llvm.ctlz.i64(i64, i1)
221 declare i32 @llvm.ctlz.i32(i32, i1)
222 declare i16 @llvm.ctlz.i16(i16, i1)
223 declare i64 @llvm.cttz.i64(i64, i1)
224 declare i32 @llvm.cttz.i32(i32, i1)
225 declare i16 @llvm.cttz.i16(i16, i1)