eliminate-sat.ll
3.64 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
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -S -indvars | FileCheck %s
declare i32 @llvm.uadd.sat.i32(i32, i32)
declare i32 @llvm.sadd.sat.i32(i32, i32)
declare i32 @llvm.usub.sat.i32(i32, i32)
declare i32 @llvm.ssub.sat.i32(i32, i32)
define void @uadd_sat(i32* %p) {
; CHECK-LABEL: @uadd_sat(
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[LOOP:%.*]]
; CHECK: loop:
; CHECK-NEXT: [[I:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[I_INC:%.*]], [[LOOP]] ]
; CHECK-NEXT: [[SAT1:%.*]] = add nuw nsw i32 [[I]], 1
; CHECK-NEXT: store volatile i32 [[SAT1]], i32* [[P:%.*]]
; CHECK-NEXT: [[I_INC]] = add nuw nsw i32 [[I]], 1
; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[I_INC]], 100
; CHECK-NEXT: br i1 [[CMP]], label [[LOOP]], label [[END:%.*]]
; CHECK: end:
; CHECK-NEXT: ret void
;
entry:
br label %loop
loop:
%i = phi i32 [ 0, %entry ], [ %i.inc, %loop ]
%sat = call i32 @llvm.uadd.sat.i32(i32 %i, i32 1)
store volatile i32 %sat, i32* %p
%i.inc = add nuw nsw i32 %i, 1
%cmp = icmp ne i32 %i.inc, 100
br i1 %cmp, label %loop, label %end
end:
ret void
}
define void @sadd_sat(i32* %p) {
; CHECK-LABEL: @sadd_sat(
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[LOOP:%.*]]
; CHECK: loop:
; CHECK-NEXT: [[I:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[I_INC:%.*]], [[LOOP]] ]
; CHECK-NEXT: [[SAT1:%.*]] = add nuw nsw i32 [[I]], 1
; CHECK-NEXT: store volatile i32 [[SAT1]], i32* [[P:%.*]]
; CHECK-NEXT: [[I_INC]] = add nuw nsw i32 [[I]], 1
; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[I_INC]], 100
; CHECK-NEXT: br i1 [[CMP]], label [[LOOP]], label [[END:%.*]]
; CHECK: end:
; CHECK-NEXT: ret void
;
entry:
br label %loop
loop:
%i = phi i32 [ 0, %entry ], [ %i.inc, %loop ]
%sat = call i32 @llvm.sadd.sat.i32(i32 %i, i32 1)
store volatile i32 %sat, i32* %p
%i.inc = add nuw nsw i32 %i, 1
%cmp = icmp ne i32 %i.inc, 100
br i1 %cmp, label %loop, label %end
end:
ret void
}
define void @usub_sat(i32* %p) {
; CHECK-LABEL: @usub_sat(
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[LOOP:%.*]]
; CHECK: loop:
; CHECK-NEXT: [[I:%.*]] = phi i32 [ 1, [[ENTRY:%.*]] ], [ [[I_INC:%.*]], [[LOOP]] ]
; CHECK-NEXT: [[SAT1:%.*]] = sub nuw nsw i32 [[I]], 1
; CHECK-NEXT: store volatile i32 [[SAT1]], i32* [[P:%.*]]
; CHECK-NEXT: [[I_INC]] = add nuw nsw i32 [[I]], 1
; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[I_INC]], 100
; CHECK-NEXT: br i1 [[CMP]], label [[LOOP]], label [[END:%.*]]
; CHECK: end:
; CHECK-NEXT: ret void
;
entry:
br label %loop
loop:
%i = phi i32 [ 1, %entry ], [ %i.inc, %loop ]
%sat = call i32 @llvm.usub.sat.i32(i32 %i, i32 1)
store volatile i32 %sat, i32* %p
%i.inc = add nuw nsw i32 %i, 1
%cmp = icmp ne i32 %i.inc, 100
br i1 %cmp, label %loop, label %end
end:
ret void
}
define void @ssub_sat(i32* %p) {
; CHECK-LABEL: @ssub_sat(
; CHECK-NEXT: entry:
; CHECK-NEXT: br label [[LOOP:%.*]]
; CHECK: loop:
; CHECK-NEXT: [[I:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[I_INC:%.*]], [[LOOP]] ]
; CHECK-NEXT: [[SAT1:%.*]] = sub nsw i32 [[I]], 1
; CHECK-NEXT: store volatile i32 [[SAT1]], i32* [[P:%.*]]
; CHECK-NEXT: [[I_INC]] = add nuw nsw i32 [[I]], 1
; CHECK-NEXT: [[CMP:%.*]] = icmp ne i32 [[I_INC]], 100
; CHECK-NEXT: br i1 [[CMP]], label [[LOOP]], label [[END:%.*]]
; CHECK: end:
; CHECK-NEXT: ret void
;
entry:
br label %loop
loop:
%i = phi i32 [ 0, %entry ], [ %i.inc, %loop ]
%sat = call i32 @llvm.ssub.sat.i32(i32 %i, i32 1)
store volatile i32 %sat, i32* %p
%i.inc = add nuw nsw i32 %i, 1
%cmp = icmp ne i32 %i.inc, 100
br i1 %cmp, label %loop, label %end
end:
ret void
}