From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24482 invoked by alias); 11 Oct 2007 17:21:24 -0000 Received: (qmail 24474 invoked by uid 22791); 11 Oct 2007 17:21:24 -0000 X-Spam-Check-By: sourceware.org Received: from VLSI1.ULTRA.NYU.EDU (HELO vlsi1.ultra.nyu.edu) (128.122.140.213) by sourceware.org (qpsmtpd/0.31) with SMTP; Thu, 11 Oct 2007 17:21:22 +0000 Received: by vlsi1.ultra.nyu.edu (4.1/1.34) id AA26583; Thu, 11 Oct 07 13:25:37 EDT From: kenner@vlsi1.ultra.nyu.edu (Richard Kenner) Message-Id: <10710111725.AA26583@vlsi1.ultra.nyu.edu> Date: Thu, 11 Oct 2007 17:21:00 -0000 To: matz@suse.de Subject: Re: [PATCH] Fix optimization regression in constant folder Cc: ebotcazou@adacore.com, gcc-patches@gcc.gnu.org, iant@google.com, mark@codesourcery.com, richard.guenther@gmail.com In-Reply-To: References: <200709171539.26653.ebotcazou@adacore.com> <200709301801.39718.ebotcazou@adacore.com> <200710010127.59677.ebotcazou@adacore.com> <10710010056.AA15609@vlsi1.ultra.nyu.edu> <10710010257.AA21585@vlsi1.ultra.nyu.edu> <10710010344.AA22633@vlsi1.ultra.nyu.edu> <470D0C50.4080506@codesourcery.com> <10710111536.AA24058@vlsi1.ultra.nyu.edu> <10710111616.AA25194@vlsi1.ultra.nyu.edu> <10710111651.AA26098@vlsi1.ultra.nyu.edu> 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: 2007-10/txt/msg00667.txt.bz2 > negative values can be represented in unsigned types just fine, it's just > a matter of interpreting it correctly. I suppose, though the idea of purposely putting a negative value in an unsigned type because we know that overflow will do the right thing seems dubious to me. > Okay, so conceptually it's like: > > struct S { > int a1[n1*n2]; > int a2[n2*n1]; > int a3[n3]; > } s; /* so a1 and a2 have the same number of elements */ > > And then you access this in e.g. such way: > > for (i = start; i <= end; i++) > use (s.a1[i], s.a2[i+2], s.a3[i]); Somewhat, though a more common case is when you have multiple arrays that are of the same size (though usually different component sizes) and the index in each of them is the same value (sounds contrived, but this happens in Ada discriminated records all the time). So you know that the computations for any offset must be a*i+b, for some A and B, but getting there from the expressions you actually have can be tricky.