Explicitly track the UFs supported in a VPlan. This is needed to
allow transformations to restrict the UFs which are supported.
Discussed as separate improvement in
D135017.
std::string VPlan::getName() const {
std::string Out;
raw_string_ostream RSO(Out);
- RSO << Name;
+ RSO << Name << " for ";
if (!VFs.empty()) {
- RSO << " for VF={" << VFs[0];
+ RSO << "VF={" << VFs[0];
for (ElementCount VF : drop_begin(VFs))
RSO << "," << VF;
- RSO << "},UF>=1";
+ RSO << "},";
+ }
+
+ if (UFs.empty()) {
+ RSO << "UF>=1";
+ } else {
+ RSO << "UF={" << UFs[0];
+ for (unsigned UF : drop_begin(UFs))
+ RSO << "," << UF;
+ RSO << "}";
}
return Out;
/// Holds the VFs applicable to this VPlan.
SmallSetVector<ElementCount, 2> VFs;
+ /// Holds the UFs applicable to this VPlan. If empty, the VPlan is valid for
+ /// any UF.
+ SmallSetVector<unsigned, 2> UFs;
+
/// Holds the name of the VPlan, for printing.
std::string Name;
bool hasScalarVFOnly() const { return VFs.size() == 1 && VFs[0].isScalar(); }
+ bool hasUF(unsigned UF) const { return UFs.empty() || UFs.contains(UF); }
+
+ void setUF(unsigned UF) {
+ assert(hasUF(UF) && "Cannot set the UF not already in plan");
+ UFs.clear();
+ UFs.insert(UF);
+ }
+
/// Return a string with the name of the plan and the applicable VFs and UFs.
std::string getName() const;
raw_string_ostream OS(FullDump);
Plan->printDOT(OS);
const char *ExpectedStr = R"(digraph VPlan {
-graph [labelloc=t, fontsize=30; label="Vectorization Plan"]
+graph [labelloc=t, fontsize=30; label="Vectorization Plan\n for UF\>=1"]
node [shape=rect, fontname=Courier, fontsize=30]
edge [fontname=Courier, fontsize=30]
compound=true
Plan.printDOT(OS);
const char *ExpectedStr = R"(digraph VPlan {
-graph [labelloc=t, fontsize=30; label="Vectorization Plan"]
+graph [labelloc=t, fontsize=30; label="Vectorization Plan\n for UF\>=1"]
node [shape=rect, fontname=Courier, fontsize=30]
edge [fontname=Courier, fontsize=30]
compound=true
EMIT vp<%1> = add
No successors
}
+)";
+ EXPECT_EQ(ExpectedStr, FullDump);
+ }
+
+ {
+ Plan.setUF(4);
+ std::string FullDump;
+ raw_string_ostream OS(FullDump);
+ Plan.print(OS);
+
+ const char *ExpectedStr = R"(VPlan 'TestPlan for VF={4,vscale x 8},UF={4}' {
+bb1:
+ EMIT vp<%1> = add
+No successors
+}
)";
EXPECT_EQ(ExpectedStr, FullDump);
}