From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 75943 invoked by alias); 18 May 2017 15:36:11 -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 75926 invoked by uid 89); 18 May 2017 15:36:10 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-24.1 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,RCVD_IN_SORBS_SPAM,SPF_PASS autolearn=ham version=3.3.2 spammy= X-HELO: mail-vk0-f66.google.com Received: from mail-vk0-f66.google.com (HELO mail-vk0-f66.google.com) (209.85.213.66) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 18 May 2017 15:36:09 +0000 Received: by mail-vk0-f66.google.com with SMTP id x71so3309626vkd.2 for ; Thu, 18 May 2017 08:36:12 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=2xO5rUE9wLueJk7ywxriECOI38U/7/cmIiKZ4i8CnWo=; b=XCKgzHBsL0b4mOtth3vmD+ck1AKnv/quyyZ9+M+57TX2LTBYYZPKTmK+JFMfk4Z48u HOVCJWwEh0PVcjWcr7vJOGGPciNsVAv4DfOP3OyIUu/g3+Y+FC5Xzxw+uBLwvpLj+/Mo Kgy0tfa1FlJVicFvWdw7XWr7tkePvz8GTf140cUtHrXTHhSKKQN7oEXo9evm/g81uxkE bznoKRguN+vSOc5UfSZ/tTzkOdL1hRSxIvGFWpsZU81LRSPBEgM91QWUM/qBzyigMi2m 5D0gkDvaD4ee6BOCKICwzP3KIrU2fDieWuBlAiPTJae9/9RSlmBMnBh+QUT0kawy9yvc lOYg== X-Gm-Message-State: AODbwcD/ayk4VGK8xTN0NBU8moZc2arRhfjJrMjtF01sSGymrBpfCrLd +fLtAnQbCozRZ1qKhnEB9EoCLNY41g== X-Received: by 10.31.61.16 with SMTP id k16mr2409446vka.43.1495121770815; Thu, 18 May 2017 08:36:10 -0700 (PDT) MIME-Version: 1.0 Received: by 10.103.14.1 with HTTP; Thu, 18 May 2017 08:36:10 -0700 (PDT) In-Reply-To: <803f5629-2a68-db02-a3a1-16fbe656f242@linux.vnet.ibm.com> References: <5790A709.4060804@linux.vnet.ibm.com> <6bc1abab-9b54-fb67-fe98-9aaf993859dd@linux.vnet.ibm.com> <27be603c-4499-ca96-f252-40934d3e420d@linux.vnet.ibm.com> <260c4925-29e2-d50a-871e-397e2f9f4efb@linux.vnet.ibm.com> <803f5629-2a68-db02-a3a1-16fbe656f242@linux.vnet.ibm.com> From: "Bin.Cheng" Date: Thu, 18 May 2017 15:46:00 -0000 Message-ID: Subject: Re: [PATCH 2/3] Simplify wrapped binops To: Robin Dapp Cc: Richard Biener , GCC Patches Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2017-05/txt/msg01474.txt.bz2 On Thu, May 18, 2017 at 3:47 PM, Robin Dapp wrote: > match.pd part of the patch. > > gcc/ChangeLog: > > 2017-05-18 Robin Dapp > > * match.pd: Simplify wrapped binary operations. > * tree-vrp.c (extract_range_from_binary_expr_1): Add overflow > parameter. > (extract_range_from_binary_expr): Likewise. > * tree-vrp.h: Export. Hi, I didn't follow this issue from the beginning, so might asking stupid questions. > diff --git a/gcc/match.pd b/gcc/match.pd > index 80a17ba..3fa18b9 100644 > --- a/gcc/match.pd > +++ b/gcc/match.pd > @@ -1290,6 +1290,85 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) > (if (cst && !TREE_OVERFLOW (cst)) > (plus { cst; } @0)))) > > +/* ((T)(A +- CST)) +- CST -> (T)(A) +- CST) */ > +#if GIMPLE > + (for outer_op (plus minus) > + (for inner_op (plus minus) > + (simplify > + (outer_op (convert (inner_op@3 @0 INTEGER_CST@1)) INTEGER_CST@2) > + (if (TREE_CODE (type) == INTEGER_TYPE > + && TYPE_PRECISION (type) > TYPE_PRECISION (TREE_TYPE (@3))) > + (with > + { > + bool ovf = true; > + > + tree cst = NULL_TREE; > + tree inner_type = TREE_TYPE (@3); > + value_range vr = VR_INITIALIZER; > + > + /* Convert combined constant to tree of outer type if > + there was no overflow in the original operation. */ > + wide_int minv, maxv; > + if (TYPE_OVERFLOW_UNDEFINED (inner_type) > + || (extract_range_from_binary_expr (&vr, inner_op, > + inner_type, @0, @1, &ovf), vr.type == VR_RANGE)) Any reason to expose tree-vrp.c internal interface here? The function looks quite expensive. Overflow check can be done by get_range_info and simple wi::cmp calls. Existing code like in tree-ssa-loop-niters.c already does that. Also could you avoid using comma expressions in condition please? It only makes the code harder to be read. Thanks, bin