From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 11281 invoked by alias); 26 Feb 2016 11:02:49 -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 11254 invoked by uid 89); 26 Feb 2016 11:02:49 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_LOW,SPF_PASS autolearn=ham version=3.3.2 spammy=as-is, asis, multiplication, Hx-languages-length:1349 X-HELO: mail-yk0-f174.google.com Received: from mail-yk0-f174.google.com (HELO mail-yk0-f174.google.com) (209.85.160.174) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Fri, 26 Feb 2016 11:02:48 +0000 Received: by mail-yk0-f174.google.com with SMTP id z7so34069621yka.3 for ; Fri, 26 Feb 2016 03:02:48 -0800 (PST) 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=K1SrwlzvHC5hbD4wMw9qlv12Vw4O+esu+gOYWupRMl4=; b=Umn+0Ei/j9YMi7CklHeSS2RPhhx6nXJOCd+BxmvrqpBKTHkgqzFpUBymmcwboj6+rF afjLQ2Gasb3g1WKF9cHE40fMsNA6y1Ue+z+6qgpU2WtiZ7Ty4Ra/Svt10VBIJyjWnyrM ELkPdTXusTwZqkOOjz5WgasCiTAGCJdVXnfbHguJb7gyYEjfRXth0IIaNXKUOO2V7WI7 lomIVQPmgWlcPV1aWfFWLu5VlZxgzT9ulKgQhIJRhH3p7UMWhyqaKMK7Wt+JW+S5M8h4 fsnURVDKLUQt+zthj5VV/HeqZFWo+D74a/fqCWXBcqxjyOIZs+pHeP3GwJBKf2fhb8w6 r8cQ== X-Gm-Message-State: AD7BkJJFjgTkdoky7SqN9cWLFd1w2s+ZrRnoYxrPTUVfODsixK0PMwebBTNTuO6T8Dlvo2atcyga9uGs1wugpg== MIME-Version: 1.0 X-Received: by 10.37.230.151 with SMTP id d145mr448713ybh.132.1456484566297; Fri, 26 Feb 2016 03:02:46 -0800 (PST) Received: by 10.37.216.79 with HTTP; Fri, 26 Feb 2016 03:02:46 -0800 (PST) In-Reply-To: <56CFC02F.2070801@linaro.org> References: <56CFC02F.2070801@linaro.org> Date: Fri, 26 Feb 2016 11:02:00 -0000 Message-ID: Subject: Re: [RFC][PATCH][PR40921] Convert x + (-y * z * z) into x - y * z * z From: Richard Biener To: kugan Cc: "gcc-patches@gcc.gnu.org" Content-Type: text/plain; charset=UTF-8 X-IsSubscribed: yes X-SW-Source: 2016-02/txt/msg01775.txt.bz2 On Fri, Feb 26, 2016 at 4:02 AM, kugan wrote: > > > Hi, > > This is an attempt to fix missed optimization: x + (-y * z * z) => x - y * z > * z as reported in PR40921. > > Regression tested and bootstrapped on x86-64-linux-gnu with no new > regressions. > > Is this OK for next stage1? Err. I think the way you implement that in reassoc is ad-hoc and not related to reassoc at all. In fact what reassoc is missing is to handle -y * z * (-w) * x -> y * x * w * x thus optimize negates as if they were additional * -1 entries in a multiplication chain. And then optimize a single remaining * -1 in the result chain to a negate. Then match.pd handles x + (-y) -> x - y (independent of -frounding-math btw). So no, this isn't ok as-is, IMHO you want to expand the multiplication ops chain pulling in the * -1 ops (if single-use, of course). Richard. > Thanks, > Kugan > > > gcc/ChangeLog: > > 2016-02-26 Kugan Vivekanandarajah > > PR middle-end/40921 > * tree-ssa-reassoc.c (propagate_neg_to_sub_or_add): New. > (reassociate_bb): Call propagate_neg_to_sub_or_add. > > > gcc/testsuite/ChangeLog: > > 2016-02-26 Kugan Vivekanandarajah > > PR middle-end/40921 > * gcc.dg/tree-ssa/pr40921.c: New test.