This removes a premature and not working optimization from the
gimplifier. When gimplification is requested not to produce a SSA
name we try to avoid generating a copy when we did so anyway but
instead replace the LHS of its definition. But that only works in
case there are no uses of the SSA name already which is something
we cannot easily check, so the following removes said optimization.
Statistics on the whole bootstrap shows we hit this optimization
only for libiberty/cp-demangle.c and overall we have
21652112
gimplifications where just 240 copies are elided. Preserving
the optimization would require scanning the original expression
and the pre and post sequences for SSA names and uses, that seems
excessive to avoid these 240 copies.
2021-06-22 Richard Biener <rguenther@suse.de>
PR middle-end/101156
* gimplify.c (gimplify_expr): Remove premature incorrect
optimization.
* gcc.dg/pr101156.c: New testcase.
bool (*gimple_test_f) (tree), fallback_t fallback,
bool allow_ssa)
{
- bool was_ssa_name_p = TREE_CODE (*expr_p) == SSA_NAME;
enum gimplify_status ret = gimplify_expr (expr_p, pre_p, post_p,
gimple_test_f, fallback);
if (! allow_ssa
&& TREE_CODE (*expr_p) == SSA_NAME)
- {
- tree name = *expr_p;
- if (was_ssa_name_p)
- *expr_p = get_initialized_tmp_var (*expr_p, pre_p, NULL, false);
- else
- {
- /* Avoid the extra copy if possible. */
- *expr_p = create_tmp_reg (TREE_TYPE (name));
- if (!gimple_nop_p (SSA_NAME_DEF_STMT (name)))
- gimple_set_lhs (SSA_NAME_DEF_STMT (name), *expr_p);
- release_ssa_name (name);
- }
- }
+ *expr_p = get_initialized_tmp_var (*expr_p, pre_p, NULL, false);
return ret;
}
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-fchecking" } */
+
+struct S { int i; };
+void baz(struct S *p)
+{
+ __builtin_setjmp(p--);
+}