diff mbox series

phiopt: Move check for maybe_undef_p slightly earlier

Message ID 20241027234142.218355-1-quic_apinski@quicinc.com
State New
Headers show
Series phiopt: Move check for maybe_undef_p slightly earlier | expand

Commit Message

Andrew Pinski Oct. 27, 2024, 11:41 p.m. UTC
This moves the check for maybe_undef_p in match_simplify_replacement
slightly earlier before figuring out the true/false arg using arg0/arg1
instead.
In most cases this is no difference in compile time; just in the case
there is an undef in the args there would be a slight compile time
improvement as there is no reason to figure out which arg corresponds
to the true/false side of the conditional.

Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

	* tree-ssa-phiopt.cc (match_simplify_replacement): Move
	check for maybe_undef_p earlier.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
---
 gcc/tree-ssa-phiopt.cc | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

Comments

Richard Biener Oct. 28, 2024, 8:13 a.m. UTC | #1
On Mon, Oct 28, 2024 at 12:42 AM Andrew Pinski <quic_apinski@quicinc.com> wrote:
>
> This moves the check for maybe_undef_p in match_simplify_replacement
> slightly earlier before figuring out the true/false arg using arg0/arg1
> instead.
> In most cases this is no difference in compile time; just in the case
> there is an undef in the args there would be a slight compile time
> improvement as there is no reason to figure out which arg corresponds
> to the true/false side of the conditional.

OK.

> Bootstrapped and tested on x86_64-linux-gnu.
>
> gcc/ChangeLog:
>
>         * tree-ssa-phiopt.cc (match_simplify_replacement): Move
>         check for maybe_undef_p earlier.
>
> Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
> ---
>  gcc/tree-ssa-phiopt.cc | 14 +++++++-------
>  1 file changed, 7 insertions(+), 7 deletions(-)
>
> diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc
> index f8b119ea836..cffafe101a4 100644
> --- a/gcc/tree-ssa-phiopt.cc
> +++ b/gcc/tree-ssa-phiopt.cc
> @@ -943,6 +943,13 @@ match_simplify_replacement (basic_block cond_bb, basic_block middle_bb,
>                                           stmt_to_move_alt))
>      return false;
>
> +  /* Do not make conditional undefs unconditional.  */
> +  if ((TREE_CODE (arg0) == SSA_NAME
> +       && ssa_name_maybe_undef_p (arg0))
> +      || (TREE_CODE (arg1) == SSA_NAME
> +         && ssa_name_maybe_undef_p (arg1)))
> +    return false;
> +
>      /* At this point we know we have a GIMPLE_COND with two successors.
>       One successor is BB, the other successor is an empty block which
>       falls through into BB.
> @@ -982,13 +989,6 @@ match_simplify_replacement (basic_block cond_bb, basic_block middle_bb,
>        arg_false = arg0;
>      }
>
> -  /* Do not make conditional undefs unconditional.  */
> -  if ((TREE_CODE (arg_true) == SSA_NAME
> -       && ssa_name_maybe_undef_p (arg_true))
> -      || (TREE_CODE (arg_false) == SSA_NAME
> -         && ssa_name_maybe_undef_p (arg_false)))
> -    return false;
> -
>    tree type = TREE_TYPE (gimple_phi_result (phi));
>    {
>      auto_flow_sensitive s1(stmt_to_move);
> --
> 2.43.0
>
diff mbox series

Patch

diff --git a/gcc/tree-ssa-phiopt.cc b/gcc/tree-ssa-phiopt.cc
index f8b119ea836..cffafe101a4 100644
--- a/gcc/tree-ssa-phiopt.cc
+++ b/gcc/tree-ssa-phiopt.cc
@@ -943,6 +943,13 @@  match_simplify_replacement (basic_block cond_bb, basic_block middle_bb,
 					  stmt_to_move_alt))
     return false;
 
+  /* Do not make conditional undefs unconditional.  */
+  if ((TREE_CODE (arg0) == SSA_NAME
+       && ssa_name_maybe_undef_p (arg0))
+      || (TREE_CODE (arg1) == SSA_NAME
+	  && ssa_name_maybe_undef_p (arg1)))
+    return false;
+
     /* At this point we know we have a GIMPLE_COND with two successors.
      One successor is BB, the other successor is an empty block which
      falls through into BB.
@@ -982,13 +989,6 @@  match_simplify_replacement (basic_block cond_bb, basic_block middle_bb,
       arg_false = arg0;
     }
 
-  /* Do not make conditional undefs unconditional.  */
-  if ((TREE_CODE (arg_true) == SSA_NAME
-       && ssa_name_maybe_undef_p (arg_true))
-      || (TREE_CODE (arg_false) == SSA_NAME
-	  && ssa_name_maybe_undef_p (arg_false)))
-    return false;
-
   tree type = TREE_TYPE (gimple_phi_result (phi));
   {
     auto_flow_sensitive s1(stmt_to_move);