summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHal Finkel <hfinkel@anl.gov>2015-01-08 22:11:49 +0000
committerHal Finkel <hfinkel@anl.gov>2015-01-08 22:11:49 +0000
commit3c0952b0723e1225270dd6229f3361bdf556cf9d (patch)
tree950d5e30c6555492bb7bc9cef123cdf7da2177a2
parent0709f5160f8b2bf0ab03ad8844ac1a9278b70312 (diff)
downloadbcm5719-llvm-3c0952b0723e1225270dd6229f3361bdf556cf9d.tar.gz
bcm5719-llvm-3c0952b0723e1225270dd6229f3361bdf556cf9d.zip
[PowerPC] Mark all instructions as non-cheap for MachineLICM
MachineLICM uses a callback named hasLowDefLatency to determine if an instruction def operand has a 'low' latency. If all relevant operands have a 'low' latency, the instruction is considered too cheap to hoist out of loops even in low-register-pressure situations. On PowerPC cores, both the embedded cores and the others, there is no reason to believe that this is a good choice: all instructions have a cost inside a loop, and hoisting them when not limited by register pressure is a reasonable default. llvm-svn: 225471
-rw-r--r--llvm/lib/Target/PowerPC/PPCInstrInfo.h9
-rw-r--r--llvm/test/CodeGen/PowerPC/addi-licm.ll55
2 files changed, 64 insertions, 0 deletions
diff --git a/llvm/lib/Target/PowerPC/PPCInstrInfo.h b/llvm/lib/Target/PowerPC/PPCInstrInfo.h
index 4d310fee47b..4add6f9781e 100644
--- a/llvm/lib/Target/PowerPC/PPCInstrInfo.h
+++ b/llvm/lib/Target/PowerPC/PPCInstrInfo.h
@@ -106,6 +106,15 @@ public:
UseNode, UseIdx);
}
+ bool hasLowDefLatency(const InstrItineraryData *ItinData,
+ const MachineInstr *DefMI,
+ unsigned DefIdx) const override {
+ // Machine LICM should hoist all instructions in low-register-pressure
+ // situations; none are sufficiently free to justify leaving in a loop
+ // body.
+ return false;
+ }
+
bool isCoalescableExtInstr(const MachineInstr &MI,
unsigned &SrcReg, unsigned &DstReg,
unsigned &SubIdx) const override;
diff --git a/llvm/test/CodeGen/PowerPC/addi-licm.ll b/llvm/test/CodeGen/PowerPC/addi-licm.ll
new file mode 100644
index 00000000000..b52cb678a96
--- /dev/null
+++ b/llvm/test/CodeGen/PowerPC/addi-licm.ll
@@ -0,0 +1,55 @@
+; RUN: llc -mcpu=pwr7 < %s | FileCheck %s
+target datalayout = "E-m:e-i64:64-n32:64"
+target triple = "powerpc64-unknown-linux-gnu"
+
+; Function Attrs: nounwind
+define double @foo() #1 {
+entry:
+ %x = alloca [2048 x float], align 4
+ %y = alloca [2048 x float], align 4
+ %0 = bitcast [2048 x float]* %x to i8*
+ call void @llvm.lifetime.start(i64 8192, i8* %0) #2
+ %1 = bitcast [2048 x float]* %y to i8*
+ call void @llvm.lifetime.start(i64 8192, i8* %1) #2
+ br label %for.body.i
+
+; CHECK-LABEL: @foo
+; CHECK: addi [[REG1:[0-9]+]], 1,
+; CHECK: addi [[REG2:[0-9]+]], 1,
+; CHECK: %for.body.i
+; CHECK-DAG: lfsx {{[0-9]+}}, [[REG1]],
+; CHECK-DAG: lfsx {{[0-9]+}}, [[REG2]],
+; CHECK: blr
+
+for.body.i: ; preds = %for.body.i.preheader, %for.body.i
+ %accumulator.09.i = phi double [ %add.i, %for.body.i ], [ 0.000000e+00, %entry ]
+ %i.08.i = phi i64 [ %inc.i, %for.body.i ], [ 0, %entry ]
+ %arrayidx.i = getelementptr inbounds [2048 x float]* %x, i64 0, i64 %i.08.i
+ %v14 = load float* %arrayidx.i, align 4
+ %conv.i = fpext float %v14 to double
+ %arrayidx1.i = getelementptr inbounds [2048 x float]* %y, i64 0, i64 %i.08.i
+ %v15 = load float* %arrayidx1.i, align 4
+ %conv2.i = fpext float %v15 to double
+ %mul.i = fmul double %conv.i, %conv2.i
+ %add.i = fadd double %accumulator.09.i, %mul.i
+ %inc.i = add nuw nsw i64 %i.08.i, 1
+ %exitcond.i = icmp eq i64 %i.08.i, 2047
+ br i1 %exitcond.i, label %loop.exit, label %for.body.i
+
+loop.exit: ; preds = %for.body.i
+ ret double %accumulator.09.i
+}
+
+; Function Attrs: nounwind
+declare void @llvm.lifetime.start(i64, i8* nocapture) #2
+
+declare void @bar(float*, float*)
+
+; Function Attrs: nounwind
+declare void @llvm.lifetime.end(i64, i8* nocapture) #2
+
+attributes #0 = { nounwind readonly }
+attributes #1 = { nounwind }
+attributes #2 = { nounwind }
+
+
OpenPOWER on IntegriCloud