From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 13105 invoked by alias); 29 Aug 2018 14:13:04 -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 12755 invoked by uid 89); 29 Aug 2018 14:13:04 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.2 spammy=abstraction, howdy!, phew, H*f:sk:ca140cb X-HELO: mail-wm0-f42.google.com Received: from mail-wm0-f42.google.com (HELO mail-wm0-f42.google.com) (74.125.82.42) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Wed, 29 Aug 2018 14:13:02 +0000 Received: by mail-wm0-f42.google.com with SMTP id s12-v6so5455693wmc.0 for ; Wed, 29 Aug 2018 07:13:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=date:in-reply-to:references:mime-version:content-transfer-encoding :subject:to:from:message-id; bh=nvr2dLKQRTdDTlHzaO/bGvaXSkCqPS2t2gPiV9ra0eY=; b=vZXCCxAX36tFzQYLo1A/zxHLa7b6ENxWtmmgetp8DiO2xYEcCVaC7mW1vHzbUJTn1Y 0FJ/bp41HuBz+/hdeNUEd+NRAE8lW7WgsbILZsPclz3QQAdBik507WRhMQrNV+X18C+7 Jxn3D5a8KNI+qV4nh0wLTiEyM0wZCltvP2l+VeYOkAzp5CsmWf3vR/xa063b9XNbtCx9 1Iiu99HoIvgTBoN1Q4p8JBb/u2SH0ZZyy+WCVop6qG0i+rrY9U3sb7RKcIaloWUGW9XG DFgfXPXXOCVf54YJ8j4hI/ECgIPH3QCIgG4lWLaTUBVKEfIT1DzCq34wUZimkcofo6TK J/+w== Return-Path: Received: from s49-gx7-B.weghof (217-149-175-40.nat.highway.telekom.at. [217.149.175.40]) by smtp.gmail.com with ESMTPSA id b5-v6sm2689915wrs.62.2018.08.29.07.12.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 Aug 2018 07:12:59 -0700 (PDT) Date: Wed, 29 Aug 2018 14:13:00 -0000 In-Reply-To: References: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Subject: Re: VRP: abstract out wide int CONVERT_EXPR_P code To: gcc-patches@gcc.gnu.org,Aldy Hernandez ,Richard Biener ,gcc-patches From: Bernhard Reutner-Fischer Message-ID: X-IsSubscribed: yes X-SW-Source: 2018-08/txt/msg01873.txt.bz2 On 27 August 2018 14:24:33 CEST, Aldy Hernandez wrote: >Howdy! > >Phew, I think this is the last abstraction. This handles the unary=20 >CONVERT_EXPR_P code. +bool +wide_int_range_convert_tree (tree &tmin, tree &tmax, + tree outer_type, + signop inner_sign, + unsigned inner_prec, + const wide_int &vr0_min, + const wide_int &vr0_max) +{ + /* If the conversion is not truncating we can convert the min and + max values and canonicalize the resulting range. Otherwise we + can do the conversion if the size of the range is less than what + the precision of the target type can represent. */ + if (TYPE_PRECISION (outer_type) >=3D inner_prec + || wi::rshift (wi::sub (vr0_max, vr0_min), + wi::uhwi (TYPE_PRECISION (outer_type), inner_prec), + inner_sign) =3D=3D 0) + { + signop outer_sign =3D TYPE_SIGN (outer_type); + outer_sign =3D inner_sign; AFAIU you don't need outer_sign at all ( since you want inner_sign always )= or what subtlety am I missing? Thanks, + tmin =3D force_fit_type (outer_type, + widest_int::from (vr0_min, outer_sign), 0, false); + tmax =3D force_fit_type (outer_type, + widest_int::from (vr0_max, outer_sign), 0, false); + return (!operand_equal_p (tmin, TYPE_MIN_VALUE (outer_type), 0) + || !operand_equal_p (tmax, TYPE_MAX_VALUE (outer_type), 0)); + } + return false; +}