diff options
Diffstat (limited to 'gcc/tree-ssa-pre.c')
-rw-r--r-- | gcc/tree-ssa-pre.c | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index e179f0ce792..161d7e5a12c 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -1317,16 +1317,25 @@ create_expression_by_pieces (basic_block block, tree expr, tree stmts) case tcc_binary: { tree_stmt_iterator tsi; + tree forced_stmts; tree genop1, genop2; tree temp; + tree folded; tree op1 = TREE_OPERAND (expr, 0); tree op2 = TREE_OPERAND (expr, 1); genop1 = find_or_generate_expression (block, op1, stmts); genop2 = find_or_generate_expression (block, op2, stmts); temp = create_tmp_var (TREE_TYPE (expr), "pretmp"); add_referenced_tmp_var (temp); - newexpr = fold (build (TREE_CODE (expr), TREE_TYPE (expr), - genop1, genop2)); + + folded = fold (build (TREE_CODE (expr), TREE_TYPE (expr), + genop1, genop2)); + newexpr = force_gimple_operand (folded, &forced_stmts, false, NULL); + if (forced_stmts) + { + tsi = tsi_last (stmts); + tsi_link_after (&tsi, forced_stmts, TSI_CONTINUE_LINKING); + } newexpr = build (MODIFY_EXPR, TREE_TYPE (expr), temp, newexpr); NECESSARY (newexpr) = 0; @@ -1341,14 +1350,22 @@ create_expression_by_pieces (basic_block block, tree expr, tree stmts) case tcc_unary: { tree_stmt_iterator tsi; + tree forced_stmts; tree genop1; tree temp; + tree folded; tree op1 = TREE_OPERAND (expr, 0); genop1 = find_or_generate_expression (block, op1, stmts); temp = create_tmp_var (TREE_TYPE (expr), "pretmp"); add_referenced_tmp_var (temp); - newexpr = fold (build (TREE_CODE (expr), TREE_TYPE (expr), - genop1)); + folded = fold (build (TREE_CODE (expr), TREE_TYPE (expr), + genop1)); + newexpr = force_gimple_operand (folded, &forced_stmts, false, NULL); + if (forced_stmts) + { + tsi = tsi_last (stmts); + tsi_link_after (&tsi, forced_stmts, TSI_CONTINUE_LINKING); + } newexpr = build (MODIFY_EXPR, TREE_TYPE (expr), temp, newexpr); name = make_ssa_name (temp, newexpr); |