public inbox for gcc-bugs@sourceware.org help / color / mirror / Atom feed
From: "joseph at codesourcery dot com" <gcc-bugzilla@gcc.gnu.org> To: gcc-bugs@gcc.gnu.org Subject: [Bug c/52283] "error: case label does not reduce to an integer constant" for constant folded cast expr Date: Thu, 16 Feb 2012 22:21:00 -0000 [thread overview] Message-ID: <bug-52283-4-fJBLjEBnJe@http.gcc.gnu.org/bugzilla/> (raw) In-Reply-To: <bug-52283-4@http.gcc.gnu.org/bugzilla/> http://gcc.gnu.org/bugzilla/show_bug.cgi?id=52283 --- Comment #9 from joseph at codesourcery dot com <joseph at codesourcery dot com> 2012-02-16 20:10:34 UTC --- On Thu, 16 Feb 2012, manu at gcc dot gnu.org wrote: > Is this folding actually necessary for anything beyond diagnostics? I thought > it was agreed that folding in the FEs was EVIL and we should stop doing it. Folding with c_fully_fold is done (a) where required for language semantics (in particular integer constant expressions ... remember that it's not possible to avoid doing struct layout quite early, for example, even if it would seem cleaner to have separate phases there, because offsetof can be used in an integer constant expression, and whether such an expression evaluates to 0 affects the types of other expressions), (b) for diagnostics (folded expressions work better in various cases that try to avoid diagnostics for e.g. signed/unsigned conversions that can't actually cause any problems), (c) in certain cases where the expression being built up is something such as SAVE_EXPR it would be problematic for the front end to try to take apart to fold inside later and (d) as a final lowering stage for a full expression that converts it into the form that will be gimplified. > I wouldn't be surprised if the compiler got noticeably faster by removing all > early folding and all the workarounds and hacks that come with it, and > replacing it by doing a temporary c_fully_fold at those specific places that > needed it (and throwing away the result and keeping the original code around). The places that use c_fully_fold on something less than a full expression are doing it because it's actually needed there and removing it will break things. Furthermore, if you throw away the result as you suggest, so repeatedly folding the same expression as a subexpression of larger expressions, you would be liable to make things slower. (When c_fully_fold is run on something less than a full expression, the result is wrapped so that it *doesn't* recurse inside that subexpression when called on a larger expression containing it.) For cases in (c) it may be useful to create new C-family tree codes that represent the operations in question at a level closer to the C source code, so allowing the lowering to SAVE_EXPR etc. to be delayed until a later c_fully_fold call. For (b), it may be useful to create codes representing that a conversion was implicit, or that a diagnostic should be generated under certain conditions, again either processing them later in c_fully_fold or passing down the "diagnose this if ..." information for diagnostics to be generated at a later stage if the code is still reachable after some optimization and the compiler can't rule out whatever the problem is - but doing things any later than the final lowering to GENERIC / GIMPLE runs into the usual trade-offs between predictable diagnostics and avoiding diagnostics where a human can see there is no problem. In any case you can't just remove the folding without creating appropriate new representations.
next prev parent reply other threads:[~2012-02-16 21:06 UTC|newest] Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top 2012-02-16 16:50 [Bug c/52283] New: " chrbr at gcc dot gnu.org 2012-02-16 16:52 ` [Bug c/52283] " chrbr at gcc dot gnu.org 2012-02-16 17:11 ` jakub at gcc dot gnu.org 2012-02-16 17:17 ` joseph at codesourcery dot com 2012-02-16 17:56 ` manu at gcc dot gnu.org 2012-02-16 18:20 ` joseph at codesourcery dot com 2012-02-16 18:28 ` manu at gcc dot gnu.org 2012-02-16 19:03 ` jakub at gcc dot gnu.org 2012-02-16 21:02 ` manu at gcc dot gnu.org 2012-02-16 22:21 ` joseph at codesourcery dot com [this message] 2012-02-16 23:56 ` joseph at codesourcery dot com 2012-02-20 12:17 ` chrbr at gcc dot gnu.org 2012-02-20 15:41 ` chrbr at gcc dot gnu.org 2012-02-20 15:43 ` rguenth at gcc dot gnu.org 2012-02-20 16:46 ` manu at gcc dot gnu.org 2012-02-21 9:58 ` manu at gcc dot gnu.org 2012-02-21 17:51 ` joseph at codesourcery dot com 2012-02-21 17:54 ` manu at gcc dot gnu.org 2012-02-21 18:26 ` joseph at codesourcery dot com 2012-02-21 20:31 ` manu at gcc dot gnu.org 2012-02-21 20:37 ` manu at gcc dot gnu.org 2012-02-21 20:49 ` manu at gcc dot gnu.org 2012-02-23 15:09 ` chrbr at gcc dot gnu.org 2012-02-24 2:50 ` manu at gcc dot gnu.org 2012-02-27 8:30 ` chrbr at gcc dot gnu.org 2012-03-16 23:50 ` manu at gcc dot gnu.org 2012-04-19 9:21 ` chrbr at gcc dot gnu.org
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=bug-52283-4-fJBLjEBnJe@http.gcc.gnu.org/bugzilla/ \ --to=gcc-bugzilla@gcc.gnu.org \ --cc=gcc-bugs@gcc.gnu.org \ /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: linkBe 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).