• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -correlated-propagation -S | FileCheck %s
2
3; CHECK-LABEL: @test0(
4define void @test0(i32 %n) {
5entry:
6  br label %for.cond
7
8for.cond:                                         ; preds = %for.body, %entry
9  %j.0 = phi i32 [ %n, %entry ], [ %div, %for.body ]
10  %cmp = icmp sgt i32 %j.0, 1
11  br i1 %cmp, label %for.body, label %for.end
12
13for.body:                                         ; preds = %for.cond
14; CHECK: %div1 = udiv i32 %j.0, 2
15  %div = sdiv i32 %j.0, 2
16  br label %for.cond
17
18for.end:                                          ; preds = %for.cond
19  ret void
20}
21
22; CHECK-LABEL: @test1(
23define void @test1(i32 %n) {
24entry:
25  br label %for.cond
26
27for.cond:                                         ; preds = %for.body, %entry
28  %j.0 = phi i32 [ %n, %entry ], [ %div, %for.body ]
29  %cmp = icmp sgt i32 %j.0, -2
30  br i1 %cmp, label %for.body, label %for.end
31
32for.body:                                         ; preds = %for.cond
33; CHECK: %div = sdiv i32 %j.0, 2
34  %div = sdiv i32 %j.0, 2
35  br label %for.cond
36
37for.end:                                          ; preds = %for.cond
38  ret void
39}
40
41; CHECK-LABEL: @test2(
42define void @test2(i32 %n) {
43entry:
44  %cmp = icmp sgt i32 %n, 1
45  br i1 %cmp, label %bb, label %exit
46
47bb:
48; CHECK: %div1 = udiv i32 %n, 2
49  %div = sdiv i32 %n, 2
50  br label %exit
51
52exit:
53  ret void
54}
55