1 # RUN: llc -mtriple=powerpc64le--linux-gnu -stop-after ppc-pre-emit-peephole %s -o - -verify-machineinstrs | FileCheck %s
3 # ADDI instr: ToBeChangedReg = ADDI FrameBaseReg, OffsetAddi
4 # ADD instr: ToBeDeletedReg = ADD ToBeChangedReg(killed), ScaleReg
5 # Imm instr: Reg = op OffsetImm, ToBeDeletedReg(killed)
9 # new ADDI instr: ToBeChangedReg = ADDI FrameBaseReg, (OffsetAddi + OffsetImm)
10 # Index instr: Reg = opx ScaleReg, ToBeChangedReg(killed)
14 #CHECK: name: testIndexForm1
15 # ToBeDeletedReg equals to ScaleReg
16 tracksRegLiveness: true
19 liveins: $x3, $x1, $x4, $x6
21 ; CHECK: $x3 = ADDI8 $x1, -76
22 $x4 = ADD8 killed $x3, killed $x4
24 $x6 = LD 4, killed $x4
25 ; CHECK: $x6 = LDX killed $x4, killed $x3
26 BLR8 implicit $lr8, implicit $rm
30 #CHECK: name: testIndexForm2
31 # ToBeDeletedReg equals to ToBeChangedReg
32 tracksRegLiveness: true
35 liveins: $x3, $x1, $x4, $x6
37 ; CHECK: $x3 = ADDI8 $x1, -76
38 $x3 = ADD8 killed $x3, killed $x4
40 $x6 = LD 4, killed $x3
41 ; CHECK: $x6 = LDX killed $x4, killed $x3
42 BLR8 implicit $lr8, implicit $rm
46 #CHECK: name: testIndexForm3
47 # There is other use for ToBeDeletedReg between ADD instr and Imm instr
48 tracksRegLiveness: true
51 liveins: $x3, $x1, $x4, $x6
53 ; CHECK: $x3 = ADDI8 $x1, -80
54 $x3 = ADD8 killed $x3, killed $x4
55 ; CHECK: $x3 = ADD8 killed $x3, killed $x4
56 STD $x3, killed $x6, 100
57 ; CHECK: STD $x3, killed $x6, 100
58 $x6 = LD 4, killed $x3
59 ; CHECK: $x6 = LD 4, killed $x3
60 BLR8 implicit $lr8, implicit $rm
64 #CHECK: name: testIndexForm4
65 # There is other use for ToBeChangedReg between ADDI instr and ADD instr
66 tracksRegLiveness: true
69 liveins: $x3, $x1, $x4, $x6
71 ; CHECK: $x3 = ADDI8 $x1, -80
72 STD $x3, killed $x6, 100
73 ; CHECK: STD $x3, killed $x6, 100
74 $x3 = ADD8 killed $x3, killed $x4
75 ; CHECK: $x3 = ADD8 killed $x3, killed $x4
76 $x6 = LD 4, killed $x3
77 ; CHECK: $x6 = LD 4, killed $x3
78 BLR8 implicit $lr8, implicit $rm
82 #CHECK: name: testIndexForm5
83 # ToBeChangedReg has no killed flag
84 tracksRegLiveness: true
87 liveins: $x3, $x1, $x4, $x6
89 ; CHECK: $x3 = ADDI8 $x1, -80
90 $x4 = ADD8 $x3, killed $x4
91 ; CHECK: $x4 = ADD8 $x3, killed $x4
92 STD killed $x3, killed $x6, 100
93 ; CHECK: STD killed $x3, killed $x6, 100
94 $x6 = LD 4, killed $x4
95 ; CHECK: $x6 = LD 4, killed $x4
96 BLR8 implicit $lr8, implicit $rm
100 #CHECK: name: testIndexForm6
101 # ToBeDeletedReg has no killed flag
102 tracksRegLiveness: true
105 liveins: $x3, $x1, $x4, $x6
107 ; CHECK: $x3 = ADDI8 $x1, -80
108 $x4 = ADD8 killed $x3, killed $x4
109 ; CHECK: $x4 = ADD8 killed $x3, killed $x4
111 ; CHECK: $x6 = LD 4, $x4
112 STD killed $x4, killed $x6, 100
113 BLR8 implicit $lr8, implicit $rm
117 #CHECK: name: testIndexForm7
118 # There is other def for ToBeChangedReg between ADD instr and Imm instr
119 tracksRegLiveness: true
122 liveins: $x3, $x1, $x4, $x5, $x6
124 ; CHECK: $x3 = ADDI8 $x1, -80
125 $x4 = ADD8 killed $x3, killed $x5
126 ; CHECK: $x4 = ADD8 killed $x3, killed $x5
128 ; CHECK: $x3 = LD 100, $x6
129 STD killed $x3, killed $x6, 200
130 ; CHECK: STD killed $x3, killed $x6, 200
131 $x6 = LD 4, killed $x4
132 ; CHECK: $x6 = LD 4, killed $x4
133 BLR8 implicit $lr8, implicit $rm
137 #CHECK: name: testIndexForm8
138 # There is other def for ScaleReg between ADD instr and Imm instr
139 tracksRegLiveness: true
142 liveins: $x3, $x1, $x4, $x5, $x6
144 ; CHECK: $x3 = ADDI8 $x1, -80
145 $x4 = ADD8 killed $x3, killed $x5
146 ; CHECK: $x4 = ADD8 killed $x3, killed $x5
148 ; CHECK: $x5 = LD 100, $x6
149 STD killed $x5, killed $x6, 200
150 ; CHECK: STD killed $x5, killed $x6, 200
151 $x6 = LD 4, killed $x4
152 ; CHECK: $x6 = LD 4, killed $x4
153 BLR8 implicit $lr8, implicit $rm
158 # Give up the folding if the register is R0/X0
159 tracksRegLiveness: true
162 liveins: $f1, $x0, $x3
163 $x4 = ADDI8 killed $x3, -8
164 $x4 = ADD8 killed $x4, $x0
165 STFD killed $f1, -8, killed $x4
167 BLR8 implicit $lr8, implicit $rm