From: Patrick Palka <patrick@parcs.ath.cx>
To: GCC Patches <gcc-patches@gcc.gnu.org>
Cc: "Joseph S. Myers" <joseph@codesourcery.com>,
Patrick Palka <patrick@parcs.ath.cx>
Subject: Re: [PATCH] [C FE] Fold trivial exprs that refer to const vars
Date: Mon, 07 Dec 2015 12:24:00 -0000 [thread overview]
Message-ID: <CA+C-WL9FPTJ4z-F=+3VeEu=kZiYw-M+o_yS+UejsOvz+tr62SQ@mail.gmail.com> (raw)
In-Reply-To: <1449463815-4150-1-git-send-email-patrick@parcs.ath.cx>
On Sun, Dec 6, 2015 at 11:50 PM, Patrick Palka <patrick@parcs.ath.cx> wrote:
> There is a minor inconsistency in the folding behavior within the C
> frontend. The C frontend does not currently fold the expression "x",
> where x is a const int, yet the FE does fold the expression "x + 0".
>
> This happens because decl_constant_value is called in c_fully_fold only
> while recursing over the operands of the expression being folded, i.e.
> there is no top-level call to decl_constant_value to handle the case
> where the expression being folded happens to be a singular expression
> such as "x", as opposed to "x + 5" (where x is a const variable).
>
> To fix this inconsistency, this patch calls decl_constant_value in
> c_fully fold after folding the given expression.
>
> Bootstrap + regtest in progress on x86_64-pc-linux-gnu, OK to commit if
> testing succeeds?
It just occurred to me that this change is not completely safe because
calling c_fully_fold on an lvalue can now return an rvalue. Callers of
c_fully_fold are not prepared to handle this. Indeed, this patch
causes a couple of regressions in the handling asm() memory operands
due to this implicit lvalue-rvalue conversion.
prev parent reply other threads:[~2015-12-07 12:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-07 4:51 Patrick Palka
2015-12-07 4:56 ` Patrick Palka
2015-12-07 12:20 ` Marek Polacek
2015-12-07 12:27 ` Patrick Palka
2015-12-07 12:24 ` Joseph Myers
2015-12-07 12:43 ` Patrick Palka
2015-12-07 12:24 ` Patrick Palka [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to='CA+C-WL9FPTJ4z-F=+3VeEu=kZiYw-M+o_yS+UejsOvz+tr62SQ@mail.gmail.com' \
--to=patrick@parcs.ath.cx \
--cc=gcc-patches@gcc.gnu.org \
--cc=joseph@codesourcery.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).