[PATCH] D92070: [PowerPC] [NFC] code refactor: split IsReassociable to fma and add.
ChenZheng via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Tue Dec 1 18:19:29 PST 2020
This revision was landed with ongoing or failed builds.
This revision was automatically updated to reflect the committed changes.
Closed by commit rG95d6042dd440: [NFC][PowerPC] code refactor: split IsReassociable to fma and add. (authored by shchenz).
Changed prior to commit:
https://reviews.llvm.org/D92070?vs=307503&id=308831#toc
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D92070/new/
https://reviews.llvm.org/D92070
Files:
llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
Index: llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
===================================================================
--- llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
+++ llvm/lib/Target/PowerPC/PPCInstrInfo.cpp
@@ -339,16 +339,28 @@
return true;
};
- auto IsReassociable = [&](const MachineInstr &Instr, int16_t &AddOpIdx,
- bool IsLeaf, bool IsAdd) {
- int16_t Idx = -1;
- if (!IsAdd) {
- Idx = getFMAOpIdxInfo(Instr.getOpcode());
- if (Idx < 0)
- return false;
- } else if (Instr.getOpcode() !=
- FMAOpIdxInfo[getFMAOpIdxInfo(Root.getOpcode())]
- [InfoArrayIdxFAddInst])
+ auto IsReassociableAdd = [&](const MachineInstr &Instr) {
+ if (Instr.getOpcode() !=
+ FMAOpIdxInfo[getFMAOpIdxInfo(Root.getOpcode())][InfoArrayIdxFAddInst])
+ return false;
+
+ // Instruction can be reassociated.
+ // fast math flags may prohibit reassociation.
+ if (!(Instr.getFlag(MachineInstr::MIFlag::FmReassoc) &&
+ Instr.getFlag(MachineInstr::MIFlag::FmNsz)))
+ return false;
+
+ // Instruction operands are virtual registers for reassociation.
+ if (!IsAllOpsVirtualReg(Instr))
+ return false;
+
+ return true;
+ };
+
+ auto IsReassociableFMA = [&](const MachineInstr &Instr, int16_t &AddOpIdx,
+ bool IsLeaf) {
+ int16_t Idx = getFMAOpIdxInfo(Instr.getOpcode());
+ if (Idx < 0)
return false;
// Instruction can be reassociated.
@@ -361,7 +373,7 @@
if (!IsAllOpsVirtualReg(Instr))
return false;
- if (IsAdd && IsLeaf)
+ if (IsLeaf)
return true;
AddOpIdx = FMAOpIdxInfo[Idx][InfoArrayIdxAddOpIdx];
@@ -379,7 +391,7 @@
int16_t AddOpIdx = -1;
// Root must be a valid FMA like instruction.
- if (!IsReassociable(Root, AddOpIdx, false, false))
+ if (!IsReassociableFMA(Root, AddOpIdx, false))
return false;
assert((AddOpIdx >= 0) && "add operand index not right!");
@@ -389,7 +401,7 @@
// Prev must be a valid FMA like instruction.
AddOpIdx = -1;
- if (!IsReassociable(*Prev, AddOpIdx, false, false))
+ if (!IsReassociableFMA(*Prev, AddOpIdx, false))
return false;
assert((AddOpIdx >= 0) && "add operand index not right!");
@@ -397,11 +409,11 @@
Register RegA = Prev->getOperand(AddOpIdx).getReg();
MachineInstr *Leaf = MRI.getUniqueVRegDef(RegA);
AddOpIdx = -1;
- if (IsReassociable(*Leaf, AddOpIdx, true, false)) {
+ if (IsReassociableFMA(*Leaf, AddOpIdx, true)) {
Patterns.push_back(MachineCombinerPattern::REASSOC_XMM_AMM_BMM);
return true;
}
- if (IsReassociable(*Leaf, AddOpIdx, true, true)) {
+ if (IsReassociableAdd(*Leaf)) {
Patterns.push_back(MachineCombinerPattern::REASSOC_XY_AMM_BMM);
return true;
}
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D92070.308831.patch
Type: text/x-patch
Size: 2809 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201202/b9eab759/attachment.bin>
More information about the llvm-commits
mailing list