• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt -S -simplifycfg < %s | FileCheck %s
2target datalayout = "E-m:e-i64:64-n32:64"
3target triple = "powerpc64-unknown-linux-gnu"
4
5define 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]]
11entry:
12  %tobool = icmp eq i64 %A, 0
13  br i1 %tobool, label %cond.end, label %cond.true
14
15cond.true:                                        ; preds = %entry
16  %0 = tail call i64 @llvm.ctlz.i64(i64 %A, i1 true)
17  br label %cond.end
18
19cond.end:                                         ; preds = %entry, %cond.true
20  %cond = phi i64 [ %0, %cond.true ], [ 64, %entry ]
21  ret i64 %cond
22}
23
24define 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]]
30entry:
31  %tobool = icmp eq i64 %A, 0
32  br i1 %tobool, label %cond.end, label %cond.true
33
34cond.true:                                        ; preds = %entry
35  %0 = tail call i64 @llvm.cttz.i64(i64 %A, i1 true)
36  br label %cond.end
37
38cond.end:                                         ; preds = %entry, %cond.true
39  %cond = phi i64 [ %0, %cond.true ], [ 64, %entry ]
40  ret i64 %cond
41}
42
43declare i64 @llvm.ctlz.i64(i64, i1)
44declare i64 @llvm.cttz.i64(i64, i1)
45
46