2 ; RUN: opt -inline -mtriple=aarch64--linux-gnu -S -debug-only=inline-cost < %s 2>&1 | FileCheck %s
4 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
5 target triple = "aarch64--linux-gnu"
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.
10 define i1 @outer1(i32 %a) {
11 %C = call i1 @inner1(i32 0, i32 %a)
15 ; CHECK: Analyzing call of inner1
16 ; CHECK: NumInstructionsSimplified: 3
17 ; CHECK: NumInstructions: 4
18 define 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
25 define i1 @outer2(i32 %a) {
26 %C = call i1 @inner2(i32 1, i32 %a)
30 ; CHECK: Analyzing call of inner2
31 ; CHECK: NumInstructionsSimplified: 3
32 ; CHECK: NumInstructions: 4
33 define 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
41 define i32 @outer3(i32 %a) {
42 %C = call i32 @inner3(i32 4294967295, i32 %a)
46 ; CHECK: Analyzing call of inner3
47 ; CHECK: NumInstructionsSimplified: 2
48 ; CHECK: NumInstructions: 2
49 define 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
55 define i32 @outer4(i32 %a) {
56 %C = call i32 @inner4(i32 0, i32 %a)
60 ; CHECK: Analyzing call of inner4
61 ; CHECK: NumInstructionsSimplified: 2
62 ; CHECK: NumInstructions: 2
63 define 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
68 define i1 @outer5(i32 %a) {
69 %C = call i1 @inner5(i32 0, i32 %a)
73 ; CHECK: Analyzing call of inner5
74 ; CHECK: NumInstructionsSimplified: 4
75 ; CHECK: NumInstructions: 5
76 define 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
82 isfalse: ; This block is unreachable once inlined
91 ret i1 %or.cond ; Simplifies to ret i1 true