assume-queries-counter.ll
4.33 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
; REQUIRES: asserts
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instcombine --debug-counter=assume-queries-counter-skip=0,assume-queries-counter-count=1 -S | FileCheck %s --check-prefixes=SAME,COUNTER1
; RUN: opt < %s -instcombine --debug-counter=assume-queries-counter-skip=1,assume-queries-counter-count=2 -S | FileCheck %s --check-prefixes=SAME,COUNTER2
; RUN: opt < %s -instcombine --debug-counter=assume-queries-counter-skip=2,assume-queries-counter-count=1 -S | FileCheck %s --check-prefixes=SAME,COUNTER3
declare i1 @get_val()
declare void @llvm.assume(i1)
define dso_local i1 @test1(i32* readonly %0) {
; COUNTER1-LABEL: @test1(
; COUNTER1-NEXT: call void @llvm.assume(i1 true) [ "nonnull"(i32* [[TMP0:%.*]]) ]
; COUNTER1-NEXT: ret i1 false
;
; COUNTER2-LABEL: @test1(
; COUNTER2-NEXT: call void @llvm.assume(i1 true) [ "nonnull"(i32* [[TMP0:%.*]]) ]
; COUNTER2-NEXT: [[TMP2:%.*]] = icmp eq i32* [[TMP0]], null
; COUNTER2-NEXT: ret i1 [[TMP2]]
;
; COUNTER3-LABEL: @test1(
; COUNTER3-NEXT: call void @llvm.assume(i1 true) [ "nonnull"(i32* [[TMP0:%.*]]) ]
; COUNTER3-NEXT: [[TMP2:%.*]] = icmp eq i32* [[TMP0]], null
; COUNTER3-NEXT: ret i1 [[TMP2]]
;
call void @llvm.assume(i1 true) ["nonnull"(i32* %0)]
%2 = icmp eq i32* %0, null
ret i1 %2
}
define dso_local i1 @test2(i32* readonly %0) {
; COUNTER1-LABEL: @test2(
; COUNTER1-NEXT: [[TMP2:%.*]] = icmp eq i32* [[TMP0:%.*]], null
; COUNTER1-NEXT: call void @llvm.assume(i1 true) [ "nonnull"(i32* [[TMP0]]) ]
; COUNTER1-NEXT: ret i1 [[TMP2]]
;
; COUNTER2-LABEL: @test2(
; COUNTER2-NEXT: call void @llvm.assume(i1 true) [ "nonnull"(i32* [[TMP0:%.*]]) ]
; COUNTER2-NEXT: ret i1 false
;
; COUNTER3-LABEL: @test2(
; COUNTER3-NEXT: [[TMP2:%.*]] = icmp eq i32* [[TMP0:%.*]], null
; COUNTER3-NEXT: call void @llvm.assume(i1 true) [ "nonnull"(i32* [[TMP0]]) ]
; COUNTER3-NEXT: ret i1 [[TMP2]]
;
%2 = icmp eq i32* %0, null
call void @llvm.assume(i1 true) ["nonnull"(i32* %0)]
ret i1 %2
}
define dso_local i32 @test4(i32* readonly %0, i1 %cond) {
; COUNTER1-LABEL: @test4(
; COUNTER1-NEXT: call void @llvm.assume(i1 true) [ "dereferenceable"(i32* [[TMP0:%.*]], i32 4) ]
; COUNTER1-NEXT: br i1 [[COND:%.*]], label [[A:%.*]], label [[B:%.*]]
; COUNTER1: B:
; COUNTER1-NEXT: br label [[A]]
; COUNTER1: A:
; COUNTER1-NEXT: [[TMP2:%.*]] = icmp eq i32* [[TMP0]], null
; COUNTER1-NEXT: br i1 [[TMP2]], label [[TMP5:%.*]], label [[TMP3:%.*]]
; COUNTER1: 3:
; COUNTER1-NEXT: [[TMP4:%.*]] = load i32, i32* [[TMP0]], align 4
; COUNTER1-NEXT: br label [[TMP5]]
; COUNTER1: 5:
; COUNTER1-NEXT: [[TMP6:%.*]] = phi i32 [ [[TMP4]], [[TMP3]] ], [ 0, [[A]] ]
; COUNTER1-NEXT: ret i32 [[TMP6]]
;
; COUNTER2-LABEL: @test4(
; COUNTER2-NEXT: call void @llvm.assume(i1 true) [ "dereferenceable"(i32* [[TMP0:%.*]], i32 4) ]
; COUNTER2-NEXT: br i1 [[COND:%.*]], label [[A:%.*]], label [[B:%.*]]
; COUNTER2: B:
; COUNTER2-NEXT: br label [[A]]
; COUNTER2: A:
; COUNTER2-NEXT: br i1 false, label [[TMP4:%.*]], label [[TMP2:%.*]]
; COUNTER2: 2:
; COUNTER2-NEXT: [[TMP3:%.*]] = load i32, i32* [[TMP0]], align 4
; COUNTER2-NEXT: br label [[TMP4]]
; COUNTER2: 4:
; COUNTER2-NEXT: [[TMP5:%.*]] = phi i32 [ [[TMP3]], [[TMP2]] ], [ 0, [[A]] ]
; COUNTER2-NEXT: ret i32 [[TMP5]]
;
; COUNTER3-LABEL: @test4(
; COUNTER3-NEXT: call void @llvm.assume(i1 true) [ "dereferenceable"(i32* [[TMP0:%.*]], i32 4) ]
; COUNTER3-NEXT: br i1 [[COND:%.*]], label [[A:%.*]], label [[B:%.*]]
; COUNTER3: B:
; COUNTER3-NEXT: br label [[A]]
; COUNTER3: A:
; COUNTER3-NEXT: br i1 false, label [[TMP4:%.*]], label [[TMP2:%.*]]
; COUNTER3: 2:
; COUNTER3-NEXT: [[TMP3:%.*]] = load i32, i32* [[TMP0]], align 4
; COUNTER3-NEXT: br label [[TMP4]]
; COUNTER3: 4:
; COUNTER3-NEXT: [[TMP5:%.*]] = phi i32 [ [[TMP3]], [[TMP2]] ], [ 0, [[A]] ]
; COUNTER3-NEXT: ret i32 [[TMP5]]
;
call void @llvm.assume(i1 true) ["dereferenceable"(i32* %0, i32 4)]
br i1 %cond, label %A, label %B
B:
br label %A
A:
%2 = icmp eq i32* %0, null
br i1 %2, label %5, label %3
3: ; preds = %1
%4 = load i32, i32* %0, align 4
br label %5
5: ; preds = %1, %3
%6 = phi i32 [ %4, %3 ], [ 0, %A ]
ret i32 %6
}