[llvm] r366775 - [PowerPC] Replace float load/store pair with integer load/store pair when it's only used in load/store
Zi Xuan Wu via llvm-commits
llvm-commits at lists.llvm.org
Mon Jul 22 20:34:40 PDT 2019
Author: wuzish
Date: Mon Jul 22 20:34:40 2019
New Revision: 366775
URL: http://llvm.org/viewvc/llvm-project?rev=366775&view=rev
Log:
[PowerPC] Replace float load/store pair with integer load/store pair when it's only used in load/store
Replace float load/store pair with integer load/store pair when it's only used in load/store,
because float load/store instructions cost more cycles then integer load/store.
A typical scenario is when there is a call with more than 13 float arguments passing, we need pass them by stack.
So we need a load/store pair to do such memory operation if the variable is global variable.
Differential Revision: https://reviews.llvm.org/D64195
Modified:
llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h
llvm/trunk/test/CodeGen/PowerPC/float-load-store-pair.ll
llvm/trunk/test/CodeGen/PowerPC/ppc64-smallarg.ll
llvm/trunk/test/CodeGen/PowerPC/ppc64le-smallarg.ll
llvm/trunk/test/CodeGen/PowerPC/pwr7-gt-nop.ll
Modified: llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h?rev=366775&r1=366774&r2=366775&view=diff
==============================================================================
--- llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h (original)
+++ llvm/trunk/lib/Target/PowerPC/PPCISelLowering.h Mon Jul 22 20:34:40 2019
@@ -834,6 +834,18 @@ namespace llvm {
return true;
}
+ bool isDesirableToTransformToIntegerOp(unsigned Opc,
+ EVT VT) const override {
+ // Only handle float load/store pair because float(fpr) load/store
+ // instruction has more cycles than integer(gpr) load/store in PPC.
+ if (Opc != ISD::LOAD && Opc != ISD::STORE)
+ return false;
+ if (VT != MVT::f32 && VT != MVT::f64)
+ return false;
+
+ return true;
+ }
+
// Returns true if the address of the global is stored in TOC entry.
bool isAccessedAsGotIndirect(SDValue N) const;
Modified: llvm/trunk/test/CodeGen/PowerPC/float-load-store-pair.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/float-load-store-pair.ll?rev=366775&r1=366774&r2=366775&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/PowerPC/float-load-store-pair.ll (original)
+++ llvm/trunk/test/CodeGen/PowerPC/float-load-store-pair.ll Mon Jul 22 20:34:40 2019
@@ -54,27 +54,27 @@ define signext i32 @test() {
; CHECK-NEXT: addis 3, 2, a10 at toc@ha
; CHECK-NEXT: lfd 10, a10 at toc@l(3)
; CHECK-NEXT: addis 3, 2, a11 at toc@ha
+; CHECK-NEXT: addis 6, 2, a17 at toc@ha
+; CHECK-NEXT: addis 5, 2, a16 at toc@ha
+; CHECK-NEXT: addi 6, 6, a17 at toc@l
+; CHECK-NEXT: addi 5, 5, a16 at toc@l
+; CHECK-NEXT: lxvx 34, 0, 6
+; CHECK-NEXT: addis 4, 2, a15 at toc@ha
+; CHECK-NEXT: lxvx 0, 0, 5
+; CHECK-NEXT: ld 4, a15 at toc@l(4)
+; CHECK-NEXT: li 5, 168
; CHECK-NEXT: lfd 11, a11 at toc@l(3)
; CHECK-NEXT: addis 3, 2, a12 at toc@ha
; CHECK-NEXT: lfd 12, a12 at toc@l(3)
; CHECK-NEXT: addis 3, 2, a13 at toc@ha
; CHECK-NEXT: lfd 13, a13 at toc@l(3)
; CHECK-NEXT: addis 3, 2, a14 at toc@ha
-; CHECK-NEXT: lfd 0, a14 at toc@l(3)
-; CHECK-NEXT: addis 3, 2, a15 at toc@ha
-; CHECK-NEXT: addis 4, 2, a17 at toc@ha
-; CHECK-NEXT: addi 4, 4, a17 at toc@l
-; CHECK-NEXT: lxsd 2, a15 at toc@l(3)
-; CHECK-NEXT: addis 3, 2, a16 at toc@ha
-; CHECK-NEXT: addi 3, 3, a16 at toc@l
-; CHECK-NEXT: lxvx 36, 0, 4
-; CHECK-NEXT: lxvx 35, 0, 3
-; CHECK-NEXT: li 3, 168
-; CHECK-NEXT: stxvx 36, 1, 3
-; CHECK-NEXT: li 3, 152
-; CHECK-NEXT: stxvx 35, 1, 3
-; CHECK-NEXT: stxsd 2, 144(1)
-; CHECK-NEXT: stfd 0, 136(1)
+; CHECK-NEXT: ld 3, a14 at toc@l(3)
+; CHECK-NEXT: stxvx 34, 1, 5
+; CHECK-NEXT: li 5, 152
+; CHECK-NEXT: stxvx 0, 1, 5
+; CHECK-NEXT: std 4, 144(1)
+; CHECK-NEXT: std 3, 136(1)
; CHECK-NEXT: bl _Z3fooddddddddddddddd
; CHECK-NEXT: nop
; CHECK-NEXT: li 3, 0
Modified: llvm/trunk/test/CodeGen/PowerPC/ppc64-smallarg.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/ppc64-smallarg.ll?rev=366775&r1=366774&r2=366775&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/PowerPC/ppc64-smallarg.ll (original)
+++ llvm/trunk/test/CodeGen/PowerPC/ppc64-smallarg.ll Mon Jul 22 20:34:40 2019
@@ -52,7 +52,7 @@ entry:
ret void
}
; CHECK: @caller2
-; CHECK: stfs {{[0-9]+}}, 156(1)
+; CHECK: std {{[0-9]+}}, 16(1)
; CHECK: bl test2
declare float @test2(float, float, float, float, float, float, float, float, float, float, float, float, float, float)
Modified: llvm/trunk/test/CodeGen/PowerPC/ppc64le-smallarg.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/ppc64le-smallarg.ll?rev=366775&r1=366774&r2=366775&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/PowerPC/ppc64le-smallarg.ll (original)
+++ llvm/trunk/test/CodeGen/PowerPC/ppc64le-smallarg.ll Mon Jul 22 20:34:40 2019
@@ -52,7 +52,7 @@ entry:
ret void
}
; CHECK: @caller2
-; CHECK: stfs {{[0-9]+}}, 136({{[0-9]+}})
+; CHECK: std {{[0-9]+}}, 16({{[0-9]+}})
; CHECK: bl test2
declare float @test2(float, float, float, float, float, float, float, float, float, float, float, float, float, float)
Modified: llvm/trunk/test/CodeGen/PowerPC/pwr7-gt-nop.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/PowerPC/pwr7-gt-nop.ll?rev=366775&r1=366774&r2=366775&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/PowerPC/pwr7-gt-nop.ll (original)
+++ llvm/trunk/test/CodeGen/PowerPC/pwr7-gt-nop.ll Mon Jul 22 20:34:40 2019
@@ -16,12 +16,12 @@ entry:
store float %2, float* %d, align 4
ret void
-; CHECK: lfs [[REG1:[0-9]+]], 0(4)
-; CHECK: stfs [[REG1]], 0(3)
-; CHECK: lfs [[REG2:[0-9]+]], 0(5)
-; CHECK: stfs [[REG2]], 0(4)
-; CHECK: lfs [[REG3:[0-9]+]], 0(3)
-; CHECK: stfs [[REG3]], 0(6)
+; CHECK: lwz [[REG1:[0-9]+]], 0(4)
+; CHECK: stw [[REG1]], 0(3)
+; CHECK: lwz [[REG2:[0-9]+]], 0(5)
+; CHECK: stw [[REG2]], 0(4)
+; CHECK: lwz [[REG3:[0-9]+]], 0(3)
+; CHECK: stw [[REG3]], 0(6)
; CHECK: blr
}
More information about the llvm-commits
mailing list