This is the first step in handling the review part of:
https://gcc.gnu.org/pipermail/gcc-patches/2025-August/692091.html
'''
Oh, as we now do alias walks in forwprop maybe we should make this
conditional and do
this not for all pass instances, since it makes forwprop possibly a lot slower?
'''

The check of the limit was after the alias check which could slow down things.
This moves the check of the limit to begining of the if.

Bootstrapped and tested on x86_64-linux-gnu.

Pushed as obvious.

        PR tree-optimization/121474
gcc/ChangeLog:

        * tree-ssa-forwprop.cc (optimize_aggr_zeroprop): Move the check
        for limit before the alias check.

Signed-off-by: Andrew Pinski <andrew.pin...@oss.qualcomm.com>
---
 gcc/tree-ssa-forwprop.cc | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/gcc/tree-ssa-forwprop.cc b/gcc/tree-ssa-forwprop.cc
index 0ccdd6aba9f..ec4fbeb9e54 100644
--- a/gcc/tree-ssa-forwprop.cc
+++ b/gcc/tree-ssa-forwprop.cc
@@ -1401,10 +1401,10 @@ optimize_aggr_zeroprop (gimple_stmt_iterator *gsip)
 
          /* If this statement does not clobber add the vdef stmt to the
             worklist.  */
-         if (gimple_vdef (use_stmt)
+         if (limit != 0
+             && gimple_vdef (use_stmt)
              && !stmt_may_clobber_ref_p_1 (use_stmt, &read,
-                                          /* tbaa_p = */ can_use_tbba)
-             && limit != 0)
+                                          /* tbaa_p = */ can_use_tbba))
            worklist.safe_push (std::make_pair (gimple_vdef (use_stmt),
                                                limit - 1));
 
-- 
2.43.0

Reply via email to