aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBin Cheng <amker@gcc.gnu.org>2017-12-01 14:33:03 +0000
committerBin Cheng <amker@gcc.gnu.org>2017-12-01 14:33:03 +0000
commit405a28c95dab82fa68436cffa12fb65e476e216c (patch)
tree8e09e28bf569dea1f51afaf524bea6fe4de9ff5b
parent4c557c22f4b7889652b1cac45a1ce777e362210c (diff)
downloadgcc-405a28c95dab82fa68436cffa12fb65e476e216c.zip
gcc-405a28c95dab82fa68436cffa12fb65e476e216c.tar.gz
gcc-405a28c95dab82fa68436cffa12fb65e476e216c.tar.bz2
gimple-loop-interchange.cc (is-a.h): New header file.
2017-12-01 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. From-SVN: r255310
-rw-r--r--gcc/gimple-loop-interchange.cc25
1 files changed, 7 insertions, 18 deletions
diff --git a/gcc/gimple-loop-interchange.cc b/gcc/gimple-loop-interchange.cc
index d5a39a0..21dbdec 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