<html><head><meta http-equiv="Content-Type" content="text/html charset=us-ascii"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><br><div><div>On Nov 18, 2012, at 9:30 PM, Hal Finkel <<a href="mailto:hfinkel@anl.gov">hfinkel@anl.gov</a>> wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite"><blockquote type="cite" style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><br>+      bool Found = false;<br>+      for (SmallVectorImpl<Value *>::iterator J = Objects.begin(),<br>+           JE = Objects.end(); J != JE; ++J)<br>+        if (V == *J) {<br>+          Found = true;<br>+          break;<br>+        }<br>+<br>+      if (!Found)<br><br>Since only visited values are pushed, you should not need this loop.<br></blockquote><br style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; "><span style="font-family: Helvetica; font-size: medium; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: 2; text-align: -webkit-auto; text-indent: 0px; text-transform: none; white-space: normal; widows: 2; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; display: inline !important; float: none; ">Collecting the underlying objects from different IntToPtr instructions could still yield duplicate underlying objects. On the other hand, is it important to insure that the values in the array are unique? (does the scheduler care about the insertion of duplicate edges?)</span></blockquote></div><br><div>What if you mark the results of GetUnderlyingObjects visited like this?</div><div><br></div><div><div>+    for (SmallVector<Value *, 4>::iterator I = Objs.begin(), IE = Objs.end();</div><div>+         I != IE; ++I) {</div><div>+      V = *I;</div></div><div><div>+    if (!Visited.insert(V))</div><div>+      continue;</div></div><div><br></div><div>Then do you still need this?</div><div><br></div><div><div>+          if (!Visited.count(O))</div><div>+            Working.push_back(O);</div></div><div><br></div><div>Or this?</div><div><br></div><div><div>+      bool Found = false;</div><div>+      for (SmallVectorImpl<Value *>::iterator J = Objects.begin(),</div><div>+           JE = Objects.end(); J != JE; ++J)</div><div>+        if (V == *J) {</div><div>+          Found = true;</div><div>+          break;</div><div>+        }</div><div>+</div><div>+      if (!Found)</div></div><div><br></div><div>The scheduler can handle duplicate edges. You just have to be careful not to blow up the DAG.</div><div><br></div><div>Otherwise your patch looks great.</div><div><br></div><div>-Andy</div></body></html>