<div dir="ltr"><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 19, 2015 at 6:58 PM, <a href="mailto:hfinkel@anl.gov">hfinkel@anl.gov</a> <span dir="ltr"><<a href="mailto:hfinkel@anl.gov" target="_blank">hfinkel@anl.gov</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">Comment at: lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp:592-595<br>
@@ +591,6 @@<br>
+<br>
+  // If there are more indices after the one we might replace with a zero, make<br>
+  // sure they're all non-negative. If any of them are negative, the overall<br>
+  // address being computed might be before the base address determined by the<br>
+  // first non-zero index.<br>
+  auto AllNonNegative = [&]() -> bool {<br>
----------------<br>
</span><span class="">chandlerc wrote:<br>
> Maybe too clever, but what do you think about bailing the first time you see a positive index as well since you're checking for inbounds? You could make the predicate "canBacktrackFromPastEnd" or some such. As soon as you see a potentially negative index return true, as soon as you see a definitely positive index, return false, if you exhaust the indices return false.<br>
</span>I'm not sure that works. Even after a positive index, we could have a "larger" negative index, and we could still keep everthing inbounds.</blockquote></div><br>Nope, inbounds says that all intermediate pointers must be inbounds. The moment you go more than 1-past-the-end, even 1 byte more, boom.</div></div>