<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jun 25, 2015, at 2:40 PM, David Blaikie <<a href="mailto:dblaikie@gmail.com" class="">dblaikie@gmail.com</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" class=""><br class=""><div class="gmail_extra"><br class=""><div class="gmail_quote">On Thu, Jun 25, 2015 at 2:30 PM, Pete Cooper <span dir="ltr" class=""><<a href="mailto:peter_cooper@apple.com" target="_blank" class="">peter_cooper@apple.com</a>></span> wrote:<br class=""><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">Hi David<br class="">
<br class="">
Currently the only SDNode iterator over operands does so with SDUse*.  Users frequently then call getNode() on the operand.<br class="">
<br class="">
This patch adds an iterator to SDNode which returns the SDNode of the operand.  This allows more patterns to be converted to foreach.  It is based on value_op_iterator which I found in User.h.<br class="">
<br class="">
For now i’ve only used it in a single place, but I found a bunch more in DAGCombiner for example which should be applicable.  I would convert those in a later commit assuming you are ok with this solution.<br class=""></blockquote><div class=""><br class="">This immediately raises red flags:<br class=""><br class=""><div class="">  SDNode *operator*() const { return I->getNode(); }</div><div class="">  SDNode *operator->() const { return operator*(); }<br class=""><br class="">op* should return a T& and op-> should return T*<br class=""></div></div></div></div></div></div></blockquote>I’d forgotten about that.<br class=""><blockquote type="cite" class=""><div class=""><div dir="ltr" class=""><div class="gmail_extra"><div class="gmail_quote"><div class=""><div class=""><br class="">If these SDNode*s can never be null, then perhaps this should be:<br class=""></div></div></div></div></div></div></blockquote>I wasn’t actually sure if they could be.  My initial reaction was that null operands wouldn’t make sense, but it turns out we never checked.  So here’s a patch which does actually ensure that the SDNode's referenced as operands are never null.  It passes make check.  I can put it on another email for review if you prefer I don’t add it here.</div><div><br class=""></div><div></div></body></html>