https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65307

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |NEW

--- Comment #9 from Richard Biener <rguenth at gcc dot gnu.org> ---
Visiting statement:
# RANGE [0, 4294967295] NONZERO 0x000000000fffffffe
_5 = 15;
which is likely CONSTANT
Lattice value changed to CONSTANT 14.  Adding SSA edges to worklist.

is of course overly optimistic ;)  (but yes, nonzero bits info is bogus)

I'd say we should eventually assert instead of miscompiling things.

That is,

static prop_value_t
evaluate_stmt (gimple stmt)
{
...
  if (flag_tree_bit_ccp
      && ((is_constant && TREE_CODE (val.value) == INTEGER_CST)
          || (!is_constant && likelyvalue != UNDEFINED))
      && gimple_get_lhs (stmt)
      && TREE_CODE (gimple_get_lhs (stmt)) == SSA_NAME)
    {
          if (!is_constant)
            {
...
            }
          else
            {
              double_int valv = tree_to_double_int (val.value);

here assert

     gcc_assert ((valv & ~val.mask & ~nonzero_bits).is_zero ());

that is, known bits in valv should be consistent with nonzero_bits info.

              if (!(valv & ~nonzero_bits & mask).is_zero ())
                val.value = double_int_to_tree (TREE_TYPE (lhs),
                                                valv & nonzero_bits);
              if (nonzero_bits.is_zero ())
                val.mask = double_int_zero;
              else
                val.mask = val.mask & (nonzero_bits | ~mask);
            }

Reply via email to