conflict.ll
1.87 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt -correlated-propagation -S < %s | FileCheck %s
; Checks that we don't crash on conflicting facts about a value
; (i.e. unreachable code)
; Test that we can handle conflict edge facts
define i8 @test(i8 %a) {
; CHECK-LABEL: @test(
; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 [[A:%.*]], 5
; CHECK-NEXT: br i1 [[CMP1]], label [[NEXT:%.*]], label [[EXIT:%.*]]
; CHECK: next:
; CHECK-NEXT: br i1 false, label [[DEAD:%.*]], label [[EXIT]]
; CHECK: dead:
; CHECK-NEXT: ret i8 5
; CHECK: exit:
; CHECK-NEXT: ret i8 0
;
%cmp1 = icmp eq i8 %a, 5
br i1 %cmp1, label %next, label %exit
next:
%cmp2 = icmp eq i8 %a, 3
br i1 %cmp2, label %dead, label %exit
dead:
; NOTE: undef, or 3 would be equal valid
ret i8 %a
exit:
ret i8 0
}
declare void @llvm.assume(i1)
; Test that we can handle conflicting assume vs edge facts
define i8 @test2(i8 %a) {
; CHECK-LABEL: @test2(
; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 [[A:%.*]], 5
; CHECK-NEXT: call void @llvm.assume(i1 [[CMP1]])
; CHECK-NEXT: br i1 false, label [[DEAD:%.*]], label [[EXIT:%.*]]
; CHECK: dead:
; CHECK-NEXT: ret i8 5
; CHECK: exit:
; CHECK-NEXT: ret i8 0
;
%cmp1 = icmp eq i8 %a, 5
call void @llvm.assume(i1 %cmp1)
%cmp2 = icmp eq i8 %a, 3
br i1 %cmp2, label %dead, label %exit
dead:
ret i8 %a
exit:
ret i8 0
}
define i8 @test3(i8 %a) {
; CHECK-LABEL: @test3(
; CHECK-NEXT: [[CMP1:%.*]] = icmp eq i8 [[A:%.*]], 5
; CHECK-NEXT: br i1 [[CMP1]], label [[DEAD:%.*]], label [[EXIT:%.*]]
; CHECK: dead:
; CHECK-NEXT: call void @llvm.assume(i1 false)
; CHECK-NEXT: ret i8 5
; CHECK: exit:
; CHECK-NEXT: ret i8 0
;
%cmp1 = icmp eq i8 %a, 5
br i1 %cmp1, label %dead, label %exit
dead:
%cmp2 = icmp eq i8 %a, 3
call void @llvm.assume(i1 %cmp2)
ret i8 %a
exit:
ret i8 0
}