binaryops-range-special-cases.ll
2.63 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
; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -ipsccp -S | FileCheck %s
declare void @use(i1)
define void @sdiv1_cmp_constants(i32 %x) {
; CHECK-LABEL: @sdiv1_cmp_constants(
; CHECK-NEXT: [[D:%.*]] = sdiv i32 1, [[X:%.*]]
; CHECK-NEXT: [[C_0:%.*]] = icmp slt i32 0, [[D]]
; CHECK-NEXT: call void @use(i1 [[C_0]])
; CHECK-NEXT: call void @use(i1 false)
; CHECK-NEXT: call void @use(i1 false)
; CHECK-NEXT: [[C_3:%.*]] = icmp eq i32 1, [[D]]
; CHECK-NEXT: call void @use(i1 [[C_3]])
; CHECK-NEXT: [[C_4:%.*]] = icmp eq i32 0, [[D]]
; CHECK-NEXT: call void @use(i1 [[C_4]])
; CHECK-NEXT: call void @use(i1 false)
; CHECK-NEXT: ret void
;
%d = sdiv i32 1, %x
%c.0 = icmp slt i32 0, %d
call void @use(i1 %c.0)
%c.1 = icmp slt i32 1, %d
call void @use(i1 %c.1)
%c.2 = icmp slt i32 2, %d
call void @use(i1 %c.2)
%c.3 = icmp eq i32 1, %d
call void @use(i1 %c.3)
%c.4 = icmp eq i32 0, %d
call void @use(i1 %c.4)
%c.5 = icmp eq i32 2, %d
call void @use(i1 %c.5)
ret void
}
define void @sdiv1_cmp_range_1(i32 %x, i1 %c) {
; CHECK-LABEL: @sdiv1_cmp_range_1(
; CHECK-NEXT: br i1 [[C:%.*]], label [[BB1:%.*]], label [[BB2:%.*]]
; CHECK: bb1:
; CHECK-NEXT: br label [[BB3:%.*]]
; CHECK: bb2:
; CHECK-NEXT: br label [[BB3]]
; CHECK: bb3:
; CHECK-NEXT: [[P:%.*]] = phi i32 [ 1, [[BB1]] ], [ 2, [[BB2]] ]
; CHECK-NEXT: [[D:%.*]] = sdiv i32 1, [[X:%.*]]
; CHECK-NEXT: call void @use(i1 false)
; CHECK-NEXT: [[C_1:%.*]] = icmp eq i32 [[P]], [[D]]
; CHECK-NEXT: call void @use(i1 [[C_1]])
; CHECK-NEXT: ret void
;
br i1 %c, label %bb1, label %bb2
bb1:
br label %bb3
bb2:
br label %bb3
bb3:
%p = phi i32 [1, %bb1], [2, %bb2]
%d = sdiv i32 1, %x
%c.0 = icmp slt i32 %p, %d
call void @use(i1 %c.0)
%c.1 = icmp eq i32 %p, %d
call void @use(i1 %c.1)
ret void
}
define void @sdiv1_cmp_range_2(i32 %x, i1 %c) {
; CHECK-LABEL: @sdiv1_cmp_range_2(
; CHECK-NEXT: br i1 [[C:%.*]], label [[BB1:%.*]], label [[BB2:%.*]]
; CHECK: bb1:
; CHECK-NEXT: br label [[BB3:%.*]]
; CHECK: bb2:
; CHECK-NEXT: br label [[BB3]]
; CHECK: bb3:
; CHECK-NEXT: [[P:%.*]] = phi i32 [ 3, [[BB1]] ], [ 2, [[BB2]] ]
; CHECK-NEXT: [[D:%.*]] = sdiv i32 1, [[X:%.*]]
; CHECK-NEXT: call void @use(i1 false)
; CHECK-NEXT: call void @use(i1 false)
; CHECK-NEXT: ret void
;
br i1 %c, label %bb1, label %bb2
bb1:
br label %bb3
bb2:
br label %bb3
bb3:
%p = phi i32 [3, %bb1], [2, %bb2]
%d = sdiv i32 1, %x
%c.0 = icmp slt i32 %p, %d
call void @use(i1 %c.0)
%c.1 = icmp eq i32 %p, %d
call void @use(i1 %c.1)
ret void
}