Skip to content

Commit 9b04fec

Browse files
author
QingShan Zhang
committed
[PowerPC] Retrieve the offset from load/store if it stores to stack slots
Scheduler will try to retrieve the offset and base addr to determine if two loads/stores are disjoint memory access. PowerPC failed to handle this for frame index which will bring extra memory dependency for loads/stores. Reviewed By: jji Differential Revision: https://reviews.llvm.org/D84308
1 parent c06e22f commit 9b04fec

File tree

5 files changed

+29
-28
lines changed

5 files changed

+29
-28
lines changed

llvm/lib/Target/PowerPC/PPCInstrInfo.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4624,7 +4624,8 @@ bool PPCInstrInfo::getMemOperandWithOffsetWidth(
46244624
// Handle only loads/stores with base register followed by immediate offset.
46254625
if (LdSt.getNumExplicitOperands() != 3)
46264626
return false;
4627-
if (!LdSt.getOperand(1).isImm() || !LdSt.getOperand(2).isReg())
4627+
if (!LdSt.getOperand(1).isImm() ||
4628+
(!LdSt.getOperand(2).isReg() && !LdSt.getOperand(2).isFI()))
46284629
return false;
46294630

46304631
if (!LdSt.hasOneMemOperand())

llvm/test/CodeGen/PowerPC/aix-cc-byval-split.ll

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,18 +36,18 @@ entry:
3636
; CHECK32: bb.0.entry:
3737
; CHECK32-NEXT: liveins: $r3, $r4, $r5, $r6, $r7, $r8, $r9, $r10
3838

39+
; CHECK32: renamable $r[[REG1:[0-9]+]] = LWZ 84, %fixed-stack.0
3940
; CHECK32-DAG: STW killed renamable $r3, 0, %fixed-stack.0 :: (store 4 into %fixed-stack.0
4041
; CHECK32-DAG: STW killed renamable $r4, 4, %fixed-stack.0 :: (store 4 into %fixed-stack.0 + 4
42+
; CHECK32: renamable $r[[REG2:[0-9]+]] = LWZ 80, %fixed-stack.0
4143
; CHECK32-DAG: STW killed renamable $r5, 8, %fixed-stack.0 :: (store 4 into %fixed-stack.0 + 8
4244
; CHECK32-DAG: STW killed renamable $r6, 12, %fixed-stack.0 :: (store 4 into %fixed-stack.0 + 12
4345
; CHECK32-DAG: STW renamable $r7, 16, %fixed-stack.0 :: (store 4 into %fixed-stack.0 + 16
4446
; CHECK32-DAG: STW renamable $r8, 20, %fixed-stack.0 :: (store 4 into %fixed-stack.0 + 20
4547
; CHECK32-DAG: STW killed renamable $r9, 24, %fixed-stack.0 :: (store 4 into %fixed-stack.0 + 24
46-
; CHECK32-DAG: STW killed renamable $r10, 28, %fixed-stack.0 :: (store 4 into %fixed-stack.0 + 28
47-
; CHECK32: renamable $r[[REG1:[0-9]+]] = LWZ 84, %fixed-stack.0
48-
; CHECK32: renamable $r[[REG2:[0-9]+]] = LWZ 80, %fixed-stack.0
4948
; CHECK32: renamable $r4 = ADDC killed renamable $r8, killed renamable $r[[REG1]], implicit-def $carry
5049
; CHECK32: renamable $r3 = ADDE killed renamable $r7, killed renamable $r[[REG2]], implicit-def dead $carry, implicit killed $carry
50+
; CHECK32 STW killed renamable $r10, 28, %fixed-stack.0 :: (store 4 into %fixed-stack.0 + 28
5151
; CHECK32: BLR implicit $lr, implicit $rm, implicit $r3, implicit $r4
5252

5353

@@ -68,14 +68,14 @@ entry:
6868
; CHECK64: bb.0.entry:
6969
; CHECK64: liveins: $x3, $x4, $x5, $x6, $x7, $x8, $x9, $x10
7070

71+
; CHECK64: renamable $x[[REG1:[0-9]+]] = LD 80, %fixed-stack.0
7172
; CHECK64: STD killed renamable $x3, 0, %fixed-stack.0 :: (store 8 into %fixed-stack.0
7273
; CHECK64: STD killed renamable $x4, 8, %fixed-stack.0 :: (store 8 into %fixed-stack.0 + 8
7374
; CHECK64: STD renamable $x5, 16, %fixed-stack.0 :: (store 8 into %fixed-stack.0 + 16
7475
; CHECK64: STD killed renamable $x6, 24, %fixed-stack.0 :: (store 8 into %fixed-stack.0 + 24
7576
; CHECK64: STD killed renamable $x7, 32, %fixed-stack.0 :: (store 8 into %fixed-stack.0 + 32
7677
; CHECK64: STD killed renamable $x8, 40, %fixed-stack.0 :: (store 8 into %fixed-stack.0 + 40
7778
; CHECK64: STD killed renamable $x9, 48, %fixed-stack.0 :: (store 8 into %fixed-stack.0 + 48
78-
; CHECK64: STD killed renamable $x10, 56, %fixed-stack.0 :: (store 8 into %fixed-stack.0 + 56
79-
; CHECK64: renamable $x[[REG1:[0-9]+]] = LD 80, %fixed-stack.0
8079
; CHECK64: renamable $x3 = ADD8 killed renamable $x5, killed renamable $x[[REG1]]
80+
; CHECK64: STD killed renamable $x10, 56, %fixed-stack.0 :: (store 8 into %fixed-stack.0 + 56
8181
; CHECK64: BLR8 implicit $lr8, implicit $rm, implicit $x3

llvm/test/CodeGen/PowerPC/aix-cc-byval.ll

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -756,15 +756,15 @@ entry:
756756

757757
; 32BIT: bb.0.entry:
758758
; 32BIT-NEXT: liveins: $r3, $r4, $r5, $r6, $r7, $r8, $r9, $r10
759+
; 32BIT: STW killed renamable $r8, 20, %fixed-stack.0 :: (store 4 into %fixed-stack.0 + 20
759760
; 32BIT-DAG: STW killed renamable $r3, 0, %fixed-stack.0 :: (store 4 into %fixed-stack.0
760761
; 32BIT-DAG: STW killed renamable $r4, 4, %fixed-stack.0 :: (store 4 into %fixed-stack.0 + 4
761762
; 32BIT-DAG: STW killed renamable $r5, 8, %fixed-stack.0 :: (store 4 into %fixed-stack.0 + 8
762763
; 32BIT-DAG: STW killed renamable $r6, 12, %fixed-stack.0 :: (store 4 into %fixed-stack.0 + 12
763764
; 32BIT-DAG: STW killed renamable $r7, 16, %fixed-stack.0 :: (store 4 into %fixed-stack.0 + 16
764-
; 32BIT-DAG: STW killed renamable $r8, 20, %fixed-stack.0 :: (store 4 into %fixed-stack.0 + 20
765+
; 32BIT: renamable $r3 = LBZ 21, %fixed-stack.0 :: (dereferenceable load 1
765766
; 32BIT-DAG: STW killed renamable $r9, 24, %fixed-stack.0 :: (store 4 into %fixed-stack.0 + 24
766767
; 32BIT-DAG: STW killed renamable $r10, 28, %fixed-stack.0 :: (store 4 into %fixed-stack.0 + 28
767-
; 32BIT: renamable $r3 = LBZ 21, %fixed-stack.0 :: (dereferenceable load 1
768768
; 32BIT: BLR
769769

770770
; 64BIT: fixedStack:
@@ -773,11 +773,11 @@ entry:
773773

774774
; 64BIT: bb.0.entry:
775775
; 64BIT-NEXT: liveins: $x3, $x4, $x5, $x6
776+
; 64BIT: STD killed renamable $x5, 16, %fixed-stack.0 :: (store 8 into %fixed-stack.0 + 16
776777
; 64BIT-DAG: STD killed renamable $x3, 0, %fixed-stack.0 :: (store 8 into %fixed-stack.0
778+
; 64BIT-NEXT: renamable $x3 = LBZ8 21, %fixed-stack.0 :: (dereferenceable load 1
777779
; 64BIT-DAG: STD killed renamable $x4, 8, %fixed-stack.0 :: (store 8 into %fixed-stack.0 + 8
778-
; 64BIT-DAG: STD killed renamable $x5, 16, %fixed-stack.0 :: (store 8 into %fixed-stack.0 + 16
779780
; 64BIT-DAG: STD killed renamable $x6, 24, %fixed-stack.0 :: (store 8 into %fixed-stack.0 + 24
780-
; 64BIT-NEXT: renamable $x3 = LBZ8 21, %fixed-stack.0 :: (dereferenceable load 1
781781
; 64BIT-NEXT: BLR8
782782

783783
; ASM-LABEL: .test_byval_32Byte:
@@ -901,9 +901,9 @@ entry:
901901
; 32BIT-DAG: STW killed renamable $r6, 12, %fixed-stack.0 :: (store 4 into %fixed-stack.0 + 12
902902
; 32BIT-DAG: STW killed renamable $r7, 16, %fixed-stack.0 :: (store 4 into %fixed-stack.0 + 16
903903
; 32BIT-DAG: STW killed renamable $r8, 20, %fixed-stack.0 :: (store 4 into %fixed-stack.0 + 20
904+
; 32BIT-NEXT: renamable $f1 = LFD 16, %fixed-stack.0 :: (dereferenceable load 8
904905
; 32BIT-DAG: STW killed renamable $r9, 24, %fixed-stack.0 :: (store 4 into %fixed-stack.0 + 24
905906
; 32BIT-DAG: STW killed renamable $r10, 28, %fixed-stack.0 :: (store 4 into %fixed-stack.0 + 28
906-
; 32BIT-NEXT: renamable $f1 = LFD 16, %fixed-stack.0 :: (dereferenceable load 8
907907
; 32BIT-NEXT: BLR
908908

909909
; 64BIT: fixedStack:
@@ -913,10 +913,10 @@ entry:
913913
; 64BIT: bb.0.entry:
914914
; 64BIT-NEXT: liveins: $x3, $x4, $x5, $x6
915915
; 64BIT-DAG: STD killed renamable $x3, 0, %fixed-stack.0 :: (store 8 into %fixed-stack.0
916-
; 64BIT-DAG: STD killed renamable $x4, 8, %fixed-stack.0 :: (store 8 into %fixed-stack.0 + 8
917916
; 64BIT-DAG: STD killed renamable $x5, 16, %fixed-stack.0 :: (store 8 into %fixed-stack.0 + 16
918-
; 64BIT-DAG: STD killed renamable $x6, 24, %fixed-stack.0 :: (store 8 into %fixed-stack.0 + 24
919917
; 64BIT-NEXT: renamable $f1 = LFD 16, %fixed-stack.0 :: (dereferenceable load 8
918+
; 64BIT-DAG: STD killed renamable $x4, 8, %fixed-stack.0 :: (store 8 into %fixed-stack.0 + 8
919+
; 64BIT-DAG: STD killed renamable $x6, 24, %fixed-stack.0 :: (store 8 into %fixed-stack.0 + 24
920920
; 64BIT-NEXT: BLR8
921921

922922
; ASM32-LABEL: .test_byval_31Byte:

llvm/test/CodeGen/PowerPC/aix32-cc-abi-vaarg.ll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@
7474
; 32BIT-DAG: renamable $r11 = ADDI %fixed-stack.0, 0
7575
; 32BIT-DAG: STW renamable $r11, 0, %stack.0.arg1 :: (store 4 into %ir.0)
7676
; 32BIT-DAG: STW renamable $r4, 0, %stack.0.arg1 :: (store 4 into %ir.arg1)
77-
; 32BIT-DAG: renamable $r5 = LWZ 0, %fixed-stack.0 :: (load 4 from %ir.2)
77+
; 32BIT-DAG: renamable $r6 = LWZ 0, %fixed-stack.0 :: (load 4 from %ir.2)
7878
; 32BIT-DAG: renamable $r4 = LWZ 0, %fixed-stack.0 :: (load 4 from %ir.4)
79-
; 32BIT-DAG: renamable $r3 = nsw ADD4 killed renamable $r5, killed renamable $r3
79+
; 32BIT-DAG: renamable $r3 = nsw ADD4 killed renamable $r6, killed renamable $r3
8080
; 32BIT-DAG: renamable $r3 = nsw ADD4 killed renamable $r3, killed renamable $r4
8181
; 32BIT-DAG: BLR implicit $lr, implicit $rm, implicit $r3
8282

llvm/test/CodeGen/PowerPC/aix64-cc-abi-vaarg.ll

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -63,15 +63,15 @@
6363
; 64BIT-DAG: STD killed renamable $x10, 48, %fixed-stack.0 :: (store 8)
6464
; 64BIT-DAG: renamable $x11 = ADDI8 %fixed-stack.0, 0
6565
; 64BIT-DAG: STD renamable $x11, 0, %stack.1.arg2 :: (store 8 into %ir.1)
66-
; 64BIT-DAG: renamable $x4 = LD 0, %stack.1.arg2 :: (load 8 from %ir.arg2)
67-
; 64BIT-DAG: renamable $x7 = ADDI8 renamable $x4, 4
68-
; 64BIT-DAG: renamable $x5 = ADDI8 %fixed-stack.0, 4
69-
; 64BIT-DAG: renamable $r6 = LWZ 0, %fixed-stack.0 :: (load 4 from %fixed-stack.0, align 8)
66+
; 64BIT-DAG: renamable $x6 = LD 0, %stack.1.arg2 :: (load 8 from %ir.arg2)
67+
; 64BIT-DAG: renamable $x9 = ADDI8 renamable $x6, 4
68+
; 64BIT-DAG: renamable $x7 = ADDI8 %fixed-stack.0, 4
69+
; 64BIT-DAG: renamable $r8 = LWZ 0, %fixed-stack.0 :: (load 4 from %fixed-stack.0, align 8)
7070
; 64BIT-DAG: STD killed renamable $x11, 0, %stack.0.arg1 :: (store 8 into %ir.0)
71-
; 64BIT-DAG: STD killed renamable $x5, 0, %stack.0.arg1 :: (store 8 into %ir.arg1)
72-
; 64BIT-DAG: STD killed renamable $x7, 0, %stack.1.arg2 :: (store 8 into %ir.arg2)
73-
; 64BIT-DAG: renamable $r4 = LWZ 0, killed renamable $x4 :: (load 4)
74-
; 64BIT-DAG: renamable $r3 = nsw ADD4 killed renamable $r6, renamable $r3, implicit killed $x3
71+
; 64BIT-DAG: STD killed renamable $x7, 0, %stack.0.arg1 :: (store 8 into %ir.arg1)
72+
; 64BIT-DAG: STD killed renamable $x9, 0, %stack.1.arg2 :: (store 8 into %ir.arg2)
73+
; 64BIT-DAG: renamable $r4 = LWZ 0, killed renamable $x6 :: (load 4)
74+
; 64BIT-DAG: renamable $r3 = nsw ADD4 killed renamable $r8, renamable $r3, implicit killed $x3
7575
; 64BIT-DAG: renamable $r4 = RLWINM killed renamable $r4, 1, 0, 30
7676
; 64BIT-DAG: renamable $r3 = nsw ADD4 killed renamable $r3, killed renamable $r4, implicit-def $x3
7777
; 64BIT-DAG: BLR8 implicit $lr8, implicit $rm, implicit $x3
@@ -225,14 +225,14 @@
225225
; 64BIT-DAG: STD killed renamable $x9, 40, %fixed-stack.0 :: (store 8)
226226
; 64BIT-DAG: STD killed renamable $x10, 48, %fixed-stack.0 :: (store 8)
227227
; 64BIT-DAG: STD renamable $x3, 0, %stack.1.arg2 :: (store 8 into %ir.1)
228-
; 64BIT-DAG: renamable $x4 = LD 0, %stack.1.arg2 :: (load 8 from %ir.arg2)
229-
; 64BIT-DAG: renamable $x5 = ADDI8 %fixed-stack.0, 8
228+
; 64BIT-DAG: renamable $x6 = LD 0, %stack.1.arg2 :: (load 8 from %ir.arg2)
229+
; 64BIT-DAG: renamable $x7 = ADDI8 %fixed-stack.0, 8
230230
; 64BIT-DAG: STD killed renamable $x3, 0, %stack.0.arg1 :: (store 8 into %ir.0)
231-
; 64BIT-DAG: STD killed renamable $x5, 0, %stack.0.arg1 :: (store 8 into %ir.arg1)
231+
; 64BIT-DAG: STD killed renamable $x7, 0, %stack.0.arg1 :: (store 8 into %ir.arg1)
232232
; 64BIT-DAG: renamable $f0 = LFD 0, %fixed-stack.0 :: (load 8)
233-
; 64BIT-DAG: renamable $x3 = ADDI8 renamable $x4, 8
233+
; 64BIT-DAG: renamable $x3 = ADDI8 renamable $x6, 8
234234
; 64BIT-DAG: STD killed renamable $x3, 0, %stack.1.arg2 :: (store 8 into %ir.arg2)
235-
; 64BIT-DAG: renamable $f2 = LFD 0, killed renamable $x4 :: (load 8)
235+
; 64BIT-DAG: renamable $f2 = LFD 0, killed renamable $x6 :: (load 8)
236236
; 64BIT-DAG: renamable $f0 = nofpexcept FADD killed renamable $f0, killed renamable $f1, implicit $rm
237237
; 64BIT-DAG: renamable $f1 = nofpexcept FADD killed renamable $f2, renamable $f2, implicit $rm
238238
; 64BIT-DAG: renamable $f1 = nofpexcept FADD killed renamable $f0, killed renamable $f1, implicit $rm

0 commit comments

Comments
 (0)