[llvm-commits] PATCH: Add support for tracking pairs of pointers with a constant offset to inline cost estimation
Duncan Sands
baldrick at free.fr
Wed Mar 14 01:48:11 PDT 2012
On 14/03/12 09:43, Chandler Carruth wrote:
> On Tue, Mar 13, 2012 at 1:23 AM, Duncan Sands <baldrick at free.fr
> <mailto:baldrick at free.fr>> wrote:
>
> maybe I'm missing something, but are all compares really guaranteed to produce a
> constant result here?
>
>
> We check below that the LHS and RHS are the "related" pointers. The idea is that
> the LHS is derived from the RHS (or vice versa) via constant operations. Thus
> the comparison of them will produce some constant.
Not necessarily. Consider for example "x < x + 1". If x is 0 the result is
"true", but if x is INT_MAX then the result is false. So in general you need
to check nsw/nuw flags etc.
Ciao, Duncan.
>
> Think of it this way, all comparison outcomes can be determined by inspecting
> some aspect of the result of a subtraction. In the same way that the subtraction
> removes the non-constant base pointer leaving only the constant relationship,
> the comparison will as well.
More information about the llvm-commits
mailing list