1 ; RUN: opt -correlated-propagation -S < %s | FileCheck %s
3 declare void @llvm.experimental.guard(i1,...)
5 define i1 @test1(i32 %a) {
7 ; CHECK: %alive = icmp eq i32 %a, 8
8 ; CHECK-NEXT: %result = or i1 false, %alive
9 %cmp = icmp ult i32 %a, 16
10 call void(i1,...) @llvm.experimental.guard(i1 %cmp) [ "deopt"() ]
11 %dead = icmp eq i32 %a, 16
12 %alive = icmp eq i32 %a, 8
13 %result = or i1 %dead, %alive
17 define i1 @test2(i32 %a) {
18 ; CHECK-LABEL: @test2(
20 ; CHECK-NEXT: %alive = icmp eq i32 %a, 8
21 ; CHECK-NEXT: %result = or i1 false, %alive
22 %cmp = icmp ult i32 %a, 16
23 call void(i1,...) @llvm.experimental.guard(i1 %cmp) [ "deopt"() ]
27 %dead = icmp eq i32 %a, 16
28 %alive = icmp eq i32 %a, 8
29 %result = or i1 %dead, %alive
33 define i1 @test3(i32 %a, i1 %flag) {
34 ; CHECK-LABEL: @test3(
36 ; CHECK-NEXT: %alive.1 = icmp eq i32 %a, 16
37 ; CHECK-NEXT: %alive.2 = icmp eq i32 %a, 8
38 ; CHECK-NEXT: %result = or i1 %alive.1, %alive.2
39 br i1 %flag, label %true, label %false
42 %cmp = icmp ult i32 %a, 16
43 call void(i1,...) @llvm.experimental.guard(i1 %cmp) [ "deopt"() ]
50 %alive.1 = icmp eq i32 %a, 16
51 %alive.2 = icmp eq i32 %a, 8
52 %result = or i1 %alive.1, %alive.2
56 define i1 @test4(i32 %a, i1 %flag) {
57 ; CHECK-LABEL: @test4(
59 ; CHECK-NEXT: %alive = icmp eq i32 %a, 12
60 ; CHECK-NEXT: %result = or i1 false, %alive
61 br i1 %flag, label %true, label %false
64 %cmp.t = icmp ult i32 %a, 16
65 call void(i1,...) @llvm.experimental.guard(i1 %cmp.t) [ "deopt"() ]
69 %cmp.f = icmp ult i32 %a, 12
70 call void(i1,...) @llvm.experimental.guard(i1 %cmp.f) [ "deopt"() ]
74 %dead = icmp eq i32 %a, 16
75 %alive = icmp eq i32 %a, 12
76 %result = or i1 %dead, %alive
80 define i1 @test5(i32 %a) {
81 ; CHECK-LABEL: @test5(
83 ; CHECK-NEXT: %alive = icmp eq i32 %a.plus.8, 16
84 ; CHECK-NEXT: %result = or i1 false, %alive
85 %cmp = icmp ult i32 %a, 16
86 call void(i1,...) @llvm.experimental.guard(i1 %cmp) [ "deopt"() ]
87 %a.plus.8 = add i32 %a, 8
91 %dead = icmp eq i32 %a.plus.8, 24
92 %alive = icmp eq i32 %a.plus.8, 16
93 %result = or i1 %dead, %alive
97 ; Check that we handle the case when the guard is the very first instruction in
99 define i1 @test6(i32 %a) {
100 ; CHECK-LABEL: @test6(
101 ; CHECK: %alive = icmp eq i32 %a, 8
102 ; CHECK-NEXT: %result = or i1 false, %alive
103 %cmp = icmp ult i32 %a, 16
107 call void(i1,...) @llvm.experimental.guard(i1 %cmp) [ "deopt"() ]
108 %dead = icmp eq i32 %a, 16
109 %alive = icmp eq i32 %a, 8
110 %result = or i1 %dead, %alive