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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|unassigned at gcc dot gnu.org      |rguenth at gcc dot 
gnu.org
             Status|NEW                         |ASSIGNED

--- Comment #3 from Richard Biener <rguenth at gcc dot gnu.org> ---
Ah, implementing the existing simplification properly fixes this, but only at
-O1.  At -O2 we have

        ((_277 == 2) AND (_79 == 0))
        OR ((NOT (_277 == 0)) AND (NOT (_277 > 2)) AND (NOT (_277 == 2)) AND
(_79 == 0))
        OR ((NOT (pretmp_300 == 255)) AND (_277 == 0) AND (NOT (_277 > 2)) AND
(NOT (_277 == 2)) AND (_79 == 0))

and

        ((_79 == 0))

and more upthread (the CFG is much more complicated).  In the above predicate
one can at least see

 (_277 == 0) AND (NOT (_277 > 2))  ->  (_277 == 0)

 (NOT (_277 > 2)) AND (NOT (_277 == 2)) -> (_277 < 2)

 (NOT (_277 > 2)) -> (_277 <= 2)  (might make !A vs. A more difficult)

kind of simplification opportunities.  The above doesn't seem to be the
predicate to simplify in the end though.

Implementing some of these simplifies this to

        ((_79 == 0) AND (_277 == 2))
        OR ((_79 == 0) AND (_277 <= 1) AND (NOT (_277 == 0)))
        OR ((_79 == 0) AND (_277 == 0) AND (NOT (pretmp_300 == 255)))

there's

  _84 = MEM[(const struct variant
*)this_69].D.41415.D.40957.D.40877.D.40745.D.40631.D.40535._M_index; 
  _115 = (signed char) _84;
  _277 = (long unsigned int) _115;

and

  pretmp_300 = MEM[(const struct _Variant_storage *)this_69]._M_index;

with pretmp_300 being unsigned char and _84 the same, so pretmp_300
and _277 are related and (_277 == 0) && !(pretmp_300 == 255) should
simplify to (_277 == 0) which really should make the last two
predicates to collapse(?) and then the rest to a single

  ((_79 == 0) AND (_277 <= 2)

?

Reply via email to