2021-04-23 18:30:28 +02:00
|
|
|
; RUN: opt -S -inline %s -debug-only=inline-cost 2>&1 | FileCheck %s
|
2021-04-24 00:22:35 +02:00
|
|
|
; REQUIRES: asserts
|
2021-04-23 18:30:28 +02:00
|
|
|
; Only the load and ret should be included in the instruction count, not
|
|
|
|
; the instructions feeding the assume.
|
|
|
|
; CHECK: NumInstructions: 2
|
2019-04-17 06:52:47 +02:00
|
|
|
|
|
|
|
@a = global i32 4
|
|
|
|
|
2021-04-23 18:30:28 +02:00
|
|
|
define i32 @inner(i8* %y) {
|
2019-04-17 06:52:47 +02:00
|
|
|
%a1 = load volatile i32, i32* @a
|
|
|
|
|
2021-04-23 18:30:28 +02:00
|
|
|
; Because these instructions are used only by the @llvm.assume intrinsic,
|
|
|
|
; they're free and should not be included in the instruction count when
|
|
|
|
; computing the inline cost.
|
2019-04-17 06:52:47 +02:00
|
|
|
%a2 = mul i32 %a1, %a1
|
2021-04-23 18:30:28 +02:00
|
|
|
%a3 = sub i32 %a1, %a2
|
2019-04-17 06:52:47 +02:00
|
|
|
%a4 = udiv i32 %a3, -13
|
|
|
|
%a5 = mul i32 %a4, %a4
|
|
|
|
%a6 = add i32 %a5, %a5
|
|
|
|
%ca = icmp sgt i32 %a6, -7
|
2021-04-23 18:30:28 +02:00
|
|
|
%r = call i1 @llvm.type.test(i8* %y, metadata !0)
|
|
|
|
%ca2 = icmp eq i1 %ca, %r
|
|
|
|
tail call void @llvm.assume(i1 %ca2)
|
2019-04-17 06:52:47 +02:00
|
|
|
|
|
|
|
ret i32 %a1
|
|
|
|
}
|
|
|
|
|
2021-04-23 18:30:28 +02:00
|
|
|
define i32 @outer(i8* %y) optsize {
|
|
|
|
%r = call i32 @inner(i8* %y)
|
2019-04-17 06:52:47 +02:00
|
|
|
ret i32 %r
|
|
|
|
}
|
|
|
|
|
|
|
|
declare void @llvm.assume(i1) nounwind
|
2021-04-23 18:30:28 +02:00
|
|
|
declare i1 @llvm.type.test(i8*, metadata) nounwind readnone
|
2019-04-17 06:52:47 +02:00
|
|
|
|
2021-04-23 18:30:28 +02:00
|
|
|
!0 = !{i32 0, !"typeid1"}
|