Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2d1a67c

Browse files
author
git apple-llvm automerger
committed
Merge commit '9adc7fc3cdf5' from llvm.org/master into apple/master
2 parents 2cc7e7c + 9adc7fc commit 2d1a67c

File tree

2 files changed

+103
-0
lines changed

2 files changed

+103
-0
lines changed

llvm/lib/Target/SystemZ/SystemZShortenInst.cpp

+43
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ class SystemZShortenInst : public MachineFunctionPass {
4646
bool shortenOn001(MachineInstr &MI, unsigned Opcode);
4747
bool shortenOn001AddCC(MachineInstr &MI, unsigned Opcode);
4848
bool shortenFPConv(MachineInstr &MI, unsigned Opcode);
49+
bool shortenFusedFPOp(MachineInstr &MI, unsigned Opcode);
4950

5051
const SystemZInstrInfo *TII;
5152
const TargetRegisterInfo *TRI;
@@ -175,6 +176,32 @@ bool SystemZShortenInst::shortenFPConv(MachineInstr &MI, unsigned Opcode) {
175176
return false;
176177
}
177178

179+
bool SystemZShortenInst::shortenFusedFPOp(MachineInstr &MI, unsigned Opcode) {
180+
MachineOperand &DstMO = MI.getOperand(0);
181+
MachineOperand &LHSMO = MI.getOperand(1);
182+
MachineOperand &RHSMO = MI.getOperand(2);
183+
MachineOperand &AccMO = MI.getOperand(3);
184+
if (SystemZMC::getFirstReg(DstMO.getReg()) < 16 &&
185+
SystemZMC::getFirstReg(LHSMO.getReg()) < 16 &&
186+
SystemZMC::getFirstReg(RHSMO.getReg()) < 16 &&
187+
SystemZMC::getFirstReg(AccMO.getReg()) < 16 &&
188+
DstMO.getReg() == AccMO.getReg()) {
189+
MachineOperand Lhs(LHSMO);
190+
MachineOperand Rhs(RHSMO);
191+
MachineOperand Src(AccMO);
192+
MI.RemoveOperand(3);
193+
MI.RemoveOperand(2);
194+
MI.RemoveOperand(1);
195+
MI.setDesc(TII->get(Opcode));
196+
MachineInstrBuilder(*MI.getParent()->getParent(), &MI)
197+
.add(Src)
198+
.add(Lhs)
199+
.add(Rhs);
200+
return true;
201+
}
202+
return false;
203+
}
204+
178205
// Process all instructions in MBB. Return true if something changed.
179206
bool SystemZShortenInst::processBlock(MachineBasicBlock &MBB) {
180207
bool Changed = false;
@@ -235,6 +262,22 @@ bool SystemZShortenInst::processBlock(MachineBasicBlock &MBB) {
235262
Changed |= shortenOn001(MI, SystemZ::MEEBR);
236263
break;
237264

265+
case SystemZ::WFMADB:
266+
Changed |= shortenFusedFPOp(MI, SystemZ::MADBR);
267+
break;
268+
269+
case SystemZ::WFMASB:
270+
Changed |= shortenFusedFPOp(MI, SystemZ::MAEBR);
271+
break;
272+
273+
case SystemZ::WFMSDB:
274+
Changed |= shortenFusedFPOp(MI, SystemZ::MSDBR);
275+
break;
276+
277+
case SystemZ::WFMSSB:
278+
Changed |= shortenFusedFPOp(MI, SystemZ::MSEBR);
279+
break;
280+
238281
case SystemZ::WFLCDB:
239282
Changed |= shortenOn01(MI, SystemZ::LCDFR);
240283
break;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
# RUN: llc -mtriple=s390x-linux-gnu -mcpu=z14 -start-before=postrapseudos %s -o - \
2+
# RUN: | FileCheck %s
3+
#
4+
# Test shortening of fused fp operations.
5+
6+
--- |
7+
define double @fun0(double %f1, double %f2, double %acc) { ret double 0.0 }
8+
...
9+
10+
# CHECK-LABEL: fun0:
11+
# CHECK: madbr %f0, %f4, %f2
12+
# CHECK-NEXT: wfmadb %f0, %f4, %v16, %f0
13+
# CHECK-NEXT: wfmadb %f0, %f4, %f0, %f2
14+
# CHECK-NEXT: maebr %f0, %f4, %f2
15+
# CHECK-NEXT: wfmasb %f0, %f4, %v16, %f0
16+
# CHECK-NEXT: wfmasb %f0, %f4, %f0, %f2
17+
# CHECK-NEXT: msdbr %f0, %f4, %f2
18+
# CHECK-NEXT: wfmsdb %f0, %f4, %v16, %f0
19+
# CHECK-NEXT: wfmsdb %f0, %f4, %f0, %f2
20+
# CHECK-NEXT: msebr %f0, %f4, %f2
21+
# CHECK-NEXT: wfmssb %f0, %f4, %v16, %f0
22+
# CHECK-NEXT: wfmssb %f0, %f4, %f0, %f2
23+
# CHECK-NEXT: br %r14
24+
---
25+
name: fun0
26+
alignment: 16
27+
tracksRegLiveness: true
28+
liveins:
29+
- { reg: '$f0d' }
30+
- { reg: '$f2d' }
31+
- { reg: '$f4d' }
32+
frameInfo:
33+
maxAlignment: 1
34+
maxCallFrameSize: 0
35+
fixedStack:
36+
- { id: 0, offset: -160, size: 8, alignment: 8 }
37+
machineFunctionInfo: {}
38+
body: |
39+
bb.0 (%ir-block.0):
40+
liveins: $f0d, $f2d, $f4d, $f16d
41+
42+
renamable $f0d = nofpexcept WFMADB renamable $f4d, renamable $f2d, renamable $f0d, implicit $fpc
43+
renamable $f0d = nofpexcept WFMADB renamable $f4d, renamable $f16d, renamable $f0d, implicit $fpc
44+
renamable $f0d = nofpexcept WFMADB renamable $f4d, renamable $f0d, renamable $f2d, implicit $fpc
45+
46+
renamable $f0s = nofpexcept WFMASB renamable $f4s, renamable $f2s, renamable $f0s, implicit $fpc
47+
renamable $f0s = nofpexcept WFMASB renamable $f4s, renamable $f16s, renamable $f0s, implicit $fpc
48+
renamable $f0s = nofpexcept WFMASB renamable $f4s, renamable $f0s, renamable $f2s, implicit $fpc
49+
50+
renamable $f0d = nofpexcept WFMSDB renamable $f4d, renamable $f2d, renamable $f0d, implicit $fpc
51+
renamable $f0d = nofpexcept WFMSDB renamable $f4d, renamable $f16d, renamable $f0d, implicit $fpc
52+
renamable $f0d = nofpexcept WFMSDB renamable $f4d, renamable $f0d, renamable $f2d, implicit $fpc
53+
54+
renamable $f0s = nofpexcept WFMSSB renamable $f4s, renamable $f2s, renamable $f0s, implicit $fpc
55+
renamable $f0s = nofpexcept WFMSSB renamable $f4s, renamable $f16s, renamable $f0s, implicit $fpc
56+
renamable $f0s = nofpexcept WFMSSB renamable $f4s, renamable $f0s, renamable $f2s, implicit $fpc
57+
58+
Return implicit $f0d
59+
60+
...

0 commit comments

Comments
 (0)