From patchwork Thu Oct 1 08:20:57 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Collison X-Patchwork-Id: 54346 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-lb0-f197.google.com (mail-lb0-f197.google.com [209.85.217.197]) by patches.linaro.org (Postfix) with ESMTPS id E948C23009 for ; Thu, 1 Oct 2015 08:21:19 +0000 (UTC) Received: by lbwr8 with SMTP id r8sf3069184lbw.0 for ; Thu, 01 Oct 2015 01:21:18 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:mailing-list:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:sender :delivered-to:message-id:date:from:user-agent:mime-version:to:cc :subject:references:in-reply-to:content-type:x-original-sender :x-original-authentication-results; bh=ukvDSdqmEkQyz1xcXXr0DVLncYsFZxmFzT6Qa/wTOx0=; b=hjIe8s1XerKnH1HgmE8BHCbMFLkQD3Vn5UeovYh7C3yijbcB0l83/e3MVLKIfldUbb ud69brWqLCAphH/VVjD3Tojox9ntCPGN6NVwYzGgd0gAACDom72/WhYpH8lKfGaqOSLm Qfsb9eKKJqyhSAoYGdNNdVOpvdsRxPDMsDOdSh7qLa06KRz0TH+Z91t6ZEnHPsCg4GrW Hyk0liXnNagnmlBqy0Gdu423PW8AY0lTiR7jQEKVP5nlFZMgo90oy43n0pwlqOMKj6xJ qfYhqWrUD1isw11h/0ycc1CkX623MjpYMPuaoq5YBH1MdWiVWt4srhhV9V/aVy9fBsPy Z3tQ== X-Gm-Message-State: ALoCoQmL3NoKAHk9QbJ0mjIX2HjEEGlR+9mZEAskSNgo6TY6XBce8iKtz28iMe4XcGoSPD8aFn6B X-Received: by 10.180.81.165 with SMTP id b5mr257130wiy.1.1443687678856; Thu, 01 Oct 2015 01:21:18 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.45.73 with SMTP id k9ls89895lam.19.gmail; Thu, 01 Oct 2015 01:21:18 -0700 (PDT) X-Received: by 10.112.13.161 with SMTP id i1mr2454439lbc.96.1443687678704; Thu, 01 Oct 2015 01:21:18 -0700 (PDT) Received: from mail-lb0-x231.google.com (mail-lb0-x231.google.com. [2a00:1450:4010:c04::231]) by mx.google.com with ESMTPS id 82si2251891lfu.87.2015.10.01.01.21.18 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Oct 2015 01:21:18 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::231 as permitted sender) client-ip=2a00:1450:4010:c04::231; Received: by lbcao8 with SMTP id ao8so4743985lbc.3 for ; Thu, 01 Oct 2015 01:21:18 -0700 (PDT) X-Received: by 10.152.7.38 with SMTP id g6mr2392945laa.106.1443687678586; Thu, 01 Oct 2015 01:21:18 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.59.35 with SMTP id w3csp432488lbq; Thu, 1 Oct 2015 01:21:17 -0700 (PDT) X-Received: by 10.68.65.2 with SMTP id t2mr10265768pbs.75.1443687677290; Thu, 01 Oct 2015 01:21:17 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id ex1si1461950pbb.19.2015.10.01.01.21.16 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Oct 2015 01:21:17 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-return-408795-patch=linaro.org@gcc.gnu.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 62564 invoked by alias); 1 Oct 2015 08:21:04 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list 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 62549 invoked by uid 89); 1 Oct 2015 08:21:03 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.3 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-pa0-f47.google.com Received: from mail-pa0-f47.google.com (HELO mail-pa0-f47.google.com) (209.85.220.47) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with (AES128-GCM-SHA256 encrypted) ESMTPS; Thu, 01 Oct 2015 08:21:01 +0000 Received: by pablk4 with SMTP id lk4so67155122pab.3 for ; Thu, 01 Oct 2015 01:21:00 -0700 (PDT) X-Received: by 10.66.164.132 with SMTP id yq4mr10744417pab.8.1443687659979; Thu, 01 Oct 2015 01:20:59 -0700 (PDT) Received: from [192.168.1.14] (ip70-176-202-128.ph.ph.cox.net. [70.176.202.128]) by smtp.googlemail.com with ESMTPSA id jv5sm5026317pbc.47.2015.10.01.01.20.58 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Oct 2015 01:20:59 -0700 (PDT) Message-ID: <560CECE9.6040905@linaro.org> Date: Thu, 01 Oct 2015 01:20:57 -0700 From: Michael Collison User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: gcc-patches@gcc.gnu.org CC: Richard Biener , Marc Glisse , Jeff Law Subject: Re: [PATCH] Optimize certain end of loop conditions into min/max operation References: <55B5A884.4060105@linaro.org> <55B65A4B.3050705@redhat.com> <55BBA052.2060900@redhat.com> <55BBBBE6.2070207@linaro.org> <55BBBE2E.1020408@redhat.com> <55FBAFD1.9080300@linaro.org> <560B8F51.6030108@linaro.org> <560C0D65.2010300@linaro.org> <560CE7BF.30709@linaro.org> In-Reply-To: X-Original-Sender: michael.collison@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 2a00:1450:4010:c04::231 as permitted sender) smtp.mailfrom=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@gcc.gnu.org X-Google-Group-Id: 836684582541 Marc, Ah I did misunderstand you. Patch with match.pd formatting fix. On 10/01/2015 01:05 AM, Marc Glisse wrote: > On Thu, 1 Oct 2015, Michael Collison wrote: > >> ChangeLog formatting and test case fixed. > > Oups, sorry for the lack of precision, but I meant indenting the code > in match.pd, I hadn't even looked at the ChangeLog. > diff --git a/gcc/match.pd b/gcc/match.pd index bd5c267..caf3c82 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -2311,3 +2311,13 @@ along with GCC; see the file COPYING3. If not see (with { tree utype = unsigned_type_for (TREE_TYPE (@0)); } (convert (bit_and (op (convert:utype @0) (convert:utype @1)) (convert:utype @4)))))))) + +/* Transform (@0 < @1 and @0 < @2) to use min, + (@0 > @1 and @0 > @2) to use max */ +(for op (lt le gt ge) + ext (min min max max) + (simplify + (bit_and (op:s @0 @1) (op:s @0 @2)) + (if (INTEGRAL_TYPE_P (TREE_TYPE (@0))) + (op @0 (ext @1 @2))))) + diff --git a/gcc/testsuite/gcc.dg/tree-ssa/minmax-loopend.c b/gcc/testsuite/gcc.dg/tree-ssa/minmax-loopend.c new file mode 100644 index 0000000..2e4300c --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/minmax-loopend.c @@ -0,0 +1,17 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-optimized" } */ + +int min_test(long a, long b, long c) { + int cmp1 = a < b; + int cmp2 = a < c; + return cmp1 & cmp2; +} + +int max_test (long a, long b, long c) { + int cmp1 = a > b; + int cmp2 = a > c; + return cmp1 & cmp2; +} + +/* { dg-final { scan-tree-dump-times "MIN_EXPR" 1 "optimized" } } */ +/* { dg-final { scan-tree-dump-times "MAX_EXPR" 1 "optimized" } } */ -- 1.9.1