On Fri, Apr 19, 2019 at 11:09:27AM +0200, Jens Gustedt wrote:
> > similarly, if one of the
> > pointers is &object or &object + sizeof (object).
> 
> Here I don't follow. Why would one waste brain and ressources to
> optimize code that does such tricks?

What tricks?  A normal pointer comparison either of two pointers
or a pointer and address of something is something that happens in
real-world code all the time, and in many cases it is essential
that optimizing compilers attempt to optimize such tests as much as
possible.
In the http://gcc.gnu.org/PR88775 (yes, it is C++, not C, but I don't see
significant differences there), we started using uintptr_t comparisons
instead of pointer comparisons in std::less etc. because the C++ standard
requires that those are total ordering even for pointers and because we do
optimize those ptr != ptr2 comparisons but don't for the uintptr_t casts
because of the ptr points to end of obj1 and ptr2 points to obj2 that might
be allocated adjacent we generate significantly worse code.
Now you are suggesting we must generate such bad code even for the pointer
comparisons.

        Jakub

Reply via email to