https://gcc.gnu.org/bugzilla/show_bug.cgi?id=27800
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |ASSIGNED Assignee|unassigned at gcc dot gnu.org |rguenth at gcc dot gnu.org --- Comment #4 from Richard Biener <rguenth at gcc dot gnu.org> --- Note this is done on purpose, possibly to better handle functions with multiple returns. A fix is probably in gimplification of the MODIFY_EXPR D.2774 = a != 0 ? b : c where gimplify_cond_expr isn't told it can re-use the LHS as temporary. That means special-casing this COND_EXPR RHS in gimplify_modify_expr_rhs which already handles the non-register type case. It could be extended to cover all cases which then generates the smaller int iii (int a, int b, int c) { int D.2774; if (a != 0) goto <D.2775>; else goto <D.2776>; <D.2775>: D.2774 = b; goto <D.2777>; <D.2776>: D.2774 = c; <D.2777>: return D.2774; } diff --git a/gcc/gimplify.cc b/gcc/gimplify.cc index 76221f7637d..b48c43f1471 100644 --- a/gcc/gimplify.cc +++ b/gcc/gimplify.cc @@ -5985,7 +5985,7 @@ gimplify_modify_expr_rhs (tree *expr_p, tree *from_p, tree *to_p, down into the branches. This is mandatory for ADDRESSABLE types, since we cannot generate temporaries for such, but it saves a copy in other cases as well. */ - if (!is_gimple_reg_type (TREE_TYPE (*from_p))) + if (1) { /* This code should mirror the code in gimplify_cond_expr. */ enum tree_code code = TREE_CODE (*expr_p); or to cases where is_gimple_reg (*to_p).