]> granicus.if.org Git - llvm/commitdiff
[AMDGPU] Run always inliner early in opt
authorStanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com>
Thu, 16 Mar 2017 16:11:46 +0000 (16:11 +0000)
committerStanislav Mekhanoshin <Stanislav.Mekhanoshin@amd.com>
Thu, 16 Mar 2017 16:11:46 +0000 (16:11 +0000)
We can mark functions to always inline early in the opt. Since we do not have
call support this early inlining creates opportunities for inter-procedural
optimizations which would not occur otherwise.

Differential Revision: https://reviews.llvm.org/D31016

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@297958 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Target/AMDGPU/AMDGPUTargetMachine.cpp
test/CodeGen/AMDGPU/early-inline.ll [new file with mode: 0644]

index 5e633a3ca376ff0ce40023a88bbb067ae499ea99..f5973c174985b29c67b30f1e4ff1feaca4daa294 100644 (file)
@@ -244,6 +244,7 @@ void AMDGPUTargetMachine::adjustPassManager(PassManagerBuilder &Builder) {
         }));
         PM.add(createGlobalDCEPass());
       }
+      PM.add(createAMDGPUAlwaysInlinePass());
   });
 }
 
diff --git a/test/CodeGen/AMDGPU/early-inline.ll b/test/CodeGen/AMDGPU/early-inline.ll
new file mode 100644 (file)
index 0000000..dd526da
--- /dev/null
@@ -0,0 +1,21 @@
+; RUN: opt -mtriple=amdgcn-- -O1 -S -inline-threshold=1 %s | FileCheck %s
+
+define i32 @callee(i32 %x) {
+entry:
+  %mul1 = mul i32 %x, %x
+  %mul2 = mul i32 %mul1, %x
+  %mul3 = mul i32 %mul1, %mul2
+  %mul4 = mul i32 %mul3, %mul2
+  %mul5 = mul i32 %mul4, %mul3
+  ret i32 %mul5
+}
+
+; CHECK-LABEL: @caller
+; CHECK: mul i32
+; CHECK-NOT: call i32
+
+define i32 @caller(i32 %x) {
+entry:
+  %res = call i32 @callee(i32 %x)
+  ret i32 %res
+}