From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 3876 invoked by alias); 19 May 2011 13:11:55 -0000 Received: (qmail 3613 invoked by uid 22791); 19 May 2011 13:11:54 -0000 X-SWARE-Spam-Status: No, hits=-2.3 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; Thu, 19 May 2011 13:11:37 +0000 Received: by wwf26 with SMTP id 26so2646940wwf.8 for ; Thu, 19 May 2011 06:11:36 -0700 (PDT) MIME-Version: 1.0 Received: by 10.227.165.10 with SMTP id g10mr3214468wby.91.1305810696004; Thu, 19 May 2011 06:11:36 -0700 (PDT) Received: by 10.227.38.129 with HTTP; Thu, 19 May 2011 06:11:35 -0700 (PDT) In-Reply-To: References: Date: Thu, 19 May 2011 13:51:00 -0000 Message-ID: Subject: Re: [patch tree-ssa-reassoc.c]: Better reassoication for comparision and boolean-logic From: Richard Guenther To: Kai Tietz Cc: GCC Patches 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-05/txt/msg01382.txt.bz2 On Thu, May 19, 2011 at 3:08 PM, Kai Tietz wrote: > 2011/5/19 Richard Guenther : >> On Thu, May 19, 2011 at 2:59 PM, Kai Tietz wro= te: >>> 2011/5/19 Richard Guenther : >>>> On Thu, May 19, 2011 at 2:48 PM, Kai Tietz w= rote: >>>>> Hello, >>>>> >>>>> This patch improves reassociation folding for comparision. It expands >>>>> expressions within binary-AND/OR expression like (X | Y) =3D=3D 0 to = (X =3D=3D >>>>> 0 && Y =3D=3D 0) >>>>> and (X | Y) !=3D 0 to (X !=3D 0 || Y !=3D 0). =A0This is necessary to= allow >>>>> better reassociation >>>>> on weak pre-folded logical expressions. =A0This unfolding gets undone >>>>> anyway later by pass, >>>>> so no disadvantage gets introduced. >>>>> Also while going through BB-list, it tries to do some little >>>>> type-sinking for SSA sequences >>>>> like "D1 =3D (type) bool1; D2 =3D (type) bool2; D3 =3D D1 & D2;' to '= D1 =3D >>>>> bool1 & bool2; D2 =3D (type) D1;'. >>>>> This folding has the advantage to see better through intermediate >>>>> results with none-boolean type. >>>>> The function eliminate_redundant_comparison () got reworded so, that >>>>> doesn't break in all cases. >>>>> It now continues to find duplicates and tries to find inverse variant >>>>> (folded to constant). By this >>>>> change we don't combine possible weak optimizations too fast, before >>>>> we can find and handle >>>>> inverse or duplicates. >>>> >>>> sinking casting belongs not here but instead to tree-ssa-forwprop. >>>> I'm not sure that a !=3D 0 | b !=3D 0 is the better canonical variant = than >>>> a | b !=3D 0 though. >>>> >>>> is_boolean_compatible_type_p looks like a strange remanent. >>>> >>>> Richard. >>> >>> Well, a | b !=3D 0 is for sure more optimal, but for reassociation we >>> need to see the unfolded variant temporary. This is necessary as >>> fold-const can't see through SSA statements. =A0But this kind of >>> expansion should be reversed then by pass to the form (a | b) !=3D 0 >>> back. >> >> ? =A0fold-const shouldn't deal with this at all as we are in gimple and = in >> SSA form. =A0Surely re-association comes to play only with chains of >> the above with more than two operands. >> >> Richard. >> >>> >>> Regards, >>> Kai >>> >> > > The issue you can see by testcase binop_tor4.c, as here are the > intermediate variables d and e (with int type) are destroying the > reassociation pass. This testcase for example needs this sinking. hoisting would work equally well > Kai >