[gcc(refs/users/marxin/heads/loop-unswitch-improvement-v7)] Simplify a bit.
Martin Liska
marxin@gcc.gnu.org
Thu Dec 9 12:47:46 GMT 2021
https://gcc.gnu.org/g:26a704a8081e834c2ce67142df3aece8e65c78af
commit 26a704a8081e834c2ce67142df3aece8e65c78af
Author: Martin Liska <mliska@suse.cz>
Date: Tue Nov 30 17:30:16 2021 +0100
Simplify a bit.
Diff:
---
gcc/tree-ssa-loop-unswitch.c | 46 ++++++++++++++++++++------------------------
1 file changed, 21 insertions(+), 25 deletions(-)
diff --git a/gcc/tree-ssa-loop-unswitch.c b/gcc/tree-ssa-loop-unswitch.c
index 10804cf4b1e..bd71e9d9fbd 100644
--- a/gcc/tree-ssa-loop-unswitch.c
+++ b/gcc/tree-ssa-loop-unswitch.c
@@ -42,8 +42,6 @@ along with GCC; see the file COPYING3. If not see
#include "gimple-range.h"
#include "dbgcnt.h"
-#include <utility>
-
/* This file implements the loop unswitching, i.e. transformation of loops like
while (A)
@@ -475,32 +473,30 @@ evaluate_insns (class loop *loop, basic_block *bbs,
int flags = 0;
basic_block bb = worklist.pop ();
- if (EDGE_COUNT (bb->succs) == 2)
+ gimple *last = last_stmt (bb);
+ gcond *cond = last != NULL ? dyn_cast<gcond *> (last) : NULL;
+ if (cond != NULL)
{
- gcond *cond = dyn_cast<gcond *> (last_stmt (bb));
- if (cond != NULL)
+ if (gimple_cond_true_p (cond))
+ flags = EDGE_FALSE_VALUE;
+ else if (gimple_cond_false_p (cond))
+ flags = EDGE_TRUE_VALUE;
+ else
{
- if (gimple_cond_true_p (cond))
- flags = EDGE_FALSE_VALUE;
- else if (gimple_cond_false_p (cond))
- flags = EDGE_TRUE_VALUE;
- else
+ // FIXME: works only for gconds
+ unswitch_predicate *predicate = NULL;
+ if (!get_predicates_for_bb (bb).is_empty ())
+ predicate = get_predicates_for_bb (bb)[0];
+
+ if (predicate != NULL)
{
- // FIXME: works only for gconds
- unswitch_predicate *predicate = NULL;
- if (!get_predicates_for_bb (bb).is_empty ())
- predicate = get_predicates_for_bb (bb)[0];
-
- if (predicate != NULL)
- {
- tree folded
- = evaluate_control_stmt_using_entry_checks (cond,
- predicate_path);
- if (folded == boolean_true_node)
- flags = EDGE_FALSE_VALUE;
- else if (folded == boolean_false_node)
- flags = EDGE_TRUE_VALUE;
- }
+ tree folded
+ = evaluate_control_stmt_using_entry_checks (cond,
+ predicate_path);
+ if (folded == boolean_true_node)
+ flags = EDGE_FALSE_VALUE;
+ else if (folded == boolean_false_node)
+ flags = EDGE_TRUE_VALUE;
}
}
}
More information about the Gcc-cvs
mailing list