http://gcc.gnu.org/bugzilla/show_bug.cgi?id=61110

            Bug ID: 61110
           Summary: Simplify value_replacement in phiopt
           Product: gcc
           Version: 4.10.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: tree-optimization
          Assignee: unassigned at gcc dot gnu.org
          Reporter: glisse at gcc dot gnu.org

The patch for PR 59100 introduced 2 functions neutral_element_p and
absorbing_element_p. I don't know why I did that. When we see:
(x != 0) ? x + y : y
instead of asking if 0 is a neutral element of + on the left, it is easier to
try to fold "0 + y" (I replaced x with the rhs of the comparison) and check if
that matches "y". This handles neutral and absorbing as a single case and is
even more general (we could also do it for the non-constant case: (x!=y) ? x|y
: x). We could even imagine generalizing it to the case where middle_bb has 2
or 3 statements (but the cost analysis may need to be refined then).

I probably won't do it immediately (the current code works) but I didn't want
this idea to be forgotten.

Reply via email to