diff options
| author | Haicheng Wu <haicheng@codeaurora.org> | 2017-01-20 18:51:22 +0000 |
|---|---|---|
| committer | Haicheng Wu <haicheng@codeaurora.org> | 2017-01-20 18:51:22 +0000 |
| commit | 201b191b82858d2055e92ca8289082ce44ee8bb0 (patch) | |
| tree | ec58fa3ce422b940a34cc6bd5e26a8873292255e /llvm/test/Transforms | |
| parent | 91fb1f4be78425f6a15a364ff9552ddc7edc1627 (diff) | |
| download | bcm5719-llvm-201b191b82858d2055e92ca8289082ce44ee8bb0.tar.gz bcm5719-llvm-201b191b82858d2055e92ca8289082ce44ee8bb0.zip | |
Recommit "[InlineCost] Use TTI to check if GEP is free." #3
This is the third attemp to recommit r292526.
The original summary:
Currently, a GEP is considered free only if its indices are all constant.
TTI::getGEPCost() can give target-specific more accurate analysis. TTI is
already used for the cost of many other instructions.
llvm-svn: 292633
Diffstat (limited to 'llvm/test/Transforms')
| -rw-r--r-- | llvm/test/Transforms/Inline/AArch64/gep-cost.ll | 30 | ||||
| -rw-r--r-- | llvm/test/Transforms/Inline/AArch64/lit.local.cfg | 2 |
2 files changed, 32 insertions, 0 deletions
diff --git a/llvm/test/Transforms/Inline/AArch64/gep-cost.ll b/llvm/test/Transforms/Inline/AArch64/gep-cost.ll new file mode 100644 index 00000000000..204958f082d --- /dev/null +++ b/llvm/test/Transforms/Inline/AArch64/gep-cost.ll @@ -0,0 +1,30 @@ +; REQUIRES: asserts +; RUN: opt -inline -mtriple=aarch64--linux-gnu -mcpu=kryo -S -debug-only=inline-cost < %s 2>&1 | FileCheck %s + +target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128" +target triple = "aarch64--linux-gnu" + +define void @outer([4 x i32]* %ptr, i32 %i) { + call void @inner1([4 x i32]* %ptr, i32 %i) + call void @inner2([4 x i32]* %ptr, i32 %i) + ret void +} +; The gep in inner1() is reg+reg, which is a legal addressing mode for AArch64. +; Thus, both the gep and ret can be simplified. +; CHECK: Analyzing call of inner1 +; CHECK: NumInstructionsSimplified: 2 +; CHECK: NumInstructions: 2 +define void @inner1([4 x i32]* %ptr, i32 %i) { + %G = getelementptr inbounds [4 x i32], [4 x i32]* %ptr, i32 0, i32 %i + ret void +} + +; The gep in inner2() is reg+imm+reg, which is not a legal addressing mode for +; AArch64. Thus, only the ret can be simplified and not the gep. +; CHECK: Analyzing call of inner2 +; CHECK: NumInstructionsSimplified: 1 +; CHECK: NumInstructions: 2 +define void @inner2([4 x i32]* %ptr, i32 %i) { + %G = getelementptr inbounds [4 x i32], [4 x i32]* %ptr, i32 1, i32 %i + ret void +} diff --git a/llvm/test/Transforms/Inline/AArch64/lit.local.cfg b/llvm/test/Transforms/Inline/AArch64/lit.local.cfg new file mode 100644 index 00000000000..7184443994b --- /dev/null +++ b/llvm/test/Transforms/Inline/AArch64/lit.local.cfg @@ -0,0 +1,2 @@ +if not 'AArch64' in config.root.targets: + config.unsupported = True |

