On Mon, Dec 13 2021, Jan Hubicka wrote:
>> >>> +          || (only_for_nonzero && 
>> >>> !src_lats->bits_lattice.known_nonzero_p ()))
>> >>> +        {
>> >>> +          if (jfunc->bits)
>> >>> +            return dest_lattice->meet_with (jfunc->bits->value,
>> >>> +                                            jfunc->bits->mask, 
>> >>> precision);
>> >>> +          else
>> >>> +            return dest_lattice->set_to_bottom ();
>> >>> +        }
>> >> I do not think you need to set to bottom here. For pointers, we
>> >> primarily track alignment and NULL is aligned - all you need to do is to
>> >> make sure that we do not believe that some bits are 1.
>> >
>> > I am not sure I understand, the testcase you wrote has all bits as zeros
>> > and still miscompiles?  It is primarily used for alignment but not only
>> > for that.
>
> Maybe I misunderstand the code.  But if you have only_for_nonzero and
> you do not know htat src lattice is non-zero you will get
>  - if src is 0, then dest is 0
>  - if src is non-zero then dest is src+offset
>

or all known bits of src are zero but then there are unknown masked-out
bits with unknown value and in that case we just don't know.  The patch
does src+offset when there is a known non-zero bit but we can only set
dest to zero if all bits are known.  But as you pointed out, the
constant part of IPA-CP should catch this case, and now does, so I
decided not to handle it here.

If you prefer, I can add a case if both m_value and m_mask or zero
(well, could the latter in theory only need "precision" zeros)? and if
so, simply meet the destination lattice with the source one.

Is that what you are asking for?

Thanks,

Martin

Reply via email to