Hi,

On Thu, Feb 17 2022, Erick Ochoa via Gcc wrote:
> Hello,
>
> I'm trying to understand ipa-bit-cp/ipa-cp and how the known bits are
> propagated to the lattice in the case of a pointer_plus_expr.
>
> I have a piece of code similar to the following (this being a simplified
> example)
>
> int main ()
> {
>   // a = some pointer.
>   foo (a);
> }
>
> foo (void* a)
> {
>   bar (a + 1);
> }
>
> bar (void *a) {}
>
> I have the following ipa-cp dump:
>
> callsite main -> foo
> param 0: UNKNOWN
>      value: 0x0, mask 0xfffffffffffffff8
>
>
> as it is passed to bar I have the following:
>
> callsite foo -> bar
> param 0: PASS THROUGH: 0, op poiner_plus_expr 8
>   value: 0x0, mask 0xffffffffffffffff
>
> My question is, shouldn't the mask to bar be 0xfffffffffffffff8?
>
> If I understand correctly the mask being 0xfffffffffffffff8 implies that
> the value will be a multiple of 8. By adding 8 (or any multiple of 8) to
> it, it should still be a multiple of 8. Where I believe the mask becomes
> 0xffffffffffffffff is that during the addition there might be an overflow
> of the masks and the operand 8. But I am still unsure. Can someone point
> out what is happening here?

If you do not use LTO, foo and bar must be static for IPA-CP to
determine that their arguments are aligned - and correctly so, if there
are unknown callers passing unknown values, we cannot assume anything.
With LTO or them being static, IPA-CP can do so.

But make sure you understand that different things in the dump mean
different stuff, you will not find any propagated values in the
jump-function dump which you quoted, those really just describe the call
without any larger context.  For results of propagation you need to look
into the "Lattices" section of the dump.

Martin

Reply via email to