From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 29908 invoked by alias); 7 Jun 2011 12:22:59 -0000 Received: (qmail 29899 invoked by uid 22791); 7 Jun 2011 12:22:58 -0000 X-SWARE-Spam-Status: No, hits=-5.8 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from cantor.suse.de (HELO mx1.suse.de) (195.135.220.2) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Tue, 07 Jun 2011 12:22:38 +0000 Received: from relay2.suse.de (charybdis-ext.suse.de [195.135.221.2]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.suse.de (Postfix) with ESMTP id 9C4AE8E8CC; Tue, 7 Jun 2011 14:22:37 +0200 (CEST) Date: Tue, 07 Jun 2011 12:22:00 -0000 From: Richard Guenther To: Richard Guenther Cc: Jakub Jelinek , Jason Merrill , gcc-patches List Subject: Re: RFA (fold): PATCH for c++/49290 (folding *(T*)(ar+10)) In-Reply-To: Message-ID: References: <4DEDB98F.6010508@redhat.com> <20110607102717.GZ17079@tyan-ft48-01.lab.bos.redhat.com> User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Content-Type: MULTIPART/MIXED; BOUNDARY="8323584-1548054455-1307449357=:810" 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/msg00507.txt.bz2 This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. --8323584-1548054455-1307449357=:810 Content-Type: TEXT/PLAIN; charset=ISO-8859-1 Content-Transfer-Encoding: 8BIT Content-length: 1514 On Tue, 7 Jun 2011, Richard Guenther wrote: > On Tue, Jun 7, 2011 at 12:27 PM, Jakub Jelinek wrote: > > On Tue, Jun 07, 2011 at 12:19:59PM +0200, Richard Guenther wrote: > >> On Tue, Jun 7, 2011 at 7:39 AM, Jason Merrill wrote: > >> > In the testcase, fold_indirect_ref_1 won't fold *(T*)(s1+10) to an ARRAY_REF > >> > because T != unsigned.  Even if it were just a typedef to unsigned, that > >> > isn't close enough, but in this case it's a typedef to const unsigned. > >> > > >> > I'm not sure what the type coherence rules are for ARRAY_REF.  Is it really > >> > necessary that the type of the ARRAY_REF match exactly the element type of > >> > the array? > >> > >> I _think_ that you can unconditionally change the code to do > >> > >>   TYPE_MAIN_VARIANT (t1) == TYPE_MAIN_VARIANT (t2) > >>   && TYPE_QUALS (t1) == TYPE_QUALS (t2) > >> > >> now, I'm not sure if for the testcase T and unsigned differ in qualifiers. > > > > I guess folding into array_ref that way is fine, but you should in the end > > fold_convert_loc it to the expected type, while the middle-end has the > > notion of useless type conversions, fold-const.c is also used by FEs and > > I think it is expected to have the types exactly matching. > > So (T)s1[10] instead of s1[10] in this case. > > I'm not sure that's a good idea if the caller wants an lvalue. Rather build the array-ref with type T directly (thus, with a mismatch between the type of the array-ref and the element type). Richard. --8323584-1548054455-1307449357=:810--