[llvm] r367326 - AMDGPU: Avoid emitting "true" predicates
Matt Arsenault via llvm-commits
llvm-commits at lists.llvm.org
Tue Jul 30 08:56:43 PDT 2019
Author: arsenm
Date: Tue Jul 30 08:56:43 2019
New Revision: 367326
URL: http://llvm.org/viewvc/llvm-project?rev=367326&view=rev
Log:
AMDGPU: Avoid emitting "true" predicates
Empty condition strings are considerde always true. This removes a lot
of clutter from the generated matcher tables.
This shrinks the source size of AMDGPUGenDAGISel.inc from 7.3M to
6.1M.
Modified:
llvm/trunk/lib/Target/AMDGPU/AMDGPUInstructions.td
llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp
llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h
llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp
llvm/trunk/utils/TableGen/SubtargetFeatureInfo.cpp
Modified: llvm/trunk/lib/Target/AMDGPU/AMDGPUInstructions.td
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/AMDGPU/AMDGPUInstructions.td?rev=367326&r1=367325&r2=367326&view=diff
==============================================================================
--- llvm/trunk/lib/Target/AMDGPU/AMDGPUInstructions.td (original)
+++ llvm/trunk/lib/Target/AMDGPU/AMDGPUInstructions.td Tue Jul 30 08:56:43 2019
@@ -75,7 +75,7 @@ class ILFormat<dag outs, dag ins, string
let isCodeGenOnly = 1;
}
-def TruePredicate : Predicate<"true">;
+def TruePredicate : Predicate<"">;
class PredicateControl {
Predicate SubtargetPredicate = TruePredicate;
Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp?rev=367326&r1=367325&r2=367326&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp (original)
+++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp Tue Jul 30 08:56:43 2019
@@ -1373,8 +1373,10 @@ getPatternComplexity(const CodeGenDAGPat
///
std::string PatternToMatch::getPredicateCheck() const {
SmallVector<const Predicate*,4> PredList;
- for (const Predicate &P : Predicates)
- PredList.push_back(&P);
+ for (const Predicate &P : Predicates) {
+ if (!P.getCondString().empty())
+ PredList.push_back(&P);
+ }
llvm::sort(PredList, deref<llvm::less>());
std::string Check;
Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h?rev=367326&r1=367325&r2=367326&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h (original)
+++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.h Tue Jul 30 08:56:43 2019
@@ -1075,8 +1075,11 @@ public:
std::string C = IsHwMode
? std::string("MF->getSubtarget().checkFeatures(\"" + Features + "\")")
: std::string(Def->getValueAsString("CondString"));
+ if (C.empty())
+ return "";
return IfCond ? C : "!("+C+')';
}
+
bool operator==(const Predicate &P) const {
return IfCond == P.IfCond && IsHwMode == P.IsHwMode && Def == P.Def;
}
Modified: llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp?rev=367326&r1=367325&r2=367326&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp (original)
+++ llvm/trunk/utils/TableGen/GlobalISelEmitter.cpp Tue Jul 30 08:56:43 2019
@@ -3212,7 +3212,7 @@ Error
GlobalISelEmitter::importRulePredicates(RuleMatcher &M,
ArrayRef<Predicate> Predicates) {
for (const Predicate &P : Predicates) {
- if (!P.Def)
+ if (!P.Def || P.getCondString().empty())
continue;
declareSubtargetFeature(P.Def);
M.addRequiredFeature(P.Def);
Modified: llvm/trunk/utils/TableGen/SubtargetFeatureInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/SubtargetFeatureInfo.cpp?rev=367326&r1=367325&r2=367326&view=diff
==============================================================================
--- llvm/trunk/utils/TableGen/SubtargetFeatureInfo.cpp (original)
+++ llvm/trunk/utils/TableGen/SubtargetFeatureInfo.cpp Tue Jul 30 08:56:43 2019
@@ -38,6 +38,10 @@ SubtargetFeatureInfo::getAll(const Recor
if (Pred->getName().empty())
PrintFatalError(Pred->getLoc(), "Predicate has no name!");
+ // Ignore always true predicates.
+ if (Pred->getValueAsString("CondString").empty())
+ continue;
+
SubtargetFeatures.emplace_back(
Pred, SubtargetFeatureInfo(Pred, SubtargetFeatures.size()));
}
@@ -95,8 +99,10 @@ void SubtargetFeatureInfo::emitComputeAv
OS << " PredicateBitset Features;\n";
for (const auto &SF : SubtargetFeatures) {
const SubtargetFeatureInfo &SFI = SF.second;
+ StringRef CondStr = SFI.TheDef->getValueAsString("CondString");
+ assert(!CondStr.empty() && "true predicate should have been filtered");
- OS << " if (" << SFI.TheDef->getValueAsString("CondString") << ")\n";
+ OS << " if (" << CondStr << ")\n";
OS << " Features[" << SFI.getEnumBitName() << "] = 1;\n";
}
OS << " return Features;\n";
More information about the llvm-commits
mailing list