summaryrefslogtreecommitdiff
path: root/test/CodeGen
diff options
context:
space:
mode:
authorAkira Hatanaka <ahatanaka@mips.com>2013-11-27 23:38:42 +0000
committerAkira Hatanaka <ahatanaka@mips.com>2013-11-27 23:38:42 +0000
commitbd448674777fc0c88c8503015d5c74615ccc66ea (patch)
tree688088a1c5b9d7915c0f0c306a1af12684060829 /test/CodeGen
parentd99338105b607f0d0b33144515ad34c90da1d21c (diff)
downloadllvm-bd448674777fc0c88c8503015d5c74615ccc66ea.tar.gz
llvm-bd448674777fc0c88c8503015d5c74615ccc66ea.tar.bz2
llvm-bd448674777fc0c88c8503015d5c74615ccc66ea.tar.xz
[mips] Implement the following optimizations using dominance information to
make PIC calls a little more efficient: 1. Remove instructions setting up $gp if it is known that a function has been called at least once. 2. Save the address of a called function in a register instead of loading it from the GOT at every call site. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@195892 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen')
-rw-r--r--test/CodeGen/Mips/call-optimization.ll83
1 files changed, 83 insertions, 0 deletions
diff --git a/test/CodeGen/Mips/call-optimization.ll b/test/CodeGen/Mips/call-optimization.ll
new file mode 100644
index 0000000000..b147f58e45
--- /dev/null
+++ b/test/CodeGen/Mips/call-optimization.ll
@@ -0,0 +1,83 @@
+; RUN: llc -march=mipsel -disable-mips-delay-filler < %s | \
+; RUN: FileCheck %s -check-prefix=O32
+; RUN: llc -march=mipsel -mips-load-target-from-got=false \
+; RUN: -disable-mips-delay-filler < %s | FileCheck %s -check-prefix=O32-LOADTGT
+
+@gd1 = common global double 0.000000e+00, align 8
+@gd2 = common global double 0.000000e+00, align 8
+
+; O32-LABEL: caller3:
+; O32-DAG: lw $25, %call16(callee3)
+; O32-DAG: move $gp
+; O32: jalr $25
+; O32-DAG: lw $25, %call16(callee3)
+; O32-NOT: move $gp
+; O32: jalr $25
+; O32-DAG: lw $25, %call16(callee3)
+; O32-NOT: move $gp
+; O32: jalr $25
+
+; O32-LOADTGT-LABEL: caller3:
+; O32-LOADTGT-DAG: lw $25, %call16(callee3)
+; O32-LOADTGT-DAG: move $gp
+; O32-LOADTGT: jalr $25
+; O32-LOADTGT-DAG: move $25
+; O32-LOADTGT-NOT: move $gp
+; O32-LOADTGT: jalr $25
+; O32-LOADTGT-DAG: move $25
+; O32-LOADTGT-NOT: move $gp
+; O32-LOADTGT: jalr $25
+
+define void @caller3(i32 %n) {
+entry:
+ tail call void @callee3()
+ tail call void @callee3()
+ %tobool1 = icmp eq i32 %n, 0
+ br i1 %tobool1, label %while.end, label %while.body
+
+while.body:
+ %n.addr.02 = phi i32 [ %dec, %while.body ], [ %n, %entry ]
+ %dec = add nsw i32 %n.addr.02, -1
+ tail call void @callee3()
+ %tobool = icmp eq i32 %dec, 0
+ br i1 %tobool, label %while.end, label %while.body
+
+while.end:
+ ret void
+}
+
+declare void @callee3()
+
+; O32-LABEL: caller4:
+; O32-DAG: lw $25, %call16(ceil)
+; O32-DAG: move $gp
+; O32: jalr $25
+; O32-DAG: lw $25, %call16(ceil)
+; O32-NOT: move $gp
+; O32: jalr $25
+; O32-DAG: lw $25, %call16(ceil)
+; O32-NOT: move $gp
+; O32: jalr $25
+
+; O32-LOADTGT-LABEL: caller4:
+; O32-LOADTGT-DAG: lw $25, %call16(ceil)
+; O32-LOADTGT-DAG: move $gp
+; O32-LOADTGT: jalr $25
+; O32-LOADTGT-DAG: move $25
+; O32-LOADTGT-NOT: move $gp
+; O32-LOADTGT: jalr $25
+; O32-LOADTGT-DAG: move $25
+; O32-LOADTGT-NOT: move $gp
+; O32-LOADTGT: jalr $25
+
+define void @caller4(double %d) {
+entry:
+ %call = tail call double @ceil(double %d)
+ %call1 = tail call double @ceil(double %call)
+ store double %call1, double* @gd2, align 8
+ %call2 = tail call double @ceil(double %call1)
+ store double %call2, double* @gd1, align 8
+ ret void
+}
+
+declare double @ceil(double)