This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: C PATCH to kill c_save_expr or towards delayed folding for the C FE
- From: Jakub Jelinek <jakub at redhat dot com>
- To: Marek Polacek <polacek at redhat dot com>
- Cc: GCC Patches <gcc-patches at gcc dot gnu dot org>, Joseph Myers <joseph at codesourcery dot com>
- Date: Fri, 12 May 2017 21:48:28 +0200
- Subject: Re: C PATCH to kill c_save_expr or towards delayed folding for the C FE
- Authentication-results: sourceware.org; auth=none
- Authentication-results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com
- Authentication-results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=jakub at redhat dot com
- Dkim-filter: OpenDKIM Filter v2.11.0 mx1.redhat.com B0047C04BD3A
- Dmarc-filter: OpenDMARC Filter v1.3.2 mx1.redhat.com B0047C04BD3A
- References: <20170512193726.GL4910@redhat.com>
- Reply-to: Jakub Jelinek <jakub at redhat dot com>
On Fri, May 12, 2017 at 09:37:27PM +0200, Marek Polacek wrote:
> @@ -565,6 +564,25 @@ c_fully_fold_internal (tree expr, bool in_init, bool *maybe_const_operands,
> appropriate in any particular case. */
> gcc_unreachable ();
>
> + case SAVE_EXPR:
> + /* Make sure to fold the contents of a SAVE_EXPR exactly once. */
> + 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;
> + }
> + }
Wouldn't it be better to guard with if (!SAVE_EXPR_FOLDED_P (expr))
only c_fully_fold_internal recursion on the operand
and then use if (tree_invariant_p (op0)) unconditionally?
> @@ -113,6 +113,10 @@ along with GCC; see the file COPYING3. If not see
> subexpression meaning it is not a constant expression. */
> #define CONSTRUCTOR_NON_CONST(EXPR) TREE_LANG_FLAG_1 (CONSTRUCTOR_CHECK (EXPR))
>
> +/* For a SAVE_EXPR, nonzero if the contents of the SAVE_EXPR have already
> + been folded. */
s/contents/operand/;s/have/has/ ?
Otherwise I'm all for this, but would like to give you and Joseph as C FE
maintainers the last word on this.
Jakub