95 lines · plain
1; REQUIRES: asserts2; RUN: opt -passes=inline -mtriple=aarch64--linux-gnu -S -debug-only=inline-cost < %s 2>&1 | FileCheck %s3 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, but8; 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 %C13}14 15; CHECK: Analyzing call of inner116; CHECK: NumInstructionsSimplified: 317; CHECK: NumInstructions: 418define i1 @inner1(i32 %a, i32 %b) {19 %tobool = icmp eq i32 %a, 0 ; Simplifies to true20 %tobool1 = icmp eq i32 %b, 0 ; Should be dead once 'or' is simplified21 %or.cond = or i1 %tobool, %tobool1 ; Simplifies to true22 ret i1 %or.cond ; Simplifies to ret i1 true23}24 25define i1 @outer2(i32 %a) {26 %C = call i1 @inner2(i32 1, i32 %a)27 ret i1 %C28}29 30; CHECK: Analyzing call of inner231; CHECK: NumInstructionsSimplified: 332; CHECK: NumInstructions: 433define i1 @inner2(i32 %a, i32 %b) {34 %tobool = icmp eq i32 %a, 0 ; Simplifies to false35 %tobool1 = icmp eq i32 %b, 0 ; Should be dead once 'and' is simplified36 %and.cond = and i1 %tobool, %tobool1 ; Simplifies to false37 ret i1 %and.cond ; Simplifies to ret i1 false38}39 40 41define i32 @outer3(i32 %a) {42 %C = call i32 @inner3(i32 4294967295, i32 %a)43 ret i32 %C44}45 46; CHECK: Analyzing call of inner347; CHECK: NumInstructionsSimplified: 248; CHECK: NumInstructions: 249define i32 @inner3(i32 %a, i32 %b) {50 %or.cond = or i32 %a, %b ; Simplifies to 429496729551 ret i32 %or.cond ; Simplifies to ret i32 429496729552}53 54 55define i32 @outer4(i32 %a) {56 %C = call i32 @inner4(i32 0, i32 %a)57 ret i32 %C58}59 60; CHECK: Analyzing call of inner461; CHECK: NumInstructionsSimplified: 262; CHECK: NumInstructions: 263define i32 @inner4(i32 %a, i32 %b) {64 %and.cond = and i32 %a, %b ; Simplifies to 065 ret i32 %and.cond ; Simplifies to ret i32 066}67 68define i1 @outer5(i32 %a) {69 %C = call i1 @inner5(i32 0, i32 %a)70 ret i1 %C71}72 73; CHECK: Analyzing call of inner574; CHECK: NumInstructionsSimplified: 475; CHECK: NumInstructions: 576define i1 @inner5(i32 %a, i32 %b) {77 %tobool = icmp eq i32 %a, 0 ; Simplifies to true78 %tobool1 = icmp eq i32 %b, 0 ; Should be dead once 'or' is simplified79 %or.cond = or i1 %tobool, %tobool1 ; Simplifies to true80 br i1 %or.cond, label %end, label %isfalse ; Simplifies to br label %end81 82isfalse: ; This block is unreachable once inlined83 call void @dead()84 call void @dead()85 call void @dead()86 call void @dead()87 call void @dead()88 br label %end89 90end:91 ret i1 %or.cond ; Simplifies to ret i1 true92}93 94declare void @dead()95