• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; REQUIRES: asserts
2; RUN: opt -inline -mtriple=aarch64--linux-gnu -S -debug-only=inline-cost < %s 2>&1 | FileCheck %s
3
4target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
5target triple = "aarch64--linux-gnu"
6
7; FIXME: Once the 'or' or 'and' is simplified the second compare is dead, but
8; the inline cost model has already added the cost.
9
10define i1 @outer1(i32 %a) {
11  %C = call i1 @inner1(i32 0, i32 %a)
12  ret i1 %C
13}
14
15; CHECK: Analyzing call of inner1
16; CHECK: NumInstructionsSimplified: 3
17; CHECK: NumInstructions: 4
18define i1 @inner1(i32 %a, i32 %b) {
19  %tobool = icmp eq i32 %a, 0         ; Simplifies to true
20  %tobool1 = icmp eq i32 %b, 0        ; Should be dead once 'or' is simplified
21  %or.cond = or i1 %tobool, %tobool1  ; Simplifies to true
22  ret i1 %or.cond                     ; Simplifies to ret i1 true
23}
24
25define i1 @outer2(i32 %a) {
26  %C = call i1 @inner2(i32 1, i32 %a)
27  ret i1 %C
28}
29
30; CHECK: Analyzing call of inner2
31; CHECK: NumInstructionsSimplified: 3
32; CHECK: NumInstructions: 4
33define i1 @inner2(i32 %a, i32 %b) {
34  %tobool = icmp eq i32 %a, 0          ; Simplifies to false
35  %tobool1 = icmp eq i32 %b, 0         ; Should be dead once 'and' is simplified
36  %and.cond = and i1 %tobool, %tobool1 ; Simplifies to false
37  ret i1 %and.cond                     ; Simplifies to ret i1 false
38}
39
40
41define i32 @outer3(i32 %a) {
42  %C = call i32 @inner3(i32 4294967295, i32 %a)
43  ret i32 %C
44}
45
46; CHECK: Analyzing call of inner3
47; CHECK: NumInstructionsSimplified: 2
48; CHECK: NumInstructions: 2
49define i32 @inner3(i32 %a, i32 %b) {
50  %or.cond = or i32 %a, %b         ; Simplifies to 4294967295
51  ret i32 %or.cond                 ; Simplifies to ret i32 4294967295
52}
53
54
55define i32 @outer4(i32 %a) {
56  %C = call i32 @inner4(i32 0, i32 %a)
57  ret i32 %C
58}
59
60; CHECK: Analyzing call of inner4
61; CHECK: NumInstructionsSimplified: 2
62; CHECK: NumInstructions: 2
63define i32 @inner4(i32 %a, i32 %b) {
64  %and.cond = and i32 %a, %b       ; Simplifies to 0
65  ret i32 %and.cond                ; Simplifies to ret i32 0
66}
67
68define i1 @outer5(i32 %a) {
69  %C = call i1 @inner5(i32 0, i32 %a)
70  ret i1 %C
71}
72
73; CHECK: Analyzing call of inner5
74; CHECK: NumInstructionsSimplified: 4
75; CHECK: NumInstructions: 5
76define i1 @inner5(i32 %a, i32 %b) {
77  %tobool = icmp eq i32 %a, 0         ; Simplifies to true
78  %tobool1 = icmp eq i32 %b, 0        ; Should be dead once 'or' is simplified
79  %or.cond = or i1 %tobool, %tobool1  ; Simplifies to true
80  br i1 %or.cond, label %end, label %isfalse ; Simplifies to br label %end
81
82isfalse:             ; This block is unreachable once inlined
83  call void @dead()
84  call void @dead()
85  call void @dead()
86  call void @dead()
87  call void @dead()
88  br label %end
89
90end:
91  ret i1 %or.cond    ; Simplifies to ret i1 true
92}
93
94declare void @dead()
95