Home | History | Annotate | Download | only in Mips
      1 ; RUN: opt -S -simplifycfg -mtriple=mips-linux-gnu < %s | FileCheck %s
      2 
      3 define i32 @ctlz(i32 %A) {
      4 ; CHECK-LABEL: @ctlz(
      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]]
      9 entry:
     10   %tobool = icmp eq i32 %A, 0
     11   br i1 %tobool, label %cond.end, label %cond.true
     12 
     13 cond.true:
     14   %0 = tail call i32 @llvm.ctlz.i32(i32 %A, i1 true)
     15   br label %cond.end
     16 
     17 cond.end:
     18   %cond = phi i32 [ %0, %cond.true ], [ 32, %entry ]
     19   ret i32 %cond
     20 }
     21 
     22 define i32 @cttz(i32 %A) {
     23 ; CHECK-LABEL: @cttz(
     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]]
     28 entry:
     29   %tobool = icmp eq i32 %A, 0
     30   br i1 %tobool, label %cond.end, label %cond.true
     31 
     32 cond.true:
     33   %0 = tail call i32 @llvm.cttz.i32(i32 %A, i1 true)
     34   br label %cond.end
     35 
     36 cond.end:
     37   %cond = phi i32 [ %0, %cond.true ], [ 32, %entry ]
     38   ret i32 %cond
     39 }
     40 
     41 declare i32 @llvm.ctlz.i32(i32, i1)
     42 declare i32 @llvm.cttz.i32(i32, i1)
     43 
     44