<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sun, Nov 22, 2015 at 11:27 AM, Craig Topper via llvm-commits <span dir="ltr"><<a href="mailto:llvm-commits@lists.llvm.org" target="_blank">llvm-commits@lists.llvm.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">Author: ctopper<br>
Date: Sun Nov 22 13:27:02 2015<br>
New Revision: 253832<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=253832&view=rev" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project?rev=253832&view=rev</a><br>
Log:<br>
[TableGen] Use std::any_of and std::find instead of manual loops. NFC<br>
<br>
Modified:<br>
llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp<br>
<br>
Modified: llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp?rev=253832&r1=253831&r2=253832&view=diff" rel="noreferrer" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp?rev=253832&r1=253831&r2=253832&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp (original)<br>
+++ llvm/trunk/utils/TableGen/CodeGenDAGPatterns.cpp Sun Nov 22 13:27:02 2015<br>
@@ -107,36 +107,36 @@ bool EEVT::TypeSet::FillWithPossibleType<br>
/// hasIntegerTypes - Return true if this TypeSet contains iAny or an<br>
/// integer value type.<br>
bool EEVT::TypeSet::hasIntegerTypes() const {<br>
- for (unsigned i = 0, e = TypeVec.size(); i != e; ++i)<br>
- if (isInteger(TypeVec[i]))<br>
- return true;<br>
- return false;<br>
+ return std::any_of(TypeVec.begin(), TypeVec.end(),<br>
+ [](MVT::SimpleValueType VT) {<br>
+ return isInteger(VT);<br>
+ });<br></blockquote><div><br></div><div>Simplified these ^ a bit further by just passing isFoo directly to std::any_of in <span style="color:rgb(0,0,0)">r253833.</span></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
}<br>
<br>
/// hasFloatingPointTypes - Return true if this TypeSet contains an fAny or<br>
/// a floating point value type.<br>
bool EEVT::TypeSet::hasFloatingPointTypes() const {<br>
- for (unsigned i = 0, e = TypeVec.size(); i != e; ++i)<br>
- if (isFloatingPoint(TypeVec[i]))<br>
- return true;<br>
- return false;<br>
+ return std::any_of(TypeVec.begin(), TypeVec.end(),<br>
+ [](MVT::SimpleValueType VT) {<br>
+ return isFloatingPoint(VT);<br>
+ });<br>
}<br>
<br>
/// hasScalarTypes - Return true if this TypeSet contains a scalar value type.<br>
bool EEVT::TypeSet::hasScalarTypes() const {<br>
- for (unsigned i = 0, e = TypeVec.size(); i != e; ++i)<br>
- if (isScalar(TypeVec[i]))<br>
- return true;<br>
- return false;<br>
+ return std::any_of(TypeVec.begin(), TypeVec.end(),<br>
+ [](MVT::SimpleValueType VT) {<br>
+ return isScalar(VT);<br>
+ });<br>
}<br>
<br>
/// hasVectorTypes - Return true if this TypeSet contains a vAny or a vector<br>
/// value type.<br>
bool EEVT::TypeSet::hasVectorTypes() const {<br>
- for (unsigned i = 0, e = TypeVec.size(); i != e; ++i)<br>
- if (isVector(TypeVec[i]))<br>
- return true;<br>
- return false;<br>
+ return std::any_of(TypeVec.begin(), TypeVec.end(),<br>
+ [](MVT::SimpleValueType VT) {<br>
+ return isVector(VT);<br>
+ });<br>
}<br>
<br>
<br>
@@ -220,14 +220,10 @@ bool EEVT::TypeSet::MergeInTypeInfo(cons<br>
TypeSet InputSet(*this);<br>
<br>
for (unsigned i = 0; i != TypeVec.size(); ++i) {<br>
- bool InInVT = false;<br>
- for (unsigned j = 0, e = InVT.TypeVec.size(); j != e; ++j)<br>
- if (TypeVec[i] == InVT.TypeVec[j]) {<br>
- InInVT = true;<br>
- break;<br>
- }<br>
+ if (std::find(InVT.TypeVec.begin(), InVT.TypeVec.end(), TypeVec[i]) !=<br>
+ InVT.TypeVec.end())<br>
+ continue;<br>
<br>
- if (InInVT) continue;<br>
TypeVec.erase(TypeVec.begin()+i--);<br>
MadeChange = true;<br>
}<br>
@@ -3554,19 +3550,14 @@ static void CombineChildVariants(TreePat<br>
if (!R->canPatternMatch(ErrString, CDP)) {<br>
delete R;<br>
} else {<br>
- bool AlreadyExists = false;<br>
-<br>
// Scan to see if this pattern has already been emitted. We can get<br>
// duplication due to things like commuting:<br>
// (and GPRC:$a, GPRC:$b) -> (and GPRC:$b, GPRC:$a)<br>
// which are the same pattern. Ignore the dups.<br>
- for (unsigned i = 0, e = OutVariants.size(); i != e; ++i)<br>
- if (R->isIsomorphicTo(OutVariants[i], DepVars)) {<br>
- AlreadyExists = true;<br>
- break;<br>
- }<br>
-<br>
- if (AlreadyExists)<br>
+ if (std::any_of(OutVariants.begin(), OutVariants.end(),<br>
+ [=](TreePatternNode *Variant) {<br>
+ return R->isIsomorphicTo(Variant, DepVars);<br>
+ }))<br></blockquote><div><br></div><div>& simplified some code around here further in <span style="color:rgb(0,0,0)">r253834</span></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex">
delete R;<br>
else<br>
OutVariants.push_back(R);<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@lists.llvm.org">llvm-commits@lists.llvm.org</a><br>
<a href="http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits" rel="noreferrer" target="_blank">http://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div></div>