From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14866 invoked by alias); 12 Jun 2011 10:56:06 -0000 Received: (qmail 14858 invoked by uid 22791); 12 Jun 2011 10:56:06 -0000 X-SWARE-Spam-Status: No, hits=-2.4 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST X-Spam-Check-By: sourceware.org Received: from mail-ww0-f51.google.com (HELO mail-ww0-f51.google.com) (74.125.82.51) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sun, 12 Jun 2011 10:55:52 +0000 Received: by wwf26 with SMTP id 26so3615785wwf.8 for ; Sun, 12 Jun 2011 03:55:50 -0700 (PDT) MIME-Version: 1.0 Received: by 10.227.197.83 with SMTP id ej19mr3906994wbb.105.1307876149846; Sun, 12 Jun 2011 03:55:49 -0700 (PDT) Received: by 10.227.28.69 with HTTP; Sun, 12 Jun 2011 03:55:49 -0700 (PDT) In-Reply-To: <37B61697-B4A5-49B6-87C4-AD361A86F752@comcast.net> References: <4DEDB98F.6010508@redhat.com> <4DEE2DCF.7020905@redhat.com> <4DEE3484.8030101@redhat.com> <4DF11FBC.3010304@redhat.com> <4DF223D4.3080700@redhat.com> <4DF22656.9050700@redhat.com> <37B61697-B4A5-49B6-87C4-AD361A86F752@comcast.net> Date: Sun, 12 Jun 2011 11:03:00 -0000 Message-ID: Subject: Re: RFA (fold): PATCH for c++/49290 (folding *(T*)(ar+10)) From: Richard Guenther To: Mike Stump Cc: Richard Guenther , Jason Merrill , gcc-patches List Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-IsSubscribed: yes Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org X-SW-Source: 2011-06/txt/msg00934.txt.bz2 On Sat, Jun 11, 2011 at 7:45 PM, Mike Stump wrote: > On Jun 10, 2011, at 7:20 AM, Richard Guenther wrote: >> On Fri, 10 Jun 2011, Jason Merrill wrote: >> >>> On 06/10/2011 10:03 AM, Richard Guenther wrote: >>>>>> *((volatile int *)&a[0] + 1) >>>>> >>>>> It would be correct to fold it to >>>>> >>>>> VIEW_CONVERT_EXPR >>>> >>>> No, it wouldn't be correct. =A0It isn't correct to fold it to an array= -ref >>>> that isn't volatile. >>> >>> Hmm? =A0The C expression produces a volatile int lvalue referring to th= e second >>> element of a, as does the VIEW_CONVERT_EXPR. =A0They seem equivalent to= me. >> >> no, a VIEW_CONVERT_EXPR is generally not an lvalue (fold for example >> would turn the above to (volatile int) a[1]). > > Curious. =A0We have built up a built-in infrastructure that allows for lv= alue register references. =A0I noticed that for vector types, vectors with = different type names but the same in every other respect come out different= , and a VIEW_CONVERT_EXPR is placed on it to get the types to match. =A0Pre= sently I'm treating VIEW_CONVERT_EXPR as an lvalue. =A0For me not to, I'd n= eed either for the same type to be used, or, for another conversion node to= be used that can preserve the lvalueness of registers. > > Now, if people want to know why, lvalue for registers, it is to support i= n/out and output only parameters to built-ins. > > Thoughts? In almost all cases(*) the need for a lvalue VIEW_CONVERT_EXPR can be avoid= ed by moving the VIEW_CONVERT_EXPR to the rvalue assigned too it. Remember th= at VIEW_CONVERT_EXPR always conver the full object and are not allowed to change sizes. So, do you have an example? Richard. (*) Ada uses lvalue component-refs on VIEW_CONVERT_EXPRs of aggregate types. While I don't like it too much it's probably not too convenient (even if it is always possible) to move these to the RHS of assignments.