1 ; RUN: opt -S -passes=simplifycfg -simplifycfg-require-and-preserve-domtree=1 -mtriple=mips-linux-gnu < %s | FileCheck %s
3 define i32 @ctlz(i32 %A) {
5 ; CHECK: [[ICMP:%[A-Za-z0-9]+]] = icmp eq i32 %A, 0
6 ; CHECK-NEXT: [[CTZ:%[A-Za-z0-9]+]] = tail call i32 @llvm.ctlz.i32(i32 %A, i1 true)
7 ; CHECK-NEXT: [[SEL:%[A-Za-z0-9.]+]] = select i1 [[ICMP]], i32 32, i32 [[CTZ]]
8 ; CHECK-NEXT: ret i32 [[SEL]]
10 %tobool = icmp eq i32 %A, 0
11 br i1 %tobool, label %cond.end, label %cond.true
14 %0 = tail call i32 @llvm.ctlz.i32(i32 %A, i1 true)
18 %cond = phi i32 [ %0, %cond.true ], [ 32, %entry ]
22 define i32 @cttz(i32 %A) {
24 ; CHECK: [[ICMP:%[A-Za-z0-9]+]] = icmp eq i32 %A, 0
25 ; CHECK-NEXT: [[CTZ:%[A-Za-z0-9]+]] = tail call i32 @llvm.cttz.i32(i32 %A, i1 true)
26 ; CHECK-NEXT: [[SEL:%[A-Za-z0-9.]+]] = select i1 [[ICMP]], i32 32, i32 [[CTZ]]
27 ; CHECK-NEXT: ret i32 [[SEL]]
29 %tobool = icmp eq i32 %A, 0
30 br i1 %tobool, label %cond.end, label %cond.true
33 %0 = tail call i32 @llvm.cttz.i32(i32 %A, i1 true)
37 %cond = phi i32 [ %0, %cond.true ], [ 32, %entry ]
41 declare i32 @llvm.ctlz.i32(i32, i1)
42 declare i32 @llvm.cttz.i32(i32, i1)