<p><br>
On Mar 25, 2012 4:14 AM, "Benjamin Kramer" <<a href="mailto:benny.kra@googlemail.com">benny.kra@googlemail.com</a>> wrote:<br>
><br>
><br>
> On 25.03.2012, at 12:51, Chandler Carruth wrote:<br>
><br>
> > I recently taught instsimplify to compute the constant difference of two pointers which are constant-derived from a common base. This uses the same logic to handle comparisons. These show up all over the place due to C++ pointers-as-iterators comparing against the end iterator.<br>

> ><br>
> > I'll add a test case before committing, but it's nothing surprising. Just wanted to double check the actual code before moving forward.<br>
><br>
> Compares are a bit more complicated than subs ;)<br>
><br>
> - The resulting predicate should be signed, "&foo[-1] u> &foo[0]" --> "-1 s> 0" --> false</p>
<p>Good catch!</p>
<p>> - It should ignore signed pointer compares. We can't reason about them due to GEP's overflow rules. "&foo[0] <s &foo[1]" can't be folded to "true" because "foo" could be the maximum signed value for the pointer type.<br>

> - It's only safe with inbounds GEPs, so we don't wrap around at the end of address space.</p>
<p>Yep. It's actually a bug with the existing logic I suspect; I'll fix the strip routine to only operate on inbounds geps first and add a test.</p>
<p>However, given inbounds geps, why can't we handle signed comparisons?</p>
<p>><br>
> - Ben<br>
> > <simplify-ptr-cmp.diff>_______________________________________________<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">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><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">http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits</a><br>
</p>