From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 16678 invoked by alias); 1 Sep 2019 16:34:32 -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 16667 invoked by uid 89); 1 Sep 2019 16:34:31 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-7.5 required=5.0 tests=AWL,BAYES_00,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS autolearn=ham version=3.3.1 spammy= X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Sun, 01 Sep 2019 16:34:30 +0000 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 86C948535D; Sun, 1 Sep 2019 16:34:29 +0000 (UTC) Received: from tucnak.zalov.cz (ovpn-116-139.ams2.redhat.com [10.36.116.139]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3147B5C1B2; Sun, 1 Sep 2019 16:34:29 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.15.2/8.15.2) with ESMTP id x81GYQHQ020389; Sun, 1 Sep 2019 18:34:27 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.15.2/8.15.2/Submit) id x81GYP8x020388; Sun, 1 Sep 2019 18:34:25 +0200 Date: Sun, 01 Sep 2019 16:34:00 -0000 From: Jakub Jelinek To: Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: Re: [PATCH] Fix up go regressions caused by my recent switchconv changes (PR go/91617) Message-ID: <20190901163425.GK2120@tucnak> Reply-To: Jakub Jelinek References: <20190831131207.GF2120@tucnak> <20190831174117.GG2120@tucnak> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.11.3 (2019-02-01) X-IsSubscribed: yes X-SW-Source: 2019-09/txt/msg00014.txt.bz2 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)? 2019-09-01 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 12:26:39.303884758 +0200 +++ gcc/fold-const.c 2019-09-01 18:22:41.866023675 +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; @@ -5049,9 +5048,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