https://gcc.gnu.org/g:8e3eff39a4564c76e3b12ae30e370f48200f962c

commit r17-1238-g8e3eff39a4564c76e3b12ae30e370f48200f962c
Author: Richard Sandiford <[email protected]>
Date:   Tue Jun 2 20:50:27 2026 +0100

    backprop: Move opt-out for abnormal edges
    
    r6-6843-ga864ad5ba2501d made sure that optimize_phi wouldn't
    optimise phi inputs for abnormal edges.  See:
    
      https://gcc.gnu.org/pipermail/gcc-patches/2016-February/441902.html
    
    for a description of the symptoms.
    
    That was the best place to put the check at the time, and still is
    as things stand.  However, a later patch will rename all statements
    that might change value, with no opt-out possible once the process
    has started.  If a phi input's value has changed, then it must be
    replaced no matter what.
    
    This patch therefore moves the check to the analysis phase.
    
    gcc/
            * gimple-ssa-backprop.cc (backprop::process_var): Don't try to
            optimize SSA names that occur as a phi input for an abnormal edge,
            moving the restriction from...
            (backprop::optimize_phi): ...here.

Diff:
---
 gcc/gimple-ssa-backprop.cc | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/gcc/gimple-ssa-backprop.cc b/gcc/gimple-ssa-backprop.cc
index 3ac44116d271..c1899af117b7 100644
--- a/gcc/gimple-ssa-backprop.cc
+++ b/gcc/gimple-ssa-backprop.cc
@@ -575,6 +575,10 @@ backprop::process_var (tree var)
   if (has_zero_uses (var))
     return;
 
+  /* Propagating along abnormal edges is delicate, punt for now.  */
+  if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (var))
+    return;
+
   usage_info info;
   intersect_uses (var, &info);
 
@@ -853,21 +857,15 @@ backprop::optimize_assign (gassign *assign, tree lhs, 
const usage_info *info)
 void
 backprop::optimize_phi (gphi *phi, tree var, const usage_info *info)
 {
-  /* If the sign of the result doesn't matter, try to strip sign operations
-     from arguments.  */
+  /* If the sign of the result doesn't matter, strip sign operations
+     from all arguments.  */
   if (info->flags.ignore_sign)
     {
-      basic_block bb = gimple_bb (phi);
       use_operand_p use;
       ssa_op_iter oi;
       bool replaced = false;
       FOR_EACH_PHI_ARG (use, phi, oi, SSA_OP_USE)
        {
-         /* Propagating along abnormal edges is delicate, punt for now.  */
-         const int index = PHI_ARG_INDEX_FROM_USE (use);
-         if (EDGE_PRED (bb, index)->flags & EDGE_ABNORMAL)
-           continue;
-
          tree new_arg = strip_sign_op (USE_FROM_PTR (use));
          if (new_arg)
            {

Reply via email to