This is the mail archive of the
mailing list for the GCC project.
Re: [PATCH] Factor out gimple_dont_merge_p
- From: Tom de Vries <Tom_deVries at mentor dot com>
- To: Richard Biener <rguenther at suse dot de>
- Cc: <gcc-patches at gcc dot gnu dot org>
- Date: Wed, 13 Nov 2013 12:24:54 +0100
- Subject: Re: [PATCH] Factor out gimple_dont_merge_p
- Authentication-results: sourceware.org; auth=none
- References: <527E590A dot 9060608 at mentor dot com> <alpine dot LNX dot 2 dot 00 dot 1311111035000 dot 4261 at zhemvz dot fhfr dot qr>
On 11-11-13 10:37, Richard Biener wrote:
On Sat, 9 Nov 2013, Tom de Vries wrote:
This patch factors out gimple_dont_merge_p from gimple_equal_p and
Bootstrapped and regtested on x86_64.
OK for trunk?
+gimple_dont_merge_p (gimple stmt)
+ switch (gimple_code (stmt))
+ case GIMPLE_CALL:
+ /* Eventually, we'll significantly complicate the CFG by adding
+ back edges to properly model the effects of transaction restart.
+ For the bulk of optimization this does not matter, but what we
+ cannot recover from is tail merging blocks between two separate
+ transactions. Avoid that by making commit not match. */
+ if (gimple_call_builtin_p (stmt, BUILT_IN_TM_COMMIT))
+ return true;
+ /* We cannot tail-merge the builtins that end transactions.
+ ??? The alternative being unsharing of BBs in the tm_init pass.
+ if (flag_tm
+ && (gimple_call_flags (stmt) & ECF_TM_BUILTIN)
+ && is_tm_ending_fndecl (gimple_call_fndecl (stmt)))
+ return true;
1) BUILT_IN_TM_COMMIT is handled in is_tm_ending_fndecl,
2) fndecl may be NULL
I'd simply get rid of gimple_dont_merge_p and call a
is_tm_ending (gimple) function you'd add to TM.
I've update the patch according to comments, bootstrapped and reg-tested.
OK for trunk?
2013-11-06 Tom de Vries <email@example.com>
* trans-mem.c (is_tm_ending): New function.
* gimple.h (is_tm_ending): Declare.
* tree-ssa-tail-merge.c (gimple_equal_p): Remove test on
(find_duplicate): Use is_tm_ending instead of is_tm_ending_fndecl.
diff --git a/gcc/gimple.h b/gcc/gimple.h
index 33e790c..8f902b9 100644
@@ -1043,6 +1043,7 @@ extern bool infer_nonnull_range (gimple, tree);
/* In trans-mem.c. */
extern void diagnose_tm_safe_errors (tree);
extern void compute_transaction_bits (void);
+extern bool is_tm_ending (gimple);
/* In tree-nested.c. */
extern void lower_nested_functions (tree);
diff --git a/gcc/trans-mem.c b/gcc/trans-mem.c
index 784ff24..7dca40e 100644
@@ -321,6 +321,22 @@ is_tm_ending_fndecl (tree fndecl)
+/* Return true if STMT is a built in function call that "ends" a
+ transaction. */
+is_tm_ending (gimple stmt)
+ tree fndecl;
+ if (gimple_code (stmt) != GIMPLE_CALL)
+ return false;
+ fndecl = gimple_call_fndecl (stmt);
+ return (fndecl != NULL_TREE
+ && is_tm_ending_fndecl (fndecl));
/* Return true if STMT is a TM load. */
diff --git a/gcc/tree-ssa-tail-merge.c b/gcc/tree-ssa-tail-merge.c
index 00dd071..15356bd 100644
@@ -1099,14 +1099,6 @@ gimple_equal_p (same_succ same_succ, gimple s1, gimple s2)
if (!gimple_call_same_target_p (s1, s2))
- /* Eventually, we'll significantly complicate the CFG by adding
- back edges to properly model the effects of transaction restart.
- For the bulk of optimization this does not matter, but what we
- cannot recover from is tail merging blocks between two separate
- transactions. Avoid that by making commit not match. */
- if (gimple_call_builtin_p (s1, BUILT_IN_TM_COMMIT))
- return false;
for (i = 0; i < gimple_call_num_args (s1); ++i)
t1 = gimple_call_arg (s1, i);
@@ -1220,15 +1212,14 @@ find_duplicate (same_succ same_succ, basic_block bb1, basic_block bb2)
gimple stmt1 = gsi_stmt (gsi1);
gimple stmt2 = gsi_stmt (gsi2);
- if (!gimple_equal_p (same_succ, stmt1, stmt2))
+ /* What could be better than to this this here is to blacklist the bb
+ containing the stmt, when encountering the stmt f.i. in
+ same_succ_hash. */
+ if (is_tm_ending (stmt1)
+ || is_tm_ending (stmt2))
- // We cannot tail-merge the builtins that end transactions.
- // ??? The alternative being unsharing of BBs in the tm_init pass.
- if (flag_tm
- && is_gimple_call (stmt1)
- && (gimple_call_flags (stmt1) & ECF_TM_BUILTIN)
- && is_tm_ending_fndecl (gimple_call_fndecl (stmt1)))
+ if (!gimple_equal_p (same_succ, stmt1, stmt2))