public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH branch/gimple-linterchange]Use dyn_cast instread of is_a<> and as_a<>
@ 2017-12-01 10:53 Bin Cheng
  2017-12-01 11:51 ` Richard Biener
  0 siblings, 1 reply; 2+ messages in thread
From: Bin Cheng @ 2017-12-01 10:53 UTC (permalink / raw)
  To: gcc-patches; +Cc: nd, dmalcolm

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

Hi,
This is a simple patch using dyn_cast instead of is_a<> and as_a<> as suggested by review.
This is for branches/gimple-linterchange, bootstrap and test as when the branch is created.  Is it OK?

Thanks,
bin
2017-11-30  Bin Cheng  <bin.cheng@arm.com>

	* gimple-loop-interchange.cc (is-a.h): New header file.
	(loop_cand::find_reduction_by_stmt): Use dyn_cast instead of is_a<>
	and as_a<>.
	(loop_cand::analyze_iloop_reduction_var): Ditto.
	(loop_cand::analyze_oloop_reduction_var): Ditto.  Check gimple stmt
	against phi node directly.

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0040-dyn_cast.patch --]
[-- Type: text/x-patch; name="0040-dyn_cast.patch", Size: 2298 bytes --]

From 88ddf90ee183f2e58bb5d4b38d14733412603b44 Mon Sep 17 00:00:00 2001
From: Bin Cheng <binche01@e108451-lin.cambridge.arm.com>
Date: Wed, 29 Nov 2017 11:23:52 +0000
Subject: [PATCH 40/42] dyn_cast

---
 gcc/gimple-loop-interchange.cc | 25 +++++++------------------
 1 file changed, 7 insertions(+), 18 deletions(-)

diff --git a/gcc/gimple-loop-interchange.cc b/gcc/gimple-loop-interchange.cc
index 7afafb8..e999822 100644
--- a/gcc/gimple-loop-interchange.cc
+++ b/gcc/gimple-loop-interchange.cc
@@ -22,6 +22,7 @@ along with GCC; see the file COPYING3.  If not see
 #include "system.h"
 #include "coretypes.h"
 #include "backend.h"
+#include "is-a.h"
 #include "tree.h"
 #include "gimple.h"
 #include "tree-pass.h"
@@ -270,12 +271,9 @@ unsupported_edge (edge e)
 reduction_p
 loop_cand::find_reduction_by_stmt (gimple *stmt)
 {
-  gphi *phi = NULL;
+  gphi *phi = dyn_cast <gphi *> (stmt);
   reduction_p re;
 
-  if (is_a <gphi *> (stmt))
-    phi = as_a <gphi *> (stmt);
-
   for (unsigned i = 0; m_reductions.iterate (i, &re); ++i)
     if ((phi != NULL && phi == re->lcssa_phi)
 	|| (stmt == re->producer || stmt == re->consumer))
@@ -591,10 +589,8 @@ loop_cand::analyze_iloop_reduction_var (tree var)
 	continue;
 
       /* Or else it's used in PHI itself.  */
-      use_phi = NULL;
-      if (is_a <gphi *> (stmt)
-	  && (use_phi = as_a <gphi *> (stmt)) != NULL
-	  && use_phi == phi)
+      use_phi = dyn_cast <gphi *> (stmt);
+      if (use_phi == phi)
 	continue;
 
       if (use_phi != NULL
@@ -684,12 +680,7 @@ loop_cand::analyze_oloop_reduction_var (loop_cand *iloop, tree var)
       if (is_gimple_debug (stmt))
 	continue;
 
-      if (!flow_bb_inside_loop_p (m_loop, gimple_bb (stmt)))
-	return false;
-
-      if (! is_a <gphi *> (stmt)
-	  || (use_phi = as_a <gphi *> (stmt)) == NULL
-	  || use_phi != inner_re->phi)
+      if (stmt != inner_re->phi)
 	return false;
     }
 
@@ -701,10 +692,8 @@ loop_cand::analyze_oloop_reduction_var (loop_cand *iloop, tree var)
 	continue;
 
       /* Or else it's used in PHI itself.  */
-      use_phi = NULL;
-      if (is_a <gphi *> (stmt)
-	  && (use_phi = as_a <gphi *> (stmt)) != NULL
-	  && use_phi == phi)
+      use_phi = dyn_cast <gphi *> (stmt);
+      if (use_phi == phi)
 	continue;
 
       if (lcssa_phi == NULL
-- 
1.9.1


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [PATCH branch/gimple-linterchange]Use dyn_cast instread of is_a<> and as_a<>
  2017-12-01 10:53 [PATCH branch/gimple-linterchange]Use dyn_cast instread of is_a<> and as_a<> Bin Cheng
@ 2017-12-01 11:51 ` Richard Biener
  0 siblings, 0 replies; 2+ messages in thread
From: Richard Biener @ 2017-12-01 11:51 UTC (permalink / raw)
  To: Bin Cheng; +Cc: gcc-patches, nd, dmalcolm

On Fri, Dec 1, 2017 at 11:53 AM, Bin Cheng <Bin.Cheng@arm.com> wrote:
> Hi,
> This is a simple patch using dyn_cast instead of is_a<> and as_a<> as suggested by review.
> This is for branches/gimple-linterchange, bootstrap and test as when the branch is created.  Is it OK?

Ok.

Richard.



> Thanks,
> bin
> 2017-11-30  Bin Cheng  <bin.cheng@arm.com>
>
>         * gimple-loop-interchange.cc (is-a.h): New header file.
>         (loop_cand::find_reduction_by_stmt): Use dyn_cast instead of is_a<>
>         and as_a<>.
>         (loop_cand::analyze_iloop_reduction_var): Ditto.
>         (loop_cand::analyze_oloop_reduction_var): Ditto.  Check gimple stmt
>         against phi node directly.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2017-12-01 11:51 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-12-01 10:53 [PATCH branch/gimple-linterchange]Use dyn_cast instread of is_a<> and as_a<> Bin Cheng
2017-12-01 11:51 ` Richard Biener

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).