1 ; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
2 ; RUN: opt -passes=correlated-propagation -S < %s | FileCheck %s
4 ; Checks that we don't crash on conflicting facts about a value
5 ; (i.e. unreachable code)
7 ; Test that we can handle conflict edge facts
9 define i8 @test(i8 %a) {
11 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 [[A:%.*]], 5
12 ; CHECK-NEXT: br i1 [[CMP1]], label [[NEXT:%.*]], label [[EXIT:%.*]]
14 ; CHECK-NEXT: br i1 false, label [[DEAD:%.*]], label [[EXIT]]
16 ; CHECK-NEXT: ret i8 5
18 ; CHECK-NEXT: ret i8 0
20 %cmp1 = icmp eq i8 %a, 5
21 br i1 %cmp1, label %next, label %exit
23 %cmp2 = icmp eq i8 %a, 3
24 br i1 %cmp2, label %dead, label %exit
26 ; NOTE: undef, or 3 would be equal valid
32 declare void @llvm.assume(i1)
34 ; Test that we can handle conflicting assume vs edge facts
36 define i8 @test2(i8 %a) {
37 ; CHECK-LABEL: @test2(
38 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 [[A:%.*]], 5
39 ; CHECK-NEXT: call void @llvm.assume(i1 [[CMP1]])
40 ; CHECK-NEXT: br i1 false, label [[DEAD:%.*]], label [[EXIT:%.*]]
42 ; CHECK-NEXT: ret i8 5
44 ; CHECK-NEXT: ret i8 0
46 %cmp1 = icmp eq i8 %a, 5
47 call void @llvm.assume(i1 %cmp1)
48 %cmp2 = icmp eq i8 %a, 3
49 br i1 %cmp2, label %dead, label %exit
56 define i8 @test3(i8 %a) {
57 ; CHECK-LABEL: @test3(
58 ; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 [[A:%.*]], 5
59 ; CHECK-NEXT: br i1 [[CMP1]], label [[DEAD:%.*]], label [[EXIT:%.*]]
61 ; CHECK-NEXT: call void @llvm.assume(i1 false)
62 ; CHECK-NEXT: ret i8 5
64 ; CHECK-NEXT: ret i8 0
66 %cmp1 = icmp eq i8 %a, 5
67 br i1 %cmp1, label %dead, label %exit
69 %cmp2 = icmp eq i8 %a, 3
70 call void @llvm.assume(i1 %cmp2)