On 05/01/14 15:52, Marc Glisse wrote:
Hello,

here is the latest version. Reviewers seemed happy with different
versions, so I went for the simplest one. We only give up on the
transformation if we are optimizing for speed, the short-cut has
probability >50% and the operation the branch is avoiding is expensive
(i.e. only divisions, with the current estimate_num_insns). The optab
checks are gone, they should eventually be added to estimate_num_insns
instead.

I believe this is covered by the previous "ok", but I won't commit
anything before Tuesday.

It would have been more general (and shorter) to call fold after
substituting the tested value and see if the result matches the other
phi argument (it might handle (a!=b)?a|b:a for instance), instead of the
*_element_p tests. I may try that later, but I guess the current patch
is good enough for now.


2014-05-06  Marc Glisse  <marc.gli...@inria.fr>

     PR tree-optimization/59100
gcc/
     * tree-ssa-phiopt.c: Include tree-inline.h.
     (neutral_element_p, absorbing_element_p): New functions.
     (value_replacement): Handle conditional binary operations with a
     neutral or absorbing element.
gcc/testsuite/
     * gcc.dg/tree-ssa/phi-opt-12.c: New file.
     * gcc.dg/tree-ssa/phi-opt-13.c: Likewise.
Going with the simpler one is a good default IMHO. As you note, you can always follow-up with refinements if the additional cases turn out to be important.

OK for the trunk.

jeff

Reply via email to