Skip to content

Commit 57d17ec

Browse files
committed
[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 llvm-svn: 366775
1 parent 3a52c38 commit 57d17ec

File tree

5 files changed

+35
-23
lines changed

5 files changed

+35
-23
lines changed

llvm/lib/Target/PowerPC/PPCISelLowering.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -834,6 +834,18 @@ namespace llvm {
834834
return true;
835835
}
836836

837+
bool isDesirableToTransformToIntegerOp(unsigned Opc,
838+
EVT VT) const override {
839+
// Only handle float load/store pair because float(fpr) load/store
840+
// instruction has more cycles than integer(gpr) load/store in PPC.
841+
if (Opc != ISD::LOAD && Opc != ISD::STORE)
842+
return false;
843+
if (VT != MVT::f32 && VT != MVT::f64)
844+
return false;
845+
846+
return true;
847+
}
848+
837849
// Returns true if the address of the global is stored in TOC entry.
838850
bool isAccessedAsGotIndirect(SDValue N) const;
839851

llvm/test/CodeGen/PowerPC/float-load-store-pair.ll

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,27 +54,27 @@ define signext i32 @test() {
5454
; CHECK-NEXT: addis 3, 2, a10@toc@ha
5555
; CHECK-NEXT: lfd 10, a10@toc@l(3)
5656
; CHECK-NEXT: addis 3, 2, a11@toc@ha
57+
; CHECK-NEXT: addis 6, 2, a17@toc@ha
58+
; CHECK-NEXT: addis 5, 2, a16@toc@ha
59+
; CHECK-NEXT: addi 6, 6, a17@toc@l
60+
; CHECK-NEXT: addi 5, 5, a16@toc@l
61+
; CHECK-NEXT: lxvx 34, 0, 6
62+
; CHECK-NEXT: addis 4, 2, a15@toc@ha
63+
; CHECK-NEXT: lxvx 0, 0, 5
64+
; CHECK-NEXT: ld 4, a15@toc@l(4)
65+
; CHECK-NEXT: li 5, 168
5766
; CHECK-NEXT: lfd 11, a11@toc@l(3)
5867
; CHECK-NEXT: addis 3, 2, a12@toc@ha
5968
; CHECK-NEXT: lfd 12, a12@toc@l(3)
6069
; CHECK-NEXT: addis 3, 2, a13@toc@ha
6170
; CHECK-NEXT: lfd 13, a13@toc@l(3)
6271
; CHECK-NEXT: addis 3, 2, a14@toc@ha
63-
; CHECK-NEXT: lfd 0, a14@toc@l(3)
64-
; CHECK-NEXT: addis 3, 2, a15@toc@ha
65-
; CHECK-NEXT: addis 4, 2, a17@toc@ha
66-
; CHECK-NEXT: addi 4, 4, a17@toc@l
67-
; CHECK-NEXT: lxsd 2, a15@toc@l(3)
68-
; CHECK-NEXT: addis 3, 2, a16@toc@ha
69-
; CHECK-NEXT: addi 3, 3, a16@toc@l
70-
; CHECK-NEXT: lxvx 36, 0, 4
71-
; CHECK-NEXT: lxvx 35, 0, 3
72-
; CHECK-NEXT: li 3, 168
73-
; CHECK-NEXT: stxvx 36, 1, 3
74-
; CHECK-NEXT: li 3, 152
75-
; CHECK-NEXT: stxvx 35, 1, 3
76-
; CHECK-NEXT: stxsd 2, 144(1)
77-
; CHECK-NEXT: stfd 0, 136(1)
72+
; CHECK-NEXT: ld 3, a14@toc@l(3)
73+
; CHECK-NEXT: stxvx 34, 1, 5
74+
; CHECK-NEXT: li 5, 152
75+
; CHECK-NEXT: stxvx 0, 1, 5
76+
; CHECK-NEXT: std 4, 144(1)
77+
; CHECK-NEXT: std 3, 136(1)
7878
; CHECK-NEXT: bl _Z3fooddddddddddddddd
7979
; CHECK-NEXT: nop
8080
; CHECK-NEXT: li 3, 0

llvm/test/CodeGen/PowerPC/ppc64-smallarg.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ entry:
5252
ret void
5353
}
5454
; CHECK: @caller2
55-
; CHECK: stfs {{[0-9]+}}, 156(1)
55+
; CHECK: std {{[0-9]+}}, 16(1)
5656
; CHECK: bl test2
5757

5858
declare float @test2(float, float, float, float, float, float, float, float, float, float, float, float, float, float)

llvm/test/CodeGen/PowerPC/ppc64le-smallarg.ll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ entry:
5252
ret void
5353
}
5454
; CHECK: @caller2
55-
; CHECK: stfs {{[0-9]+}}, 136({{[0-9]+}})
55+
; CHECK: std {{[0-9]+}}, 16({{[0-9]+}})
5656
; CHECK: bl test2
5757

5858
declare float @test2(float, float, float, float, float, float, float, float, float, float, float, float, float, float)

llvm/test/CodeGen/PowerPC/pwr7-gt-nop.ll

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,12 +16,12 @@ entry:
1616
store float %2, float* %d, align 4
1717
ret void
1818

19-
; CHECK: lfs [[REG1:[0-9]+]], 0(4)
20-
; CHECK: stfs [[REG1]], 0(3)
21-
; CHECK: lfs [[REG2:[0-9]+]], 0(5)
22-
; CHECK: stfs [[REG2]], 0(4)
23-
; CHECK: lfs [[REG3:[0-9]+]], 0(3)
24-
; CHECK: stfs [[REG3]], 0(6)
19+
; CHECK: lwz [[REG1:[0-9]+]], 0(4)
20+
; CHECK: stw [[REG1]], 0(3)
21+
; CHECK: lwz [[REG2:[0-9]+]], 0(5)
22+
; CHECK: stw [[REG2]], 0(4)
23+
; CHECK: lwz [[REG3:[0-9]+]], 0(3)
24+
; CHECK: stw [[REG3]], 0(6)
2525
; CHECK: blr
2626
}
2727

0 commit comments

Comments
 (0)