[llvm] 27c61d0 - [RISCV] Split DemandedField logic in advance of reuse in dataflow [nfc]
Philip Reames via llvm-commits
llvm-commits at lists.llvm.org
Thu Jun 16 08:49:59 PDT 2022
Author: Philip Reames
Date: 2022-06-16T08:49:41-07:00
New Revision: 27c61d033fbfb9bd7ef56922e182d3cb92bbeec5
URL: https://github.com/llvm/llvm-project/commit/27c61d033fbfb9bd7ef56922e182d3cb92bbeec5
DIFF: https://github.com/llvm/llvm-project/commit/27c61d033fbfb9bd7ef56922e182d3cb92bbeec5.diff
LOG: [RISCV] Split DemandedField logic in advance of reuse in dataflow [nfc]
This change just moves some code around, and extracts out a helper function expected to be useful when reusing the demanded field logic in the forward dataflow.
Added:
Modified:
llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
Removed:
################################################################################
diff --git a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
index f757633c9a53..df857db5afd6 100644
--- a/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
+++ b/llvm/lib/Target/RISCV/RISCVInsertVSETVLI.cpp
@@ -94,6 +94,55 @@ static unsigned getSEWLMULRatio(unsigned SEW, RISCVII::VLMUL VLMul) {
return (SEW * 8) / LMul;
}
+/// Which subfields of VL or VTYPE have values we need to preserve?
+struct DemandedFields {
+ bool VL = false;
+ bool SEW = false;
+ bool LMUL = false;
+ bool SEWLMULRatio = false;
+ bool TailPolicy = false;
+ bool MaskPolicy = false;
+
+ // Return true if any part of VTYPE was used
+ bool usedVTYPE() {
+ return SEW || LMUL || SEWLMULRatio || TailPolicy || MaskPolicy;
+ }
+};
+
+/// Return true if the two values of the VTYPE register provided are
+/// indistinguishable from the perspective of an instruction (or set of
+/// instructions) which use only the Used subfields and properties.
+static bool areCompatibleVTYPEs(uint64_t VType1,
+ uint64_t VType2,
+ const DemandedFields &Used) {
+ if (Used.SEW &&
+ RISCVVType::getSEW(VType1) != RISCVVType::getSEW(VType2))
+ return false;
+
+ if (Used.LMUL &&
+ RISCVVType::getVLMUL(VType1) != RISCVVType::getVLMUL(VType2))
+ return false;
+
+ if (Used.SEWLMULRatio) {
+ auto Ratio1 = getSEWLMULRatio(RISCVVType::getSEW(VType1),
+ RISCVVType::getVLMUL(VType1));
+ auto Ratio2 = getSEWLMULRatio(RISCVVType::getSEW(VType2),
+ RISCVVType::getVLMUL(VType2));
+ if (Ratio1 != Ratio2)
+ return false;
+ }
+
+ if (Used.TailPolicy &&
+ RISCVVType::isTailAgnostic(VType1) != RISCVVType::isTailAgnostic(VType2))
+ return false;
+ if (Used.MaskPolicy &&
+ RISCVVType::isMaskAgnostic(VType1) != RISCVVType::isMaskAgnostic(VType2))
+ return false;
+ return true;
+}
+
+/// Defines the abstract state with which the forward dataflow models the
+/// values of the VL and VTYPE registers after insertion.
class VSETVLIInfo {
union {
Register AVLReg;
@@ -1364,21 +1413,6 @@ void RISCVInsertVSETVLI::doPRE(MachineBasicBlock &MBB) {
AvailableInfo, OldInfo);
}
-/// Which subfields of VL or VTYPE have values we need to preserve?
-struct DemandedFields {
- bool VL = false;
- bool SEW = false;
- bool LMUL = false;
- bool SEWLMULRatio = false;
- bool TailPolicy = false;
- bool MaskPolicy = false;
-
- // Return true if any part of VTYPE was used
- bool usedVTYPE() {
- return SEW || LMUL || SEWLMULRatio || TailPolicy || MaskPolicy;
- }
-};
-
static void doUnion(DemandedFields &A, DemandedFields B) {
A.VL |= B.VL;
A.SEW |= B.SEW;
@@ -1436,31 +1470,7 @@ static bool canMutatePriorConfig(const MachineInstr &PrevMI,
auto PriorVType = PrevMI.getOperand(2).getImm();
auto VType = MI.getOperand(2).getImm();
-
- if (Used.SEW &&
- RISCVVType::getSEW(VType) != RISCVVType::getSEW(PriorVType))
- return false;
-
- if (Used.LMUL &&
- RISCVVType::getVLMUL(VType) != RISCVVType::getVLMUL(PriorVType))
- return false;
-
- if (Used.SEWLMULRatio) {
- auto PriorRatio = getSEWLMULRatio(RISCVVType::getSEW(PriorVType),
- RISCVVType::getVLMUL(PriorVType));
- auto Ratio = getSEWLMULRatio(RISCVVType::getSEW(VType),
- RISCVVType::getVLMUL(VType));
- if (PriorRatio != Ratio)
- return false;
- }
-
- if (Used.TailPolicy &&
- RISCVVType::isTailAgnostic(VType) != RISCVVType::isTailAgnostic(PriorVType))
- return false;
- if (Used.MaskPolicy &&
- RISCVVType::isMaskAgnostic(VType) != RISCVVType::isMaskAgnostic(PriorVType))
- return false;
- return true;
+ return areCompatibleVTYPEs(PriorVType, VType, Used);
}
void RISCVInsertVSETVLI::doLocalPostpass(MachineBasicBlock &MBB) {
More information about the llvm-commits
mailing list