From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 93901 invoked by alias); 24 May 2016 03:13:47 -0000 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 Received: (qmail 92899 invoked by uid 89); 24 May 2016 03:13:45 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.6 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=bba, 2016-05-24, 20160524 X-HELO: mail-qk0-f181.google.com Received: from mail-qk0-f181.google.com (HELO mail-qk0-f181.google.com) (209.85.220.181) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Tue, 24 May 2016 03:13:35 +0000 Received: by mail-qk0-f181.google.com with SMTP id n63so2942370qkf.0 for ; Mon, 23 May 2016 20:13:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=jhu5Sd/xxbLP7AHbxKTrFAjkX4yGQexJB3RF9mHdZiU=; b=WYN0DlPDcuU9PPwKv+mv0z9f2ZDF+M6jsE56RFWC1BNvqbpoCs1sxPI0yw0P7nZ+hs UvwR9hFj/hd1sWtBns0JATolVmH8rzg0uBJgqb9EAQ5cuyFA9absv8U6kEKq6Yve4gFv nM3BTl/wQ4JrwCnobx2fYeCmrjuzCf8IWGvMj6Ocje32rICER2Ru/MvNdKOL+Lejgs9t 5d+/aHNaIiPiHiafY/FOdCOuGVp4Zaq1C0zp288AGJsSOyx5gWia/wiNcv/N/FL1okwy zVTT5XT1WdZLPHo8HVy/XKzO5JkqS7GJCDRSdc5yv4Pl97v00njLkYB6Y5AWfM2ldJPb BMPw== X-Gm-Message-State: ALyK8tLQDfTVISWb292+k7Z7G3ufp5x/u3ifxlDsLaCo3sT7NSxo/eqPU3FnXXoxyzR9ajGU7Il6AaTPGNf02wj7 MIME-Version: 1.0 X-Received: by 10.237.34.240 with SMTP id q45mr2041994qtc.90.1464059612447; Mon, 23 May 2016 20:13:32 -0700 (PDT) Received: by 10.200.42.71 with HTTP; Mon, 23 May 2016 20:13:32 -0700 (PDT) In-Reply-To: References: <573D7394.5050208@suse.cz> <573D78CE.6020900@linaro.org> Date: Tue, 24 May 2016 03:13:00 -0000 Message-ID: Subject: Re: [PATCH] Fix PR tree-optimization/71170 From: Kugan Vivekanandarajah To: Richard Biener Cc: =?UTF-8?Q?Martin_Li=C5=A1ka?= , GCC Patches Content-Type: multipart/mixed; boundary=001a113e76b8217d9a05338df1fd X-IsSubscribed: yes X-SW-Source: 2016-05/txt/msg01849.txt.bz2 --001a113e76b8217d9a05338df1fd Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-length: 3044 On 23 May 2016 at 21:35, Richard Biener wrote: > On Sat, May 21, 2016 at 8:08 AM, Kugan Vivekanandarajah > wrote: >> On 20 May 2016 at 21:07, Richard Biener wro= te: >>> On Fri, May 20, 2016 at 1:51 AM, Kugan Vivekanandarajah >>> wrote: >>>> Hi Richard, >>>> >>>>> I think it should have the same rank as op or op + 1 which is the cur= rent >>>>> behavior. Sth else doesn't work correctly here I think, like inserti= ng the >>>>> multiplication not near the definition of op. >>>>> >>>>> Well, the whole "clever insertion" logic is simply flawed. >>>> >>>> What I meant to say was that the simple logic we have now wouldn=E2=80= =99t >>>> work. "clever logic" is knowing where exactly where it is needed and >>>> inserting there. I think thats what you are suggesting below in a >>>> simple to implement way. >>>> >>>>> I'd say that ideally we would delay inserting the multiplication to >>>>> rewrite_expr_tree time. For example by adding a ops->stmt_to_insert >>>>> member. >>>>> >>>> >>>> Here is an implementation based on above. Bootstrap on x86-linux-gnu >>>> is OK. regression testing is ongoing. >>> >>> I like it. Please push the insertion code to a helper as I think you n= eed >>> to post-pone setting the stmts UID to that point. >>> >>> Ideally we'd make use of the same machinery in attempt_builtin_powi, >>> removing the special-casing of powi_result. (same as I said that ideal= ly >>> the plus->mult stuff would use the repeat-ops machinery...) >>> >>> I'm not 100% convinced the place you insert the stmt is correct but I >>> haven't spent too much time to decipher reassoc in this area. >> >> >> Hi Richard, >> >> Thanks. Here is a tested version of the patch. I did miss one place >> which I fixed now (tranform_stmt_to_copy) I also created a function to >> do the insertion. >> >> >> Bootstrap and regression testing on x86_64-linux-gnu are fine. Is this >> OK for trunk. > > @@ -3798,6 +3805,7 @@ rewrite_expr_tree (gimple *stmt, unsigned int opind= ex, > oe1 =3D ops[opindex]; > oe2 =3D ops[opindex + 1]; > > + > if (rhs1 !=3D oe1->op || rhs2 !=3D oe2->op) > { > gimple_stmt_iterator gsi =3D gsi_for_stmt (stmt); > > please remove this stray change. > > Ok with that change. Hi Richard, Thanks for the review. I also found another issue with this patch. I.e. for the stmt_to_insert we will get gimple_bb of NULL which is not expected in sort_by_operand_rank. This only showed up only while building a version of glibc. Bootstrap and regression testing are ongoing.Is this OK for trunk if passes regression and bootstrap. Thanks, Kugan gcc/ChangeLog: 2016-05-24 Kugan Vivekanandarajah * tree-ssa-reassoc.c (sort_by_operand_rank): Check for gimple_bb of NULL for stmt_to_insert. gcc/testsuite/ChangeLog: 2016-05-24 Kugan Vivekanandarajah * gcc.dg/tree-ssa/reassoc-44.c: New test. --001a113e76b8217d9a05338df1fd Content-Type: text/plain; charset=US-ASCII; name="p.txt" Content-Disposition: attachment; filename="p.txt" Content-Transfer-Encoding: base64 X-Attachment-Id: f_iokv9d8g0 Content-length: 1212 ZGlmZiAtLWdpdCBhL2djYy90ZXN0c3VpdGUvZ2NjLmRnL3RyZWUtc3NhL3Jl YXNzb2MtNDQuYyBiL2djYy90ZXN0c3VpdGUvZ2NjLmRnL3RyZWUtc3NhL3Jl YXNzb2MtNDQuYwppbmRleCBlNjlkZTI5Li45YjEyMjEyIDEwM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