https://gcc.gnu.org/g:71a578ec8c1083db800d5a527e65c73f9105c05b
commit r16-8427-g71a578ec8c1083db800d5a527e65c73f9105c05b Author: Andrew Pinski <[email protected]> Date: Wed Apr 1 10:35:57 2026 -0700 phiprop: Move the check for load of ptr before the checks of dom This moves the check for thge load of *ptr before the checks of domination. In the next patch I need to know if the load is an aggregates or not. This should NOT have any code generation difference. Bootstrapped and tested on x86_64-linux-gnu. gcc/ChangeLog: * tree-ssa-phiprop.cc (propagate_with_phi): Move the check for load from ptr before the checks of domination. Signed-off-by: Andrew Pinski <[email protected]> Diff: --- gcc/tree-ssa-phiprop.cc | 38 +++++++++++++++++++------------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/gcc/tree-ssa-phiprop.cc b/gcc/tree-ssa-phiprop.cc index d244d6457e55..ca8c7cfe04d0 100644 --- a/gcc/tree-ssa-phiprop.cc +++ b/gcc/tree-ssa-phiprop.cc @@ -339,6 +339,25 @@ propagate_with_phi (basic_block bb, gphi *vphi, gphi *phi, tree vuse; bool delay = false; + /* Check whether this is a load of *ptr. */ + if (!(is_gimple_assign (use_stmt) + && gimple_assign_rhs_code (use_stmt) == MEM_REF + && TREE_OPERAND (gimple_assign_rhs1 (use_stmt), 0) == ptr + && integer_zerop (TREE_OPERAND (gimple_assign_rhs1 (use_stmt), 1)) + && (!type + || types_compatible_p + (TREE_TYPE (gimple_assign_lhs (use_stmt)), type)) + /* We cannot replace a load that may throw or is volatile. + For volatiles the transform can change the number of + executions if the load is inside a loop but the address + computations outside (PR91812). We could relax this + if we guard against that appropriately. For loads that can + throw we could relax things if the moved loads all are + known to not throw. */ + && !stmt_can_throw_internal (cfun, use_stmt) + && !gimple_has_volatile_ops (use_stmt))) + continue; + if (canpossible_trap && !dom_info_available_p (cfun, CDI_POST_DOMINATORS)) calculate_dominance_info (CDI_POST_DOMINATORS); @@ -361,25 +380,6 @@ propagate_with_phi (basic_block bb, gphi *vphi, gphi *phi, gimple_bb (use_stmt)->loop_father))))) delay = true; - /* Check whether this is a load of *ptr. */ - if (!(is_gimple_assign (use_stmt) - && gimple_assign_rhs_code (use_stmt) == MEM_REF - && TREE_OPERAND (gimple_assign_rhs1 (use_stmt), 0) == ptr - && integer_zerop (TREE_OPERAND (gimple_assign_rhs1 (use_stmt), 1)) - && (!type - || types_compatible_p - (TREE_TYPE (gimple_assign_lhs (use_stmt)), type)) - /* We cannot replace a load that may throw or is volatile. - For volatiles the transform can change the number of - executions if the load is inside a loop but the address - computations outside (PR91812). We could relax this - if we guard against that appropriately. For loads that can - throw we could relax things if the moved loads all are - known to not throw. */ - && !stmt_can_throw_internal (cfun, use_stmt) - && !gimple_has_volatile_ops (use_stmt))) - continue; - /* Check if we can move the loads. This is when the virtual use is the same as the one active at the start of BB which we know either from its virtual PHI def or from the common incoming
