public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Richard Guenther <richard.guenther@gmail.com>
To: Jason Merrill <jason@redhat.com>
Cc: gcc-patches List <gcc-patches@gcc.gnu.org>
Subject: Re: RFA: PATCH to make fold_indirect_ref_1 fold more things
Date: Sat, 30 Oct 2010 07:53:00 -0000	[thread overview]
Message-ID: <AANLkTi=aE9GR+8Fbaz9DLyW1NPFskbADjMY7rCnEJpVC@mail.gmail.com> (raw)
In-Reply-To: <4CCB21C4.9010001@redhat.com>

On Fri, Oct 29, 2010 at 9:34 PM, Jason Merrill <jason@redhat.com> wrote:
> On 10/29/2010 11:25 AM, Richard Guenther wrote:
>>
>> So - what kind of testcases are you trying to handle?  (the middle-end
>> will
>> optimize this stuff keeping TBAA info correct during forwprop)
>
> The RECORD_TYPE folding was for this testcase:
>
> struct C { // literal type
>  int m;
>  int n;
>  constexpr C(int m) : m(m), n(-m) {}
>  constexpr bool is_neg() { return m < 0; }
> };
>
> constexpr bool check1(const C& c, int C:: *pm) { return c.*pm < 0; } // #1
>
> constexpr bool check2(const C* pc, bool (C::*pm)() const) { return
> (pc->*pm)(); } // #2
>
> constexpr C c(-1);
>
> static_assert(!check1(c, &C::n), "Error");
> static_assert(check1(c, &C::m), "Error");
>
> static_assert(check2(&c, &C::is_neg), "Error");
>
> For constexpr we need to evaluate suitable constant expressions at parsing
> time so that we can use them as template arguments, array bounds and such
> like.
>
> I guess I can just do this folding in the constexpr expander...

Yeah, I think that should be safer.

Richard.

> Jason
>

  reply	other threads:[~2010-10-29 23:32 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-27  2:16 Jason Merrill
2010-10-27 20:10 ` Richard Guenther
2010-10-28 16:18   ` Jason Merrill
2010-10-29 16:06     ` Richard Guenther
2010-10-29 21:51       ` Jason Merrill
2010-10-30  7:53         ` Richard Guenther [this message]
2010-10-31 23:44           ` Jason Merrill
2010-11-01 22:17             ` Richard Guenther

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='AANLkTi=aE9GR+8Fbaz9DLyW1NPFskbADjMY7rCnEJpVC@mail.gmail.com' \
    --to=richard.guenther@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jason@redhat.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).