aboutsummaryrefslogtreecommitdiff
path: root/test/Transforms/Inline
diff options
context:
space:
mode:
authorChandler Carruth <chandlerc@gmail.com>2012-03-12 11:19:33 +0000
committerChandler Carruth <chandlerc@gmail.com>2012-03-12 11:19:33 +0000
commit6c0b3ac8ea51d35bbd2565f17f1a73c3bfcb5cdf (patch)
treec2b037cd4eee85dfebfa559534cd769940752560 /test/Transforms/Inline
parentfc72ae613afd7ca2526bb66156bafe8b0054cb3b (diff)
When inlining a function and adding its inner call sites to the
candidate set for subsequent inlining, try to simplify the arguments to the inner call site now that inlining has been performed. The goal here is to propagate and fold constants through deeply nested call chains. Without doing this, we loose the inliner bonus that should be applied because the arguments don't match the exact pattern the cost estimator uses. Reviewed on IRC by Benjamin Kramer. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@152556 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/Inline')
-rw-r--r--test/Transforms/Inline/inline_constprop.ll75
1 files changed, 75 insertions, 0 deletions
diff --git a/test/Transforms/Inline/inline_constprop.ll b/test/Transforms/Inline/inline_constprop.ll
index 18edf15ab4..cc7aaac2b3 100644
--- a/test/Transforms/Inline/inline_constprop.ll
+++ b/test/Transforms/Inline/inline_constprop.ll
@@ -12,3 +12,78 @@ define i32 @caller1() {
%X = call i32 @callee1( i32 10, i32 3 )
ret i32 %X
}
+
+define i32 @caller2() {
+; CHECK: @caller2
+; CHECK-NOT: call void @callee2
+; CHECK: ret
+
+; We contrive to make this hard for *just* the inline pass to do in order to
+; simulate what can actually happen with large, complex functions getting
+; inlined.
+ %a = add i32 42, 0
+ %b = add i32 48, 0
+
+ %x = call i32 @callee21(i32 %a, i32 %b)
+ ret i32 %x
+}
+
+define i32 @callee21(i32 %x, i32 %y) {
+ %sub = sub i32 %y, %x
+ %result = call i32 @callee22(i32 %sub)
+ ret i32 %result
+}
+
+declare i8* @getptr()
+
+define i32 @callee22(i32 %x) {
+ %icmp = icmp ugt i32 %x, 42
+ br i1 %icmp, label %bb.true, label %bb.false
+bb.true:
+ ; This block musn't be counted in the inline cost.
+ %ptr = call i8* @getptr()
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+ load volatile i8* %ptr
+
+ ret i32 %x
+bb.false:
+ ret i32 %x
+}