From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 32129 invoked by alias); 20 May 2011 19:22:08 -0000 Received: (qmail 32088 invoked by uid 22791); 20 May 2011 19:22:06 -0000 X-SWARE-Spam-Status: No, hits=-1.0 required=5.0 tests=AWL,BAYES_00,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,FREEMAIL_ENVFROM_END_DIGIT,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,RFC_ABUSE_POST X-Spam-Check-By: sourceware.org Received: from mail-qy0-f175.google.com (HELO mail-qy0-f175.google.com) (209.85.216.175) by sourceware.org (qpsmtpd/0.43rc1) with ESMTP; Fri, 20 May 2011 19:21:52 +0000 Received: by qyk35 with SMTP id 35so463883qyk.20 for ; Fri, 20 May 2011 12:21:52 -0700 (PDT) MIME-Version: 1.0 Received: by 10.229.7.3 with SMTP id b3mr3532341qcb.194.1305919311926; Fri, 20 May 2011 12:21:51 -0700 (PDT) Received: by 10.229.33.209 with HTTP; Fri, 20 May 2011 12:21:51 -0700 (PDT) In-Reply-To: References: Date: Sat, 21 May 2011 00:12:00 -0000 Message-ID: Subject: Re: [patch tree-ssa-reassoc.c]: Better reassoication for comparision and boolean-logic From: Kai Tietz To: Richard Guenther 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/msg01505.txt.bz2 2011/5/20 Richard Guenther : > On Thu, May 19, 2011 at 7:52 PM, Kai Tietz wrot= e: >> 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. This works so far nice when fold_convert doesn't hoist for boolean-types. But in pass forwprop (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. As 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. As after reassociation again the forward-propagation happens, we have still the better final expression variant as result. So how to continue here? Regards, Kai