public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Andrew MacLeod <amacleod@redhat.com>
To: gcc-patches <gcc-patches@gcc.gnu.org>
Subject: [PATCH] tree-optimization/103464 - Also pre-process PHIs in range-of-stmt.
Date: Tue, 30 Nov 2021 09:33:14 -0500	[thread overview]
Message-ID: <ed0547a3-7690-d327-b8a8-7dff7f9425c4@redhat.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 465 bytes --]

When I flatten the call stack for range_of_stmt in PR 103231 ( 
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=103231 ), I mention that I 
was only flattening it for chains of statements with range handlers. If 
it turned out that PHI chaining was also a problem, we could also do PHIs.

The cost to do phis is quite nominal, and resolve this testcase...  so 
we might as well do PHIs as well.

Bootstrapped on x86_64-pc-linux-gnu with no regressions.  OK?

Andrew

[-- Attachment #2: 464.diff --]
[-- Type: text/x-patch, Size: 2058 bytes --]

commit 99b0f5f03a04fd342461a67287d81250f86f0586
Author: Andrew MacLeod <amacleod@redhat.com>
Date:   Mon Nov 29 12:00:26 2021 -0500

    Also pre-process PHIs in range-of-stmt.
    
            PR tree-optimization/103464
            * gimple-range.cc (gimple_ranger::prefill_name): Process phis also.
            (gimple_ranger::prefill_stmt_dependencies): Ditto.

diff --git a/gcc/gimple-range.cc b/gcc/gimple-range.cc
index 178a470a419..c8431a7180b 100644
--- a/gcc/gimple-range.cc
+++ b/gcc/gimple-range.cc
@@ -333,7 +333,7 @@ gimple_ranger::prefill_name (irange &r, tree name)
   if (!gimple_range_ssa_p (name))
     return;
   gimple *stmt = SSA_NAME_DEF_STMT (name);
-  if (!gimple_range_handler (stmt))
+  if (!gimple_range_handler (stmt) && !is_a<gphi *> (stmt))
     return;
 
   bool current;
@@ -356,8 +356,8 @@ gimple_ranger::prefill_stmt_dependencies (tree ssa)
   gimple *stmt = SSA_NAME_DEF_STMT (ssa);
   gcc_checking_assert (stmt && gimple_bb (stmt));
 
-  // Only pre-process range-ops.
-  if (!gimple_range_handler (stmt))
+  // Only pre-process range-ops and phis.
+  if (!gimple_range_handler (stmt) && !is_a<gphi *> (stmt))
     return;
 
   // Mark where on the stack we are starting.
@@ -401,13 +401,22 @@ gimple_ranger::prefill_stmt_dependencies (tree ssa)
 	  print_gimple_stmt (dump_file, stmt, 0, TDF_SLIM);
 	}
 
-      gcc_checking_assert (gimple_range_handler (stmt));
-      tree op = gimple_range_operand2 (stmt);
-      if (op)
-	prefill_name (r, op);
-      op = gimple_range_operand1 (stmt);
-      if (op)
-	prefill_name (r, op);
+      gphi *phi = dyn_cast <gphi *> (stmt);
+      if (phi)
+	{
+	  for (unsigned x = 0; x < gimple_phi_num_args (phi); x++)
+	    prefill_name (r, gimple_phi_arg_def (phi, x));
+	}
+      else
+	{
+	  gcc_checking_assert (gimple_range_handler (stmt));
+	  tree op = gimple_range_operand2 (stmt);
+	  if (op)
+	    prefill_name (r, op);
+	  op = gimple_range_operand1 (stmt);
+	  if (op)
+	    prefill_name (r, op);
+	}
     }
   if (idx)
     tracer.trailer (idx, "ROS ", false, ssa, r);

             reply	other threads:[~2021-11-30 14:34 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-30 14:33 Andrew MacLeod [this message]
2021-12-01  8:50 ` Richard Biener

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ed0547a3-7690-d327-b8a8-7dff7f9425c4@redhat.com \
    --to=amacleod@redhat.com \
    --cc=gcc-patches@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).