From patchwork Wed Jul 27 00:10:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kugan Vivekanandarajah X-Patchwork-Id: 72834 Delivered-To: patch@linaro.org Received: by 10.140.29.52 with SMTP id a49csp1964814qga; Tue, 26 Jul 2016 17:11:33 -0700 (PDT) X-Received: by 10.66.88.131 with SMTP id bg3mr44932551pab.43.1469578293480; Tue, 26 Jul 2016 17:11:33 -0700 (PDT) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id k29si3092451pfk.57.2016.07.26.17.11.33 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Jul 2016 17:11:33 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-432580-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org; spf=pass (google.com: domain of gcc-patches-return-432580-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=gcc-patches-return-432580-patch=linaro.org@gcc.gnu.org; dmarc=fail (p=NONE dis=NONE) header.from=linaro.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:references:cc:message-id:date:mime-version :in-reply-to:content-type; q=dns; s=default; b=OTEHXYCgiLxUu8J40 gBaVa5unbqf69G7THI9ezs2FigZFY6/JfwDMeoDvdzDDUb9RtmsG0bh/f3odK0G+ s81sHDngrntfEv6jI05f8FERareI6VR3/KiFIkKrBelw1FOFk+fpw4/1tyP6JPd1 NDva2deiiSdaUmHb5gsF+WhS54= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:from :subject:to:references:cc:message-id:date:mime-version :in-reply-to:content-type; s=default; bh=5zhYWB2VJosTIhusyo1knmX fvLU=; b=cJBzeoY6j9/8ZxFUatORqgkyOum6Nuf1X2/wm2stoDkOP00ED6RYIgT UpkV9TvDxWerwtgEucpQEaEGuupvMUk4Zy/dOuzZB7jT2F59W24ae90OHPKPCArd bz0hiqfPCjL6MvkijVvqm95VxJL3PWg8WYThWkfRCiQ7ZDct+BkE= Received: (qmail 70992 invoked by alias); 27 Jul 2016 00:11:19 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 70979 invoked by uid 89); 27 Jul 2016 00:11:18 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.4 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 spammy=2016-07-27, 20160727, Hx-languages-length:1918 X-HELO: mail-pf0-f177.google.com Received: from mail-pf0-f177.google.com (HELO mail-pf0-f177.google.com) (209.85.192.177) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Wed, 27 Jul 2016 00:11:08 +0000 Received: by mail-pf0-f177.google.com with SMTP id x72so4506507pfd.2 for ; Tue, 26 Jul 2016 17:11:08 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:subject:to:references:cc:message-id:date :user-agent:mime-version:in-reply-to; bh=QmH88lI9QWLKsmcd6iIEsWRE4f9kbvijF7AW+uvjFAk=; b=C7+Ko7DNK5rKSEPC8BeQxet3dObFmTlA228+3xnTwA8sPFoNYs8TQ7hg/bZ2NKJq6V PMRZHCYb9nkA2QbiDs3fY55HCEFXj6uQuahnQXMPMlQLet6UJo3W2gnsdKcd4gtQeHqs Z+GDywmYxNYVdU2JEt7bt+rlqG5vCMLl9OZxSvFOsKxbJ7v2KMYzUZ8aFxNItv98Yl9Y Vsd2P5EDLKQez8nfS8BAexGp9LrdIl25txc2cXjym02WfaHggU6Pu3L+QXAYH/4aSHJn mojBOpJ8HSGlmzwSrxEsph6zUQkvE/Jlw42BJOGKVHll6XIiVgqig2RV5sgBXldvFFJM mizQ== X-Gm-Message-State: AEkoouvpyf2qEgrmwN5XqyY8EiM4RoziwB3j5GBU8C9DRSsoEEPPc6OBnir3uFci9xHtiohy X-Received: by 10.98.8.13 with SMTP id c13mr44321326pfd.166.1469578266778; Tue, 26 Jul 2016 17:11:06 -0700 (PDT) Received: from [10.1.1.4] (58-6-183-210.dyn.iinet.net.au. [58.6.183.210]) by smtp.gmail.com with ESMTPSA id l82sm4114770pfk.8.2016.07.26.17.11.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Jul 2016 17:11:05 -0700 (PDT) From: kugan Subject: Re: [Bug tree-optimization] Fix for PR71994 To: Jeff Law , "gcc-patches@gcc.gnu.org" References: <71f2cde7-f575-a1f0-9dba-5fd38d1c03ed@redhat.com> Cc: Richard Biener Message-ID: Date: Wed, 27 Jul 2016 10:10:44 +1000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.2.0 MIME-Version: 1.0 In-Reply-To: <71f2cde7-f575-a1f0-9dba-5fd38d1c03ed@redhat.com> X-IsSubscribed: yes Hi Jeff, Thanks for your comments. .... >> * tree-ssa-reassoc.c (maybe_optimize_range_tests): Check type >> compatibility. > I'd kind of like to see some analysis of how we've got a bool here -- > ISTM it ought to have been converted it to the type of the LHS of the > PHI when propagated. You are right. The problem was with the order of checking tcc_compare and calling get_ops. We ended up calling get_ops where we should not. Bootstrap and regression testing is ongoing. Is this OK for trunk if no regressions? Thanks, Kugan gcc/testsuite/ChangeLog: 2016-07-27 Kugan Vivekanandarajah * gcc.dg/torture/pr71994.c: New test. gcc/ChangeLog: 2016-07-27 Kugan Vivekanandarajah * tree-ssa-reassoc.c (maybe_optimize_range_tests): Check tcc_comparison before calling get_ops. diff --git a/gcc/testsuite/gcc.dg/torture/pr71994.c b/gcc/testsuite/gcc.dg/torture/pr71994.c index e69de29..8f5e92c 100644 --- a/gcc/testsuite/gcc.dg/torture/pr71994.c +++ b/gcc/testsuite/gcc.dg/torture/pr71994.c @@ -0,0 +1,14 @@ +/* PR tree-optimization/71994 */ +/* { dg-do compile } */ +int om, h6; + +void eo (void) +{ + const int tl = 1; + int ln; + + h6 = (om + tl) > 0; + ln = om && (om & h6); + h6 = om; + om = ln < h6; +} diff --git a/gcc/tree-ssa-reassoc.c b/gcc/tree-ssa-reassoc.c index 18cf978..8f2256f 100644 --- a/gcc/tree-ssa-reassoc.c +++ b/gcc/tree-ssa-reassoc.c @@ -3520,10 +3520,10 @@ maybe_optimize_range_tests (gimple *stmt) push into ops the individual range test arguments of the bitwise or resp. and, recursively. */ if (TREE_CODE (rhs) == SSA_NAME - && !get_ops (rhs, code, &ops, - loop_containing_stmt (stmt)) && (TREE_CODE_CLASS (gimple_assign_rhs_code (stmt)) != tcc_comparison) + && !get_ops (rhs, code, &ops, + loop_containing_stmt (stmt)) && has_single_use (rhs)) { /* Otherwise, push the _234 range test itself. */