aboutsummaryrefslogtreecommitdiff
path: root/test/CodeGen
diff options
context:
space:
mode:
authorHal Finkel <hfinkel@anl.gov>2013-04-08 16:24:03 +0000
committerHal Finkel <hfinkel@anl.gov>2013-04-08 16:24:03 +0000
commit5ee67e8e76dfcaffa5e776ef3d5eeb80807a627b (patch)
tree5320cc3ba452b158e02aa6cd235be0fc66bcda8b /test/CodeGen
parentd6b89ef0fa17cf77677358a797934fa061564f5b (diff)
Generate PPC early conditional returns
PowerPC has a conditional branch to the link register (return) instruction: BCLR. This should be used any time when we'd otherwise have a conditional branch to a return. This adds a small pass, PPCEarlyReturn, which runs just prior to the branch selection pass (and, importantly, after block placement) to generate these conditional returns when possible. It will also eliminate unconditional branches to returns (these happen rarely; most of the time these have already been tail duplicated by the time PPCEarlyReturn is invoked). This is a nice optimization for small functions that do not maintain a stack frame. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@179026 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/CodeGen')
-rw-r--r--test/CodeGen/PowerPC/early-ret.ll52
-rw-r--r--test/CodeGen/PowerPC/rounding-ops.ll10
2 files changed, 58 insertions, 4 deletions
diff --git a/test/CodeGen/PowerPC/early-ret.ll b/test/CodeGen/PowerPC/early-ret.ll
new file mode 100644
index 0000000000..ac4fe05c91
--- /dev/null
+++ b/test/CodeGen/PowerPC/early-ret.ll
@@ -0,0 +1,52 @@
+; RUN: llc < %s -mtriple=powerpc64-unknown-linux-gnu -mcpu=pwr7 | FileCheck %s
+target datalayout = "E-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-f128:128:128-v128:128:128-n32:64"
+target triple = "powerpc64-unknown-linux-gnu"
+
+define void @foo(i32* %P) #0 {
+entry:
+ %tobool = icmp eq i32* %P, null
+ br i1 %tobool, label %if.end, label %if.then
+
+if.then: ; preds = %entry
+ store i32 0, i32* %P, align 4, !tbaa !0
+ br label %if.end
+
+if.end: ; preds = %entry, %if.then
+ ret void
+
+; CHECK: @foo
+; CHECK: beqlr
+; CHECK: blr
+}
+
+define void @bar(i32* %P, i32* %Q) #0 {
+entry:
+ %tobool = icmp eq i32* %P, null
+ br i1 %tobool, label %if.else, label %if.then
+
+if.then: ; preds = %entry
+ store i32 0, i32* %P, align 4, !tbaa !0
+ %tobool1 = icmp eq i32* %Q, null
+ br i1 %tobool1, label %if.end3, label %if.then2
+
+if.then2: ; preds = %if.then
+ store i32 1, i32* %Q, align 4, !tbaa !0
+ br label %if.end3
+
+if.else: ; preds = %entry
+ store i32 0, i32* %Q, align 4, !tbaa !0
+ br label %if.end3
+
+if.end3: ; preds = %if.then, %if.then2, %if.else
+ ret void
+
+; CHECK: @bar
+; CHECK: beqlr
+; CHECK: blr
+}
+
+attributes #0 = { nounwind }
+
+!0 = metadata !{metadata !"int", metadata !1}
+!1 = metadata !{metadata !"omnipotent char", metadata !2}
+!2 = metadata !{metadata !"Simple C/C++ TBAA"}
diff --git a/test/CodeGen/PowerPC/rounding-ops.ll b/test/CodeGen/PowerPC/rounding-ops.ll
index b210a6bda8..2b5e1c9a28 100644
--- a/test/CodeGen/PowerPC/rounding-ops.ll
+++ b/test/CodeGen/PowerPC/rounding-ops.ll
@@ -107,9 +107,10 @@ define double @test10(double %x) nounwind {
declare double @trunc(double) nounwind readnone
-define float @test11(float %x) nounwind {
+define void @test11(float %x, float* %y) nounwind {
%call = tail call float @rintf(float %x) nounwind readnone
- ret float %call
+ store float %call, float* %y
+ ret void
; CHECK: test11:
; CHECK-NOT: frin
@@ -125,9 +126,10 @@ define float @test11(float %x) nounwind {
declare float @rintf(float) nounwind readnone
-define double @test12(double %x) nounwind {
+define void @test12(double %x, double* %y) nounwind {
%call = tail call double @rint(double %x) nounwind readnone
- ret double %call
+ store double %call, double* %y
+ ret void
; CHECK: test12:
; CHECK-NOT: frin