From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 116259 invoked by alias); 2 Sep 2019 08:29:40 -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 116250 invoked by uid 89); 2 Sep 2019 08:29:39 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-7.0 required=5.0 tests=AWL,BAYES_00,FREEMAIL_FROM,GIT_PATCH_2,GIT_PATCH_3,RCVD_IN_DNSWL_NONE,SPF_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mail-vk1-f195.google.com Received: from mail-vk1-f195.google.com (HELO mail-vk1-f195.google.com) (209.85.221.195) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 02 Sep 2019 08:29:38 +0000 Received: by mail-vk1-f195.google.com with SMTP id u203so2748721vku.3 for ; Mon, 02 Sep 2019 01:29:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=5PR/XDow3qf9iqZAFG1rCfQ7fZSNFTNhNLte3kfoGCE=; b=JVwJdBtglo+B/ttZ711o30nglrSz3+ojP1LpVWxyzkm+qOzdybo+PJ+vM5N+4BnqHR CBc9msOM+jjsg76o2Oq++8IZL3wRuVlvIC8kMwL8XZwYKyZwEvyNcYivJGm/dd2qg8Z9 zGDLUWpU8QFxrRKvfI/u2w0kjAGSWVTexUTzkuHs/BmoImWGFym3D6mCsiGojP5uLXJG CpcNTM/ardLbDLTgdcN1yfJBXT4fgwtEWZvmE68R9D9OSQQEzaxT2BIlzGEBjBZCJm5f C2bObygp58ZMp19RciysN7lBsHhEm5ev5082pBvGuGdBSQGsxC6Z+GR3QwmyPEhlgjRh svrQ== MIME-Version: 1.0 References: <20190831131207.GF2120@tucnak> <20190831174117.GG2120@tucnak> <20190901163425.GK2120@tucnak> <20190902081421.GL2120@tucnak> In-Reply-To: <20190902081421.GL2120@tucnak> From: Andrew Pinski Date: Mon, 02 Sep 2019 08:29:00 -0000 Message-ID: Subject: Re: [PATCH] Fix up go regressions caused by my recent switchconv changes (PR go/91617) To: Jakub Jelinek Cc: Richard Biener , GCC Patches Content-Type: text/plain; charset="UTF-8" X-IsSubscribed: yes X-SW-Source: 2019-09/txt/msg00031.txt.bz2 On Mon, Sep 2, 2019 at 1:14 AM Jakub Jelinek wrote: > > On Sun, Sep 01, 2019 at 06:44:15PM +0200, Richard Biener wrote: > > On September 1, 2019 6:34:25 PM GMT+02:00, Jakub Jelinek wrote: > > >On Sat, Aug 31, 2019 at 08:25:49PM +0200, Richard Biener wrote: > > >> So why not always return an unsigned type then by telling > > >type_for_size? > > > > > >So like this (if it passes bootstrap/regtest)? > > > > Yes. > > Unfortunately that didn't work, because TYPE_MAX_VALUE/TYPE_MIN_VALUE > are not present on POINTER_TYPEs. > > Here is an updated version that passed bootstrap/regtest on both > x86_64-linux and i686-linux, ok for trunk? Seems like this would fix PR91632 also. Which has a C testcase included. Thanks, Andrew Pinski > > 2019-09-02 Jakub Jelinek > > PR go/91617 > * fold-const.c (range_check_type): For enumeral and boolean > type, pass 1 to type_for_size langhook instead of > TYPE_UNSIGNED (etype). Return unsigned_type_for result whenever > etype isn't TYPE_UNSIGNED INTEGER_TYPE. > (build_range_check): Don't call unsigned_type_for for pointer types. > * match.pd (X / C1 op C2): Don't call unsigned_type_for on > range_check_type result. > > --- gcc/fold-const.c.jj 2019-08-27 22:52:24.207334541 +0200 > +++ gcc/fold-const.c 2019-09-01 22:46:17.091058145 +0200 > @@ -4938,10 +4938,9 @@ range_check_type (tree etype) > /* First make sure that arithmetics in this type is valid, then make sure > that it wraps around. */ > if (TREE_CODE (etype) == ENUMERAL_TYPE || TREE_CODE (etype) == BOOLEAN_TYPE) > - etype = lang_hooks.types.type_for_size (TYPE_PRECISION (etype), > - TYPE_UNSIGNED (etype)); > + etype = lang_hooks.types.type_for_size (TYPE_PRECISION (etype), 1); > > - if (TREE_CODE (etype) == INTEGER_TYPE && !TYPE_OVERFLOW_WRAPS (etype)) > + if (TREE_CODE (etype) == INTEGER_TYPE && !TYPE_UNSIGNED (etype)) > { > tree utype, minv, maxv; > > @@ -4959,6 +4958,8 @@ range_check_type (tree etype) > else > return NULL_TREE; > } > + else if (POINTER_TYPE_P (etype)) > + etype = unsigned_type_for (etype); > return etype; > } > > @@ -5049,9 +5050,6 @@ build_range_check (location_t loc, tree > if (etype == NULL_TREE) > return NULL_TREE; > > - if (POINTER_TYPE_P (etype)) > - etype = unsigned_type_for (etype); > - > high = fold_convert_loc (loc, etype, high); > low = fold_convert_loc (loc, etype, low); > exp = fold_convert_loc (loc, etype, exp); > --- gcc/match.pd.jj 2019-08-27 12:26:40.745863588 +0200 > +++ gcc/match.pd 2019-09-01 18:23:02.098729356 +0200 > @@ -1569,8 +1569,6 @@ (define_operator_list COND_TERNARY > tree etype = range_check_type (TREE_TYPE (@0)); > if (etype) > { > - if (! TYPE_UNSIGNED (etype)) > - etype = unsigned_type_for (etype); > hi = fold_convert (etype, hi); > lo = fold_convert (etype, lo); > hi = const_binop (MINUS_EXPR, etype, hi, lo); > > > Jakub