1 ; RUN: opt -S -simplifycfg < %s | FileCheck %s 2 target datalayout = "E-m:e-i64:64-n32:64" 3 target triple = "powerpc64-unknown-linux-gnu" 4 5 define i64 @test1(i64 %A) { 6 ; CHECK-LABEL: @test1( 7 ; CHECK: [[ICMP:%[A-Za-z0-9]+]] = icmp eq i64 %A, 0 8 ; CHECK-NEXT: [[CTLZ:%[A-Za-z0-9]+]] = tail call i64 @llvm.ctlz.i64(i64 %A, i1 true) 9 ; CHECK-NEXT: [[SEL:%[A-Za-z0-9.]+]] = select i1 [[ICMP]], i64 64, i64 [[CTLZ]] 10 ; CHECK-NEXT: ret i64 [[SEL]] 11 entry: 12 %tobool = icmp eq i64 %A, 0 13 br i1 %tobool, label %cond.end, label %cond.true 14 15 cond.true: ; preds = %entry 16 %0 = tail call i64 @llvm.ctlz.i64(i64 %A, i1 true) 17 br label %cond.end 18 19 cond.end: ; preds = %entry, %cond.true 20 %cond = phi i64 [ %0, %cond.true ], [ 64, %entry ] 21 ret i64 %cond 22 } 23 24 define i64 @test1b(i64 %A) { 25 ; CHECK-LABEL: @test1b( 26 ; CHECK: [[ICMP:%[A-Za-z0-9]+]] = icmp eq i64 %A, 0 27 ; CHECK-NEXT: [[CTTZ:%[A-Za-z0-9]+]] = tail call i64 @llvm.cttz.i64(i64 %A, i1 true) 28 ; CHECK-NEXT: [[SEL:%[A-Za-z0-9.]+]] = select i1 [[ICMP]], i64 64, i64 [[CTLZ]] 29 ; CHECK-NEXT: ret i64 [[SEL]] 30 entry: 31 %tobool = icmp eq i64 %A, 0 32 br i1 %tobool, label %cond.end, label %cond.true 33 34 cond.true: ; preds = %entry 35 %0 = tail call i64 @llvm.cttz.i64(i64 %A, i1 true) 36 br label %cond.end 37 38 cond.end: ; preds = %entry, %cond.true 39 %cond = phi i64 [ %0, %cond.true ], [ 64, %entry ] 40 ret i64 %cond 41 } 42 43 declare i64 @llvm.ctlz.i64(i64, i1) 44 declare i64 @llvm.cttz.i64(i64, i1) 45 46