aboutsummaryrefslogtreecommitdiff
path: root/gcc/tree-cfg.c
diff options
context:
space:
mode:
authorTom de Vries <tdevries@suse.de>2020-10-07 07:22:53 +0200
committerTom de Vries <tdevries@suse.de>2020-10-14 14:37:03 +0200
commit17d5739a6b103cdd3315f5d0e09fe8faa6620a03 (patch)
treeb6f7b76c6622ee165aacb1e445fa7e54f14dd7a6 /gcc/tree-cfg.c
parent9068711f210e02a2b80f46813e47f338718c94dc (diff)
downloadgcc-17d5739a6b103cdd3315f5d0e09fe8faa6620a03.zip
gcc-17d5739a6b103cdd3315f5d0e09fe8faa6620a03.tar.gz
gcc-17d5739a6b103cdd3315f5d0e09fe8faa6620a03.tar.bz2
[gimple] Move can_duplicate_bb_p to gimple_can_duplicate_bb_p
The function gimple_can_duplicate_bb_p currently always returns true. The presence of can_duplicate_bb_p in tracer.c however suggests that there are cases when bb's indeed cannot be duplicated. Move the implementation of can_duplicate_bb_p to gimple_can_duplicate_bb_p. Bootstrapped and reg-tested on x86_64-linux. Build x86_64-linux with nvptx accelerator and tested libgomp. No issues found. As corner-case check, bootstrapped and reg-tested a patch that makes gimple_can_duplicate_bb_p always return false, resulting in PR97333 - "[gimple_can_duplicate_bb_p == false, tree-ssa-threadupdate] ICE in duplicate_block, at cfghooks.c:1093". gcc/ChangeLog: 2020-10-09 Tom de Vries <tdevries@suse.de> * tracer.c (cached_can_duplicate_bb_p, analyze_bb): Use can_duplicate_block_p. (can_duplicate_insn_p, can_duplicate_bb_no_insn_iter_p) (can_duplicate_bb_p): Move and merge ... * tree-cfg.c (gimple_can_duplicate_bb_p): ... here.
Diffstat (limited to 'gcc/tree-cfg.c')
-rw-r--r--gcc/tree-cfg.c38
1 files changed, 37 insertions, 1 deletions
diff --git a/gcc/tree-cfg.c b/gcc/tree-cfg.c
index 5caf3b6..002560d 100644
--- a/gcc/tree-cfg.c
+++ b/gcc/tree-cfg.c
@@ -6211,8 +6211,44 @@ gimple_split_block_before_cond_jump (basic_block bb)
/* Return true if basic_block can be duplicated. */
static bool
-gimple_can_duplicate_bb_p (const_basic_block bb ATTRIBUTE_UNUSED)
+gimple_can_duplicate_bb_p (const_basic_block bb)
{
+ gimple *last = last_stmt (CONST_CAST_BB (bb));
+
+ /* Do checks that can only fail for the last stmt, to minimize the work in the
+ stmt loop. */
+ if (last) {
+ /* A transaction is a single entry multiple exit region. It
+ must be duplicated in its entirety or not at all. */
+ if (gimple_code (last) == GIMPLE_TRANSACTION)
+ return false;
+
+ /* An IFN_UNIQUE call must be duplicated as part of its group,
+ or not at all. */
+ if (is_gimple_call (last)
+ && gimple_call_internal_p (last)
+ && gimple_call_internal_unique_p (last))
+ return false;
+ }
+
+ for (gimple_stmt_iterator gsi = gsi_start_bb (CONST_CAST_BB (bb));
+ !gsi_end_p (gsi); gsi_next (&gsi))
+ {
+ gimple *g = gsi_stmt (gsi);
+
+ /* An IFN_GOMP_SIMT_ENTER_ALLOC/IFN_GOMP_SIMT_EXIT call must be
+ duplicated as part of its group, or not at all.
+ The IFN_GOMP_SIMT_VOTE_ANY and IFN_GOMP_SIMT_XCHG_* are part of such a
+ group, so the same holds there. */
+ if (is_gimple_call (g)
+ && (gimple_call_internal_p (g, IFN_GOMP_SIMT_ENTER_ALLOC)
+ || gimple_call_internal_p (g, IFN_GOMP_SIMT_EXIT)
+ || gimple_call_internal_p (g, IFN_GOMP_SIMT_VOTE_ANY)
+ || gimple_call_internal_p (g, IFN_GOMP_SIMT_XCHG_BFLY)
+ || gimple_call_internal_p (g, IFN_GOMP_SIMT_XCHG_IDX)))
+ return false;
+ }
+
return true;
}