From 1537930ea1c4e172fea6fa0767f1337860f82bd5 Mon Sep 17 00:00:00 2001 From: Stanislav Mekhanoshin Date: Thu, 16 Mar 2017 16:11:46 +0000 Subject: [PATCH] [AMDGPU] Run always inliner early in opt 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 | 1 + test/CodeGen/AMDGPU/early-inline.ll | 21 +++++++++++++++++++++ 2 files changed, 22 insertions(+) create mode 100644 test/CodeGen/AMDGPU/early-inline.ll diff --git a/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp b/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp index 5e633a3ca37..f5973c17498 100644 --- a/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp +++ b/lib/Target/AMDGPU/AMDGPUTargetMachine.cpp @@ -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 index 00000000000..dd526da354e --- /dev/null +++ b/test/CodeGen/AMDGPU/early-inline.ll @@ -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 +} -- 2.50.1