<div dir="ltr">I'm loving all these TableGen cleanups!<div><div><br></div><div>-- Sean Silva</div></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, May 13, 2015 at 10:54 PM, Craig Topper <span dir="ltr"><<a href="mailto:craig.topper@gmail.com" target="_blank">craig.topper@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Author: ctopper<br>
Date: Thu May 14 00:54:02 2015<br>
New Revision: 237343<br>
<br>
URL: <a href="http://llvm.org/viewvc/llvm-project?rev=237343&view=rev" target="_blank">http://llvm.org/viewvc/llvm-project?rev=237343&view=rev</a><br>
Log:<br>
[TableGen] Remove an unnecessary outer 'if' around 3 separate inner ifs. No functional change intended.<br>
<br>
The outer if had 3 separate conditions ORed together and then the inner ifs detected which of the three conditions it was by using only a portion of the specific condition. Just put the whole condition in each inner if and remove the outer if.<br>
<br>
Modified:<br>
llvm/trunk/lib/TableGen/Record.cpp<br>
<br>
Modified: llvm/trunk/lib/TableGen/Record.cpp<br>
URL: <a href="http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/Record.cpp?rev=237343&r1=237342&r2=237343&view=diff" target="_blank">http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/TableGen/Record.cpp?rev=237343&r1=237342&r2=237343&view=diff</a><br>
==============================================================================<br>
--- llvm/trunk/lib/TableGen/Record.cpp (original)<br>
+++ llvm/trunk/lib/TableGen/Record.cpp Thu May 14 00:54:02 2015<br>
@@ -1096,35 +1096,31 @@ Init *TernOpInit::Fold(Record *CurRec, M<br>
VarInit *RHSv = dyn_cast<VarInit>(RHS);<br>
StringInit *RHSs = dyn_cast<StringInit>(RHS);<br>
<br>
- if ((LHSd && MHSd && RHSd) ||<br>
- (LHSv && MHSv && RHSv) ||<br>
- (LHSs && MHSs && RHSs)) {<br>
- if (RHSd) {<br>
- Record *Val = RHSd->getDef();<br>
- if (LHSd->getAsString() == RHSd->getAsString())<br>
- Val = MHSd->getDef();<br>
- return DefInit::get(Val);<br>
- }<br>
- if (RHSv) {<br>
- std::string Val = RHSv->getName();<br>
- if (LHSv->getAsString() == RHSv->getAsString())<br>
- Val = MHSv->getName();<br>
- return VarInit::get(Val, getType());<br>
- }<br>
- if (RHSs) {<br>
- std::string Val = RHSs->getValue();<br>
+ if (LHSd && MHSd && RHSd) {<br>
+ Record *Val = RHSd->getDef();<br>
+ if (LHSd->getAsString() == RHSd->getAsString())<br>
+ Val = MHSd->getDef();<br>
+ return DefInit::get(Val);<br>
+ }<br>
+ if (LHSv && MHSv && RHSv) {<br>
+ std::string Val = RHSv->getName();<br>
+ if (LHSv->getAsString() == RHSv->getAsString())<br>
+ Val = MHSv->getName();<br>
+ return VarInit::get(Val, getType());<br>
+ }<br>
+ if (LHSs && MHSs && RHSs) {<br>
+ std::string Val = RHSs->getValue();<br>
<br>
- std::string::size_type found;<br>
- std::string::size_type idx = 0;<br>
- do {<br>
- found = Val.find(LHSs->getValue(), idx);<br>
- if (found != std::string::npos)<br>
- Val.replace(found, LHSs->getValue().size(), MHSs->getValue());<br>
- idx = found + MHSs->getValue().size();<br>
- } while (found != std::string::npos);<br>
+ std::string::size_type found;<br>
+ std::string::size_type idx = 0;<br>
+ do {<br>
+ found = Val.find(LHSs->getValue(), idx);<br>
+ if (found != std::string::npos)<br>
+ Val.replace(found, LHSs->getValue().size(), MHSs->getValue());<br>
+ idx = found + MHSs->getValue().size();<br>
+ } while (found != std::string::npos);<br>
<br>
- return StringInit::get(Val);<br>
- }<br>
+ return StringInit::get(Val);<br>
}<br>
break;<br>
}<br>
<br>
<br>
_______________________________________________<br>
llvm-commits mailing list<br>
<a href="mailto:llvm-commits@cs.uiuc.edu">llvm-commits@cs.uiuc.edu</a><br>
<a href="http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits" target="_blank">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</blockquote></div><br></div>