binaryops-constexprs.ll
4.78 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
122
123
124
125
126
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -sccp -S | FileCheck %s
declare void @use.i32(i32)
declare void @use.i1(i1)
define void @and_constexpr(i32 %a) {
; CHECK-LABEL: @and_constexpr(
; CHECK-NEXT: entry:
; CHECK-NEXT: call void @use.i32(i32 0)
; CHECK-NEXT: [[AND_2:%.*]] = and i32 20, [[A:%.*]]
; CHECK-NEXT: call void @use.i32(i32 [[AND_2]])
; CHECK-NEXT: call void @use.i1(i1 true)
; CHECK-NEXT: call void @use.i1(i1 false)
; CHECK-NEXT: [[COND_1:%.*]] = icmp eq i32 [[AND_2]], 10
; CHECK-NEXT: call void @use.i1(i1 [[COND_1]])
; CHECK-NEXT: call void @use.i32(i32 4)
; CHECK-NEXT: ret void
;
entry:
%and.1 = and i32 ptrtoint (i32* inttoptr (i32 0 to i32*) to i32), %a
call void @use.i32(i32 %and.1)
%and.2 = and i32 ptrtoint (i32* inttoptr (i32 20 to i32*) to i32), %a
call void @use.i32(i32 %and.2)
%true.1 = icmp ne i32 %and.2, 100
call void @use.i1(i1 %true.1)
%false.1 = icmp eq i32 %and.2, 100
call void @use.i1(i1 %false.1)
%cond.1 = icmp eq i32 %and.2, 10
call void @use.i1(i1 %cond.1)
%and.3 = and i32 ptrtoint (i32* inttoptr (i32 20 to i32*) to i32), ptrtoint (i32* inttoptr (i32 100 to i32*) to i32)
call void @use.i32(i32 %and.3)
ret void
}
define void @add_constexpr(i32 %a) {
; CHECK-LABEL: @add_constexpr(
; CHECK-NEXT: entry:
; CHECK-NEXT: [[ADD_1:%.*]] = add i32 0, [[A:%.*]]
; CHECK-NEXT: call void @use.i32(i32 [[ADD_1]])
; CHECK-NEXT: [[ADD_2:%.*]] = add i32 20, [[A]]
; CHECK-NEXT: call void @use.i32(i32 [[ADD_2]])
; CHECK-NEXT: [[COND_1:%.*]] = icmp ne i32 [[ADD_2]], 100
; CHECK-NEXT: call void @use.i1(i1 [[COND_1]])
; CHECK-NEXT: [[COND_2:%.*]] = icmp eq i32 [[ADD_2]], 100
; CHECK-NEXT: call void @use.i1(i1 [[COND_2]])
; CHECK-NEXT: [[COND_3:%.*]] = icmp eq i32 [[ADD_2]], 10
; CHECK-NEXT: call void @use.i1(i1 [[COND_3]])
; CHECK-NEXT: call void @use.i32(i32 120)
; CHECK-NEXT: ret void
;
entry:
%add.1 = add i32 ptrtoint (i32* inttoptr (i32 0 to i32*) to i32), %a
call void @use.i32(i32 %add.1)
%add.2 = add i32 ptrtoint (i32* inttoptr (i32 20 to i32*) to i32), %a
call void @use.i32(i32 %add.2)
%cond.1 = icmp ne i32 %add.2, 100
call void @use.i1(i1 %cond.1)
%cond.2 = icmp eq i32 %add.2, 100
call void @use.i1(i1 %cond.2)
%cond.3 = icmp eq i32 %add.2, 10
call void @use.i1(i1 %cond.3)
%add.3 = add i32 ptrtoint (i32* inttoptr (i32 20 to i32*) to i32), ptrtoint (i32* inttoptr (i32 100 to i32*) to i32)
call void @use.i32(i32 %add.3)
ret void
}
define void @mul_constexpr(i32 %a) {
; CHECK-LABEL: @mul_constexpr(
; CHECK-NEXT: entry:
; CHECK-NEXT: call void @use.i32(i32 0)
; CHECK-NEXT: [[MUL_2:%.*]] = mul i32 20, [[A:%.*]]
; CHECK-NEXT: call void @use.i32(i32 [[MUL_2]])
; CHECK-NEXT: [[COND_1:%.*]] = icmp ne i32 [[MUL_2]], 100
; CHECK-NEXT: call void @use.i1(i1 [[COND_1]])
; CHECK-NEXT: [[COND_2:%.*]] = icmp eq i32 [[MUL_2]], 100
; CHECK-NEXT: call void @use.i1(i1 [[COND_2]])
; CHECK-NEXT: [[COND_3:%.*]] = icmp eq i32 [[MUL_2]], 10
; CHECK-NEXT: call void @use.i1(i1 [[COND_3]])
; CHECK-NEXT: call void @use.i32(i32 2000)
; CHECK-NEXT: ret void
;
entry:
%mul.1 = mul i32 ptrtoint (i32* inttoptr (i32 0 to i32*) to i32), %a
call void @use.i32(i32 %mul.1)
%mul.2 = mul i32 ptrtoint (i32* inttoptr (i32 20 to i32*) to i32), %a
call void @use.i32(i32 %mul.2)
%cond.1 = icmp ne i32 %mul.2, 100
call void @use.i1(i1 %cond.1)
%cond.2 = icmp eq i32 %mul.2, 100
call void @use.i1(i1 %cond.2)
%cond.3 = icmp eq i32 %mul.2, 10
call void @use.i1(i1 %cond.3)
%mul.3 = mul i32 ptrtoint (i32* inttoptr (i32 20 to i32*) to i32), ptrtoint (i32* inttoptr (i32 100 to i32*) to i32)
call void @use.i32(i32 %mul.3)
ret void
}
define void @udiv_constexpr(i32 %a) {
; CHECK-LABEL: @udiv_constexpr(
; CHECK-NEXT: entry:
; CHECK-NEXT: call void @use.i32(i32 0)
; CHECK-NEXT: [[UDIV_2:%.*]] = udiv i32 20, [[A:%.*]]
; CHECK-NEXT: call void @use.i32(i32 [[UDIV_2]])
; CHECK-NEXT: call void @use.i1(i1 true)
; CHECK-NEXT: call void @use.i1(i1 false)
; CHECK-NEXT: [[COND_1:%.*]] = icmp eq i32 [[UDIV_2]], 10
; CHECK-NEXT: call void @use.i1(i1 [[COND_1]])
; CHECK-NEXT: call void @use.i32(i32 0)
; CHECK-NEXT: ret void
;
entry:
%udiv.1 = udiv i32 ptrtoint (i32* inttoptr (i32 0 to i32*) to i32), %a
call void @use.i32(i32 %udiv.1)
%udiv.2 = udiv i32 ptrtoint (i32* inttoptr (i32 20 to i32*) to i32), %a
call void @use.i32(i32 %udiv.2)
%true.1 = icmp ne i32 %udiv.2, 100
call void @use.i1(i1 %true.1)
%false.1 = icmp eq i32 %udiv.2, 50
call void @use.i1(i1 %false.1)
%cond.1 = icmp eq i32 %udiv.2, 10
call void @use.i1(i1 %cond.1)
%udiv.3 = udiv i32 ptrtoint (i32* inttoptr (i32 20 to i32*) to i32), ptrtoint (i32* inttoptr (i32 100 to i32*) to i32)
call void @use.i32(i32 %udiv.3)
ret void
}