logical-and-or.ll
2.72 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
; REQUIRES: asserts
; RUN: opt -inline -mtriple=aarch64--linux-gnu -S -debug-only=inline-cost < %s 2>&1 | FileCheck %s
target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
target triple = "aarch64--linux-gnu"
; FIXME: Once the 'or' or 'and' is simplified the second compare is dead, but
; the inline cost model has already added the cost.
define i1 @outer1(i32 %a) {
%C = call i1 @inner1(i32 0, i32 %a)
ret i1 %C
}
; CHECK: Analyzing call of inner1
; CHECK: NumInstructionsSimplified: 3
; CHECK: NumInstructions: 4
define i1 @inner1(i32 %a, i32 %b) {
%tobool = icmp eq i32 %a, 0 ; Simplifies to true
%tobool1 = icmp eq i32 %b, 0 ; Should be dead once 'or' is simplified
%or.cond = or i1 %tobool, %tobool1 ; Simplifies to true
ret i1 %or.cond ; Simplifies to ret i1 true
}
define i1 @outer2(i32 %a) {
%C = call i1 @inner2(i32 1, i32 %a)
ret i1 %C
}
; CHECK: Analyzing call of inner2
; CHECK: NumInstructionsSimplified: 3
; CHECK: NumInstructions: 4
define i1 @inner2(i32 %a, i32 %b) {
%tobool = icmp eq i32 %a, 0 ; Simplifies to false
%tobool1 = icmp eq i32 %b, 0 ; Should be dead once 'and' is simplified
%and.cond = and i1 %tobool, %tobool1 ; Simplifies to false
ret i1 %and.cond ; Simplifies to ret i1 false
}
define i32 @outer3(i32 %a) {
%C = call i32 @inner3(i32 4294967295, i32 %a)
ret i32 %C
}
; CHECK: Analyzing call of inner3
; CHECK: NumInstructionsSimplified: 2
; CHECK: NumInstructions: 2
define i32 @inner3(i32 %a, i32 %b) {
%or.cond = or i32 %a, %b ; Simplifies to 4294967295
ret i32 %or.cond ; Simplifies to ret i32 4294967295
}
define i32 @outer4(i32 %a) {
%C = call i32 @inner4(i32 0, i32 %a)
ret i32 %C
}
; CHECK: Analyzing call of inner4
; CHECK: NumInstructionsSimplified: 2
; CHECK: NumInstructions: 2
define i32 @inner4(i32 %a, i32 %b) {
%and.cond = and i32 %a, %b ; Simplifies to 0
ret i32 %and.cond ; Simplifies to ret i32 0
}
define i1 @outer5(i32 %a) {
%C = call i1 @inner5(i32 0, i32 %a)
ret i1 %C
}
; CHECK: Analyzing call of inner5
; CHECK: NumInstructionsSimplified: 4
; CHECK: NumInstructions: 5
define i1 @inner5(i32 %a, i32 %b) {
%tobool = icmp eq i32 %a, 0 ; Simplifies to true
%tobool1 = icmp eq i32 %b, 0 ; Should be dead once 'or' is simplified
%or.cond = or i1 %tobool, %tobool1 ; Simplifies to true
br i1 %or.cond, label %end, label %isfalse ; Simplifies to br label %end
isfalse: ; This block is unreachable once inlined
call void @dead()
call void @dead()
call void @dead()
call void @dead()
call void @dead()
br label %end
end:
ret i1 %or.cond ; Simplifies to ret i1 true
}
declare void @dead()