From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 14004 invoked by alias); 21 May 2011 09:20:24 -0000 Received: (qmail 13995 invoked by uid 22791); 21 May 2011 09:20:23 -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-f41.google.com (HELO mail-ww0-f41.google.com) (74.125.82.41) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Sat, 21 May 2011 09:20:08 +0000 Received: by wwi18 with SMTP id 18so194773wwi.2 for ; Sat, 21 May 2011 02:20:06 -0700 (PDT) MIME-Version: 1.0 Received: by 10.227.174.79 with SMTP id s15mr454043wbz.76.1305969606760; Sat, 21 May 2011 02:20:06 -0700 (PDT) Received: by 10.227.38.129 with HTTP; Sat, 21 May 2011 02:20:06 -0700 (PDT) In-Reply-To: References: Date: Sat, 21 May 2011 16:17: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/msg01524.txt.bz2 On Fri, May 20, 2011 at 9:21 PM, Kai Tietz wrote: > 2011/5/20 Richard Guenther : >> On Thu, May 19, 2011 at 7:52 PM, Kai Tietz wro= te: >>> To illustrate in which scenario code in tree-ssa-forwprop doesn't help >>> is binop-tor4.c >>> >>> w/o this patch we get >>> >>> >>> foo (int a, int b, int c) >>> { >>> =A0int e; >>> =A0int d; >>> =A0int D.2701; >>> =A0_Bool D.2700; >>> =A0_Bool D.2699; >>> =A0_Bool D.2698; >>> =A0_Bool D.2697; >>> =A0_Bool D.2696; >>> =A0int D.2695; >>> >>> : >>> =A0D.2695_3 =3D b_2(D) | a_1(D); >>> =A0d_4 =3D D.2695_3 !=3D 0; >>> =A0D.2696_5 =3D a_1(D) =3D=3D 0; >>> =A0D.2697_6 =3D b_2(D) =3D=3D 0; >>> =A0D.2698_7 =3D D.2697_6 | D.2696_5; >>> =A0D.2699_9 =3D c_8(D) !=3D 0; >>> =A0D.2700_10 =3D D.2698_7 | D.2699_9; >>> =A0e_11 =3D (int) D.2700_10; >>> =A0D.2701_12 =3D e_11 | d_4; >>> =A0return D.2701_12; >>> } >>> >>> Of interest is here =A0D.2701_12, which doesn't have a type sinking. >>> This is caused by >>> >>> =A0D.2695_3 =3D b_2(D) | a_1(D); >>> =A0d_4 =3D D.2695_3 !=3D 0; >>> >>> which is a comparison result with implicit integer cast. So maybe the >>> solution here could be to first doing boolification of comparison in >>> gimplifier. By this, the code for type-sinking in my patch could go >>> away. >> >> Well, forwprop either needs to be teached to handle this different kind >> of widening >> >> =A0d_4 =3D D.2687_3 !=3D 0; >> =A0e_11 =3D (int) D.2692_10; >> =A0D.2694_12 =3D e_11 | d_4; >> >> or indeed comparisons should also be boolified (which I think they >> should - they are also predicate producers). >> >> Still whether sinking or hoisting the stuff is the right thing, reassoc >> is not the place to do it. >> >> Richard. > > So I tested code to do boolifying of comparison in gimplifier. =A0This > works so far nice when fold_convert doesn't hoist for boolean-types. > But in pass =A0forwprop (see here function forward_propagate_comparison) > does again type hoisting, which destroys of coures the boolified > comparisons and so later reassociation pass has again the issue about > finding matches. > To introduce (as you suggested) into tree-ssa-forwprop the type > sinking, therefore doesn't work. =A0As type hoisting is for sure the > better final result of an expression, but on expression folding > passes it has advantages to use type sinking instead. > So this might be a thing for a different pass, or in reassoc-pass > itself (as patch does) as here type-sinking helps to combine. =A0As > after reassociation again the forward-propagation happens, we have > still the better final expression variant as result. > > So how to continue here? Please send me the boolification of comparisons patch you have, as that is the right way to continue. forwprop shouldn't undo this (if it does, it does so via fold). Richard. > Regards, > Kai >