From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14529 invoked by alias); 20 May 2009 18:15:41 -0000 Received: (qmail 14510 invoked by uid 22791); 20 May 2009 18:15:40 -0000 X-SWARE-Spam-Status: No, hits=-3.3 required=5.0 tests=AWL,BAYES_00,J_CHICKENPOX_15 X-Spam-Check-By: sourceware.org Received: from cantor2.suse.de (HELO mx2.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 20 May 2009 18:15:29 +0000 Received: from relay2.suse.de (relay-ext.suse.de [195.135.221.8]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx2.suse.de (Postfix) with ESMTP id 4AA1F8655F; Wed, 20 May 2009 20:15:25 +0200 (CEST) Date: Wed, 20 May 2009 21:34:00 -0000 From: Richard Guenther To: Mark Mitchell Cc: gcc-patches@gcc.gnu.org, gcc@gcc.gnu.org Subject: Re: [PATCH][RFC] Adjust the middle-end memory model In-Reply-To: <4A14288E.4060304@codesourcery.com> Message-ID: References: <4A12F125.6030309@codesourcery.com> <4A14288E.4060304@codesourcery.com> User-Agent: Alpine 2.00 (LNX 1167 2008-08-23) MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Mailing-List: contact gcc-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-owner@gcc.gnu.org X-SW-Source: 2009-05/txt/msg00522.txt.bz2 On Wed, 20 May 2009, Mark Mitchell wrote: > Richard Guenther wrote: > > >> void f(float *f, int *n) { > >> for (int i = 0; i < *n; ++i) { > >> f[i] *= 2; > >> } > >> } > > > The difference is if you want to sink a load from *n beyond the > > store to f[i] - in which case you ask if there is an anti-dependence > > which we cannot exclude in this case (no TBAA is allowed here). > > By "not allowed", you don't mean "would be an invalid optimization", but > rather "will no longer be done by GCC", right? Right, not invalid in the above case but nevertheless no longer being done by GCC. This is to properly support int i; float f; void foo() { int *p = (int *)malloc(sizeof(int)); *p = 1; i = *p; float *q = (float *)p; *q = 2.0; f = *q; } where we need to avoid scheduling the store via *q before the load from *p. The above is valid as I read C99 6.5/6, it is an object with no declared type (obtained via malloc) and has type int due to the store via *p "for that access and for subsequent accesses _that do not modify the stored value_." (emphasis mine). So for objects without a declared type C can do "placement new" by simply storing with a different type. In C++ we of course have the usual placement new situations. Richard.