]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
forwprop: Refine when TODO_update_address_taken is set [PR122143]
authorAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Sat, 4 Oct 2025 00:51:33 +0000 (17:51 -0700)
committerAndrew Pinski <andrew.pinski@oss.qualcomm.com>
Sat, 4 Oct 2025 16:29:40 +0000 (09:29 -0700)
As requested in https://inbox.sourceware.org/gcc-patches/CAFiYyc162F+i=majzQqutFcq1y=DtRoJVC4z+V3gP8N7uTnFLA@mail.gmail.com/T/#u.
This refines when TODO_update_address_taken is set so it only set when folding of a call.
This should speed up compile time slightly if we don't fold a call during the last forwprop.

Boostrapped and tested on x86_64-linux-gnu.

PR tree-optimization/122143
gcc/ChangeLog:

* tree-ssa-forwprop.cc (pass_forwprop::execute): Restrict setting
TODO_update_address_taken only when the statement was a call before fold_stmt.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
gcc/tree-ssa-forwprop.cc

index 2c6e1eab9cdbfa27338963232e6bf1980acd46e0..ad09f7334cc645f200504a82fbcc6ba6b967fc4a 100644 (file)
@@ -5451,7 +5451,8 @@ pass_forwprop::execute (function *fun)
          do
            {
              gimple *orig_stmt = stmt = gsi_stmt (gsi);
-             bool was_noreturn = (is_gimple_call (stmt)
+             bool was_call = is_gimple_call (stmt);
+             bool was_noreturn = (was_call
                                   && gimple_call_noreturn_p (stmt));
              changed = false;
 
@@ -5465,8 +5466,10 @@ pass_forwprop::execute (function *fun)
                  changed = true;
                  /* There is no updating of the address
                     taken after the last forwprop so update
-                    the addresses when a folding happened. */
-                 if (last_p)
+                    the addresses when a folding happened to a call.
+                    The va_* builtins can remove taking of the address so
+                    can the sincos->cexpi transformation.  See PR 39643 and PR 20983. */
+                 if (was_call && last_p)
                    todoflags |= TODO_update_address_taken;
                  stmt = gsi_stmt (gsi);
                  /* Cleanup the CFG if we simplified a condition to