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

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

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |law at gcc dot gnu.org,
                   |                            |rguenth at gcc dot gnu.org

--- Comment #2 from Richard Biener <rguenth at gcc dot gnu.org> ---
Similar reason as PR68625.  So we need to go a step further only allowing
"trivial" dead code and thus skip

        case GIMPLE_COND:
          {
            code_helper rcode;
            tree ops[3] = {};
            if (gimple_simplify (stmt, &rcode, ops, NULL, no_follow_ssa_edges,
                                 no_follow_ssa_edges)
                && rcode == INTEGER_CST)
              val = ops[0];

Skip as in use const_binop (condition) [note that doing this change always will
regress things]

Hmm, but doing const_binop in the "first" iteration only makes the situation
less likely in following ones (and we'd need to unconditonally iterate at least
once).

Conceptually doing only const_binob above would be the right thing to do (TM)
but as said it regressed (just place an assert above).

Note the above call doesn't need to follow SSA edges to hit the issue but
h_1 in h_1 != 0 is already released (its def stmt is released and is not
dominating this use as DOM figured out one edge was not executable)

Note that DOM does

Optimizing block #15

LKUP STMT .MEM_35 = PHI <.MEM_8, .MEM_19>
2>>> STMT .MEM_35 = PHI <.MEM_8, .MEM_19>
<<<< STMT .MEM_35 = PHI <.MEM_8, .MEM_19>
Optimizing statement a = 0;
LKUP STMT a = 0 with .MEM_35
LKUP STMT 0 = a with .MEM_35
LKUP STMT 0 = a with .MEM_12
2>>> STMT 0 = a with .MEM_12
Optimizing statement a.8_30 = a;
LKUP STMT a.8_30 = a with .MEM_12
FIND: 0
  Replaced redundant expr 'a' with '0'
==== ASGN a.8_30 = 0
Optimizing statement if (a.8_30 <= 0)
  Replaced 'a.8_30' with constant '0'
gimple_simplified to if (1 != 0)
  Folded to: if (1 != 0)
LKUP STMT 1 ne_expr 0

...

Optimizing block #10

so this is the usual dominator-iteration doesn't see #10 is unreachable
because #9 is not yet visited.

Eventually a pass over all BBs _after_ the domwalk and then forcefully
"simplifying" conditions in unreachable regions might be a workaround.

OTOH we really should work toward being able to do the right thing (TM)
in cfg-cleanup...

Reply via email to