From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 7368 invoked by alias); 13 Jul 2011 08:13:17 -0000 Received: (qmail 7359 invoked by uid 22791); 13 Jul 2011 08:13:16 -0000 X-SWARE-Spam-Status: No, hits=-6.5 required=5.0 tests=AWL,BAYES_00,RCVD_IN_DNSWL_HI,SPF_HELO_PASS,T_RP_MATCHES_RCVD X-Spam-Check-By: sourceware.org Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Wed, 13 Jul 2011 08:12:57 +0000 Received: from int-mx01.intmail.prod.int.phx2.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id p6D8Ctwp005990 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=OK); Wed, 13 Jul 2011 04:12:56 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (tyan-ft48-01.lab.bos.redhat.com [10.16.42.4]) by int-mx01.intmail.prod.int.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id p6D8CsbF001687 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NO); Wed, 13 Jul 2011 04:12:55 -0400 Received: from tyan-ft48-01.lab.bos.redhat.com (localhost.localdomain [127.0.0.1]) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4) with ESMTP id p6D8CswW010121; Wed, 13 Jul 2011 10:12:54 +0200 Received: (from jakub@localhost) by tyan-ft48-01.lab.bos.redhat.com (8.14.4/8.14.4/Submit) id p6D8CrXs010119; Wed, 13 Jul 2011 10:12:53 +0200 Date: Wed, 13 Jul 2011 08:30:00 -0000 From: Jakub Jelinek To: Ilya Enkovich Cc: "William J. Schmidt" , gcc-patches@gcc.gnu.org Subject: Re: [PATCH Atom][PR middle-end/44382] Tree reassociation improvement Message-ID: <20110713081253.GS2687@tyan-ft48-01.lab.bos.redhat.com> Reply-To: Jakub Jelinek References: <1310489429.5266.25.camel@oc2474580526.ibm.com> <1310491307.5266.31.camel@oc2474580526.ibm.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: User-Agent: Mutt/1.5.21 (2010-09-15) 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-07/txt/msg00995.txt.bz2 On Wed, Jul 13, 2011 at 11:52:25AM +0400, Ilya Enkovich wrote: > > However, it does not fix http://gcc.gnu.org/PR45671, which surprises me > > as it was marked as a duplicate of this one.  Any thoughts on why this > > isn't sufficient to reassociate the linear chain of adds? > > > > Test case: > > > > int myfunction (int a, int b, int c, int d, int e, int f, int g, int h) > > { > >  int ret; > > > >  ret = a + b + c + d + e + f + g + h; > >  return ret; > > > > } > > > > > > > > Reassociation does not work for signed integers because signed integer > is not wrap-around type in C. You can change it by passing -fwrapv > option but it will disable other useful optimization. Reassociation of > signed integers without this option is not a trivial question because > in that case you may introduce overflows and therefore undefined > behavior. Well, if it is clearly a win to reassociate, you can always reassociate them by doing arithmetics in corresponding unsigned type and afterwards converting back to the signed type. Jakub