From d11c168a673e6a451bbaa7ccde2ed2229d123a94 Mon Sep 17 00:00:00 2001 From: Jakub Jelinek Date: Mon, 22 May 2017 20:55:29 +0200 Subject: [PATCH] c-fold.c (c_fully_fold_internal): Save the c_fully_fold_internal result for SAVE_EXPR operand and set... * c-fold.c (c_fully_fold_internal): Save the c_fully_fold_internal result for SAVE_EXPR operand and set SAVE_EXPR_FOLDED_P even if it returned invariant. Call tree_invariant_p unconditionally afterwards to decide whether to return expr or op0. From-SVN: r248347 --- gcc/c/ChangeLog | 7 +++++++ gcc/c/c-fold.c | 16 ++++++---------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog index 0318bcf043b..292762ac9c2 100644 --- a/gcc/c/ChangeLog +++ b/gcc/c/ChangeLog @@ -1,3 +1,10 @@ +2017-05-22 Jakub Jelinek + + * c-fold.c (c_fully_fold_internal): Save the c_fully_fold_internal + result for SAVE_EXPR operand and set SAVE_EXPR_FOLDED_P even if + it returned invariant. Call tree_invariant_p unconditionally + afterwards to decide whether to return expr or op0. + 2017-05-22 Nathan Sidwell * c-decl.c (c_parse_final_cleanups): Drop TDI_tu handling. diff --git a/gcc/c/c-fold.c b/gcc/c/c-fold.c index 1baee446d3e..2601224c847 100644 --- a/gcc/c/c-fold.c +++ b/gcc/c/c-fold.c @@ -566,21 +566,17 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands, case SAVE_EXPR: /* Make sure to fold the contents of a SAVE_EXPR exactly once. */ + op0 = TREE_OPERAND (expr, 0); if (!SAVE_EXPR_FOLDED_P (expr)) { - op0 = TREE_OPERAND (expr, 0); op0 = c_fully_fold_internal (op0, in_init, maybe_const_operands, maybe_const_itself, for_int_const); - /* Don't wrap the folded tree in a SAVE_EXPR if we don't - have to. */ - if (tree_invariant_p (op0)) - ret = op0; - else - { - TREE_OPERAND (expr, 0) = op0; - SAVE_EXPR_FOLDED_P (expr) = true; - } + TREE_OPERAND (expr, 0) = op0; + SAVE_EXPR_FOLDED_P (expr) = true; } + /* Return the SAVE_EXPR operand if it is invariant. */ + if (tree_invariant_p (op0)) + ret = op0; goto out; default: -- 2.30.2