[LLVMdev] [cfe-dev] no-alias generated as result of restrict function arguments

Joerg Sonnenberger joerg at britannica.bec.de
Thu Jan 17 11:17:33 PST 2013


On Thu, Jan 17, 2013 at 11:00:55AM -0800, Dan Gohman wrote:
> How important is this optimization? Do you have real-world code where
> it matters?

There are at least quite a few test cases that hit this optimisation.

My main concern here is getting correct code, which isn't true ATM.
I would expect list handling code and a number of other cases to be well
optimisable in this regard.

> Intuitively, it seems that the kind of pointer comparisons you're
> aiming at would be uncommon.

The NoAlias arguments are the least specific case, but most likely the
one case that is critical. I don't have a strong position on including
them.

> Code authors can avoid them for the same
> reason that you think the compiler can eliminate them (except that a
> code author typically doesn't have to worry about their own code being
> pathological, while the optimizer does). I'm aware that code can often
> look pretty surprising after macro expansion and inlining, but anyone
> choosing to add restrict to their pointers is obliged to be fairly
> careful about how such pointers are used.

The only reason we are discussing this complications is because Inline
Cost Estimation might at some point in the future want to use this
infrastructure across function boundaries. Even then, the worst case
would be a bad cost estimate, so it might be acceptable.

Joerg



More information about the llvm-dev mailing list