assume_icmp.ll
3.81 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
113
114
115
116
117
118
119
120
121
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -instsimplify -S | FileCheck %s
declare void @llvm.assume(i1)
declare void @use(i1)
define void @basic_ugt(i32 %x, i32 %y) {
; CHECK-LABEL: @basic_ugt(
; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt i32 [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: call void @llvm.assume(i1 [[CMP1]])
; CHECK-NEXT: call void @use(i1 true)
; CHECK-NEXT: call void @use(i1 true)
; CHECK-NEXT: call void @use(i1 false)
; CHECK-NEXT: call void @use(i1 false)
; CHECK-NEXT: call void @use(i1 false)
; CHECK-NEXT: call void @use(i1 false)
; CHECK-NEXT: call void @use(i1 true)
; CHECK-NEXT: call void @use(i1 true)
; CHECK-NEXT: ret void
;
%cmp1 = icmp ugt i32 %x, %y
call void @llvm.assume(i1 %cmp1)
%cmp2 = icmp ugt i32 %x, %y
call void @use(i1 %cmp2)
%cmp3 = icmp uge i32 %x, %y
call void @use(i1 %cmp3)
%cmp4 = icmp ult i32 %x, %y
call void @use(i1 %cmp4)
%cmp5 = icmp ule i32 %x, %y
call void @use(i1 %cmp5)
%cmp6 = icmp ugt i32 %y, %x
call void @use(i1 %cmp6)
%cmp7 = icmp uge i32 %y, %x
call void @use(i1 %cmp7)
%cmp8 = icmp ult i32 %y, %x
call void @use(i1 %cmp8)
%cmp9 = icmp ule i32 %y, %x
call void @use(i1 %cmp9)
ret void
}
define void @basic_uge(i32 %x, i32 %y) {
; CHECK-LABEL: @basic_uge(
; CHECK-NEXT: [[CMP1:%.*]] = icmp uge i32 [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: call void @llvm.assume(i1 [[CMP1]])
; CHECK-NEXT: [[CMP2:%.*]] = icmp ugt i32 [[X]], [[Y]]
; CHECK-NEXT: call void @use(i1 [[CMP2]])
; CHECK-NEXT: call void @use(i1 true)
; CHECK-NEXT: call void @use(i1 false)
; CHECK-NEXT: [[CMP5:%.*]] = icmp ule i32 [[X]], [[Y]]
; CHECK-NEXT: call void @use(i1 [[CMP5]])
; CHECK-NEXT: call void @use(i1 false)
; CHECK-NEXT: [[CMP7:%.*]] = icmp uge i32 [[Y]], [[X]]
; CHECK-NEXT: call void @use(i1 [[CMP7]])
; CHECK-NEXT: [[CMP8:%.*]] = icmp ult i32 [[Y]], [[X]]
; CHECK-NEXT: call void @use(i1 [[CMP8]])
; CHECK-NEXT: call void @use(i1 true)
; CHECK-NEXT: ret void
;
%cmp1 = icmp uge i32 %x, %y
call void @llvm.assume(i1 %cmp1)
%cmp2 = icmp ugt i32 %x, %y
call void @use(i1 %cmp2)
%cmp3 = icmp uge i32 %x, %y
call void @use(i1 %cmp3)
%cmp4 = icmp ult i32 %x, %y
call void @use(i1 %cmp4)
%cmp5 = icmp ule i32 %x, %y
call void @use(i1 %cmp5)
%cmp6 = icmp ugt i32 %y, %x
call void @use(i1 %cmp6)
%cmp7 = icmp uge i32 %y, %x
call void @use(i1 %cmp7)
%cmp8 = icmp ult i32 %y, %x
call void @use(i1 %cmp8)
%cmp9 = icmp ule i32 %y, %x
call void @use(i1 %cmp9)
ret void
}
; This does not simplify in InstSimplify, because AssumptionCache tracker
; does not track values through "and". The "and" assume will be broken
; down into two separate assume calls by InstCombine.
define void @and(i32 %x, i32 %y, i32 %z) {
; CHECK-LABEL: @and(
; CHECK-NEXT: [[CMP1:%.*]] = icmp ugt i32 [[X:%.*]], [[Y:%.*]]
; CHECK-NEXT: [[CMP2:%.*]] = icmp ugt i32 [[Z:%.*]], [[Y]]
; CHECK-NEXT: [[AND:%.*]] = and i1 [[CMP1]], [[CMP2]]
; CHECK-NEXT: call void @llvm.assume(i1 [[AND]])
; CHECK-NEXT: [[CMP3:%.*]] = icmp ugt i32 [[X]], [[Y]]
; CHECK-NEXT: call void @use(i1 [[CMP3]])
; CHECK-NEXT: [[CMP4:%.*]] = icmp uge i32 [[X]], [[Y]]
; CHECK-NEXT: call void @use(i1 [[CMP4]])
; CHECK-NEXT: [[CMP5:%.*]] = icmp ugt i32 [[Z]], [[Y]]
; CHECK-NEXT: call void @use(i1 [[CMP5]])
; CHECK-NEXT: [[CMP6:%.*]] = icmp uge i32 [[Z]], [[Y]]
; CHECK-NEXT: call void @use(i1 [[CMP6]])
; CHECK-NEXT: ret void
;
%cmp1 = icmp ugt i32 %x, %y
%cmp2 = icmp ugt i32 %z, %y
%and = and i1 %cmp1, %cmp2
call void @llvm.assume(i1 %and)
%cmp3 = icmp ugt i32 %x, %y
call void @use(i1 %cmp3)
%cmp4 = icmp uge i32 %x, %y
call void @use(i1 %cmp4)
%cmp5 = icmp ugt i32 %z, %y
call void @use(i1 %cmp5)
%cmp6 = icmp uge i32 %z, %y
call void @use(i1 %cmp6)
ret void
}