Skip to content

Commit 6f18d91

Browse files
committed
Final
1 parent d8fc31c commit 6f18d91

27 files changed

+177
-1094
lines changed

llvm/include/llvm/CodeGen/MachineCombinerPattern.h

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -34,15 +34,6 @@ enum MachineCombinerPattern : unsigned {
3434
REASSOC_XA_YB,
3535

3636
TARGET_PATTERN_START
37-
// SystemZ patterns. (EXPERIMENTAL)
38-
FMA2_P1P0,
39-
FMA2_P0P1,
40-
FMA2,
41-
FMA1_Add_L,
42-
FMA1_Add_R,
43-
FMA3, // These are inspired by PPC
44-
FMA2_Add, //
45-
4637
};
4738

4839
} // end namespace llvm

llvm/lib/CodeGen/MachineCombiner.cpp

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -298,13 +298,6 @@ CombinerObjective MachineCombiner::getCombinerObjective(unsigned Pattern) {
298298
case MachineCombinerPattern::REASSOC_AX_YB:
299299
case MachineCombinerPattern::REASSOC_XA_BY:
300300
case MachineCombinerPattern::REASSOC_XA_YB:
301-
case MachineCombinerPattern::FMA2_P1P0:
302-
case MachineCombinerPattern::FMA2_P0P1:
303-
case MachineCombinerPattern::FMA2:
304-
case MachineCombinerPattern::FMA1_Add_L:
305-
case MachineCombinerPattern::FMA1_Add_R:
306-
case MachineCombinerPattern::FMA3:
307-
case MachineCombinerPattern::FMA2_Add:
308301
return CombinerObjective::MustReduceDepth;
309302
default:
310303
return TII->getCombinerObjective(Pattern);

llvm/lib/Target/SystemZ/SystemZFinalizeReassociation.cpp

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
//===---- SystemZFinalizeReassociation.cpp - Finalize FP reassociation ----===//
1+
//===----- SystemZFinalizeReassociation.cpp - Finalize reassociation ------===//
22
//
33
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
44
// See https://llvm.org/LICENSE.txt for license information.
@@ -11,12 +11,13 @@
1111
//
1212
// 1. Instruction selection: Disable reg/mem folding for any operations that
1313
// are reassociable since MachineCombiner will not succeed otherwise.
14-
// Select a reg/reg pseudo that pretends to clobber CC since the reg/mem
14+
// Select a reg/reg pseudo that pretends to clobber CC if the reg/mem
1515
// opcode clobbers it.
1616
//
17-
// 2. MachineCombiner: Performs reassociation with the reg/reg instructions.
17+
// 2. MachineCombiner: reassociation with the reg/reg instructions.
1818
//
19-
// 3. PeepholeOptimizer: Fold loads into reg/mem instructions.
19+
// 3. PeepholeOptimizer: Fold loads and reg/reg pseudos into reg/mem
20+
// instructions.
2021
//
2122
// 4. This pass: Convert any remaining reg/reg pseudos.
2223
//
@@ -33,16 +34,14 @@ namespace {
3334
class SystemZFinalizeReassociation : public MachineFunctionPass {
3435
public:
3536
static char ID;
36-
SystemZFinalizeReassociation()
37-
: MachineFunctionPass(ID), TII(nullptr) {
37+
SystemZFinalizeReassociation() : MachineFunctionPass(ID), TII(nullptr) {
3838
initializeSystemZFinalizeReassociationPass(*PassRegistry::getPassRegistry());
3939
}
4040

4141
bool runOnMachineFunction(MachineFunction &MF) override;
4242
void getAnalysisUsage(AnalysisUsage &AU) const override;
4343

4444
private:
45-
4645
bool visitMBB(MachineBasicBlock &MBB);
4746

4847
const SystemZInstrInfo *TII;
@@ -55,8 +54,8 @@ char SystemZFinalizeReassociation::ID = 0;
5554
INITIALIZE_PASS(SystemZFinalizeReassociation, "systemz-finalize-reassoc",
5655
"SystemZ Finalize Reassociation", false, false)
5756

58-
FunctionPass *llvm::
59-
createSystemZFinalizeReassociationPass(SystemZTargetMachine &TM) {
57+
FunctionPass *
58+
llvm::createSystemZFinalizeReassociationPass(SystemZTargetMachine &TM) {
6059
return new SystemZFinalizeReassociation();
6160
}
6261

@@ -70,18 +69,17 @@ bool SystemZFinalizeReassociation::visitMBB(MachineBasicBlock &MBB) {
7069
for (MachineInstr &MI : MBB) {
7170
unsigned PseudoOpcode = MI.getOpcode();
7271
unsigned TargetOpcode =
73-
PseudoOpcode == SystemZ::WFADB_CCPseudo ? SystemZ::WFADB
74-
: PseudoOpcode == SystemZ::WFASB_CCPseudo ? SystemZ::WFASB
75-
: PseudoOpcode == SystemZ::WFSDB_CCPseudo ? SystemZ::WFSDB
76-
: PseudoOpcode == SystemZ::WFSSB_CCPseudo ? SystemZ::WFSSB
77-
: PseudoOpcode == SystemZ::WFMADB_CCPseudo ? SystemZ::WFMADB
78-
: PseudoOpcode == SystemZ::WFMASB_CCPseudo ? SystemZ::WFMASB
79-
: 0;
72+
PseudoOpcode == SystemZ::WFADB_CCPseudo ? SystemZ::WFADB
73+
: PseudoOpcode == SystemZ::WFASB_CCPseudo ? SystemZ::WFASB
74+
: PseudoOpcode == SystemZ::WFSDB_CCPseudo ? SystemZ::WFSDB
75+
: PseudoOpcode == SystemZ::WFSSB_CCPseudo ? SystemZ::WFSSB
76+
: 0;
8077
if (TargetOpcode) {
81-
MI.setDesc(TII->get(TargetOpcode));
82-
int CCIdx = MI.findRegisterDefOperandIdx(SystemZ::CC);
83-
MI.removeOperand(CCIdx);
84-
Changed = true;
78+
MI.setDesc(TII->get(TargetOpcode));
79+
int CCIdx = MI.findRegisterDefOperandIdx(SystemZ::CC, /*isDead=*/true);
80+
assert(CCIdx != -1 && "Expected dead CC-def.");
81+
MI.removeOperand(CCIdx);
82+
Changed = true;
8583
}
8684
}
8785
return Changed;

llvm/lib/Target/SystemZ/SystemZISelDAGToDAG.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2053,8 +2053,7 @@ bool SystemZDAGToDAGISel::shouldSelectForReassoc(SDNode *N) const {
20532053
EVT VT = N->getValueType(0);
20542054
assert(VT.isFloatingPoint() && "Expected FP SDNode");
20552055
return N->getFlags().hasAllowReassociation() &&
2056-
N->getFlags().hasNoSignedZeros() &&
2057-
Subtarget->hasVector() &&
2056+
N->getFlags().hasNoSignedZeros() && Subtarget->hasVector() &&
20582057
(VT != MVT::f32 || Subtarget->hasVectorEnhancements1()) &&
20592058
!N->isStrictFPOpcode();
20602059
}

llvm/lib/Target/SystemZ/SystemZInstrFP.td

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -501,10 +501,8 @@ let Uses = [FPC], mayRaiseFPException = 1 in {
501501
def MAEBR : TernaryRRD<"maebr", 0xB30E, z_any_fma, FP32, FP32>;
502502
def MADBR : TernaryRRD<"madbr", 0xB31E, z_any_fma, FP64, FP64>;
503503

504-
defm MAEB : TernaryRXFAndPseudo<"maeb", 0xED0E, z_any_fma_noreassoc, FP32,
505-
FP32, z_load, 4>;
506-
defm MADB : TernaryRXFAndPseudo<"madb", 0xED1E, z_any_fma_noreassoc, FP64,
507-
FP64, z_load, 8>;
504+
defm MAEB : TernaryRXFAndPseudo<"maeb", 0xED0E, z_any_fma, FP32, FP32, z_load, 4>;
505+
defm MADB : TernaryRXFAndPseudo<"madb", 0xED1E, z_any_fma, FP64, FP64, z_load, 8>;
508506
}
509507

510508
// Fused multiply-subtract.

llvm/lib/Target/SystemZ/SystemZInstrFormats.td

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5537,6 +5537,9 @@ multiclass StringRRE<string mnemonic, bits<16> opcode,
55375537
GR32:$char))]>;
55385538
}
55395539

5540+
// Duplicate the instruction with a pseudo that defines CC that will be
5541+
// selected in cases where reassociation is enabled. The CC operand is needed
5542+
// in order to do later reg/mem folding into instructions that clobber CC.
55405543
multiclass BinaryVRRcAndCCPseudo<string mnemonic, bits<16> opcode,
55415544
SDPatternOperator operator,
55425545
SDPatternOperator reassoc_operator,
@@ -5551,19 +5554,3 @@ multiclass BinaryVRRcAndCCPseudo<string mnemonic, bits<16> opcode,
55515554
(reassoc_operator (tr2.vt tr2.op:$V2),
55525555
(tr2.vt tr2.op:$V3)))]>;
55535556
}
5554-
5555-
multiclass TernaryVRReAndCCPseudo<string mnemonic, bits<16> opcode,
5556-
SDPatternOperator operator,
5557-
SDPatternOperator reassoc_operator,
5558-
TypedReg tr1, TypedReg tr2, bits<4> m5 = 0,
5559-
bits<4> type = 0, string fp_mnemonic = ""> {
5560-
def "" : TernaryVRRe<mnemonic, opcode, operator, tr1, tr2, m5, type,
5561-
fp_mnemonic>;
5562-
let Defs = [CC], AddedComplexity = 1 in // Win over "".
5563-
def _CCPseudo : Pseudo<(outs tr1.op:$V1),
5564-
(ins tr2.op:$V2, tr2.op:$V3, tr1.op:$V4),
5565-
[(set (tr1.vt tr1.op:$V1),
5566-
(reassoc_operator (tr2.vt tr2.op:$V2),
5567-
(tr2.vt tr2.op:$V3),
5568-
(tr1.vt tr1.op:$V4)))]>;
5569-
}

0 commit comments

Comments
 (0)