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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
   Last reconfirmed|                            |2021-04-06
             Blocks|                            |85316
     Ever confirmed|0                           |1
   Target Milestone|---                         |9.4

--- Comment #5 from Richard Biener <rguenth at gcc dot gnu.org> ---
The main issue is optimize_bit_field_compare in fold-const.c which produces
during GENERIC folding in .005t.original:

  if ((BIT_FIELD_REF <b, 8, 0> & 1) != 0)
    {
      b.j = 0;
    }
  else
    {
      b.j = b.i;
    }
  return b.j;

that's premature in this place.  For f() it also takes until DOM3 to do
the folding unless you disable SRA which then makes EVRP recognize the
second store as a.j = 0.  With SRA we fail to derive ranges for a_10 in

  a_10 = MEM <unsigned char> [(struct A *)&a];
  a$1_11 = MEM <unsigned char> [(struct A *)&a + 1B];
  _1 = VIEW_CONVERT_EXPR<_Bool>(a_10);
  if (_1 != 0)
    goto <bb 4>; [INV]
  else
    goto <bb 3>; [INV]

  <bb 3> :

  <bb 4> :
  # a$1_9 = PHI <0(2), a_10(3)>
  _7 = VIEW_CONVERT_EXPR<_Bool>(a$1_9);

thus we're missing looking through VIEW_CONVERT_EXPR in register_assert_for.
Amending that would eventually also allow optimizing the prematurely folded
vairant.


Referenced Bugs:

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=85316
[Bug 85316] [meta-bug] VRP range propagation missed cases

Reply via email to