From patchwork Wed Sep 20 07:23:25 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 142260 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:612c:172:b0:3f2:4152:657d with SMTP id h50csp3940782vqi; Wed, 20 Sep 2023 00:24:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFVYKuOuNXSq2CgAKqaeN5Qye1lneJ+1yNbl8YeIlKxHnqIakE/r8agEOuwoy4OztMr1GnL X-Received: by 2002:a17:906:8a4c:b0:9a6:4f23:9d8f with SMTP id gx12-20020a1709068a4c00b009a64f239d8fmr1200744ejc.47.1695194681600; Wed, 20 Sep 2023 00:24:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695194681; cv=none; d=google.com; s=arc-20160816; b=ZsEN7K9HURULk47dycp2wy8lwj+5uFUJ8jH/z6/KwvHKImBYoZNlHKoLO/nU9txbHE HMYlZKjW/paHV+BshQnCbizi/yWS8a91toJgQRxIOuNxCb4QplPCxz19ATQdrSvclEvR RFgTEga40RojKfNJMb0CdAYc6IBN7Wnh60y78SoTOp+GejxbtrIOEDF5Hz5tUUtXweoa 0Xhzr6xXueaBUNFCuxnRZhN2/PQB9TciYZ/1CAtN0gw/71SCNGhpswCXwEdZiNIxz7TP GS71GTQVXiNb1RJ/GkuOOyfABKqaGZOGd77kph0hkSNvvxGlZB+oZuXpBV8AZKzkbjrJ y6Lw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:reply-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-disposition:in-reply-to :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature:dmarc-filter:delivered-to; bh=Ddw3o8t3nYr67kNSU5Zd8aVnc2XHd9SVX4hhLbve+Ks=; fh=4oceweYoeRficmRLZMsxda+FDNTH2F5JsJJ9Vyr2AeQ=; b=0WiuVg8KzCEzeXQlzB6q2r67cG8wLtCHx7iuTcINJLhumCFcYy6hiyssgydEZQ/+oj DwD1x85ACOtsoZ0sgwPhAmb88cQq6urhTgWAonx8aCEUwg4vyQLeChJFR1rT2xO5+7qu au+wp2+Ykoaj52W5KhCJHkW1dsvfOBWZ+nUYThmIW4Hzgb/5S3kYI24trHCQyJAY2vm6 nKd5xzoSyHS89Zx0xzmvVlJ6mOj3DAuEF7WReg2J51Mgv3CmsLMmsZlp0+rVX8DsRfvB pu4pHjfntLoXNti8/wa0syBlBqLojpAtcm8p0KwnLSF0WqtPiw4s41keCgIJOOmvFSXB e8PQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SDKbtQn3; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id mf4-20020a170906cb8400b00992c30f5887si12129234ejb.474.2023.09.20.00.24.41 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Sep 2023 00:24:41 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) client-ip=2620:52:3:1:0:246e:9693:128c; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=SDKbtQn3; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 2620:52:3:1:0:246e:9693:128c as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id EE513385E83C for ; Wed, 20 Sep 2023 07:24:00 +0000 (GMT) X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 7FF393858D20 for ; Wed, 20 Sep 2023 07:23:35 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 7FF393858D20 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1695194614; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=Ddw3o8t3nYr67kNSU5Zd8aVnc2XHd9SVX4hhLbve+Ks=; b=SDKbtQn3i54WA+HzWNknnsnjcVgO5ZjShLiiQFprNCFOSnWbvUPvYg6tKcPkNUZzcyBx9F e3RAPLEYwLMJBxy4/5+8roydakaOaqW+GMV6htzoMzKWZJQ4O2GFtr+80vx9OQVHOc9cay /kpRJeQhJoK1d5TyaVxf6Dpd3rFCG6g= Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-593-3bhZyNbOMiSWCeUB8uqyjQ-1; Wed, 20 Sep 2023 03:23:29 -0400 X-MC-Unique: 3bhZyNbOMiSWCeUB8uqyjQ-1 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 90BFD185A790; Wed, 20 Sep 2023 07:23:29 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.193.241]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5147D492B16; Wed, 20 Sep 2023 07:23:29 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 38K7NQqR1141021 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Wed, 20 Sep 2023 09:23:26 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 38K7NPSK1141020; Wed, 20 Sep 2023 09:23:25 +0200 Date: Wed, 20 Sep 2023 09:23:25 +0200 From: Jakub Jelinek To: richard.sandiford@arm.com, Richard Biener Cc: gcc-patches@gcc.gnu.org Subject: [PATCH] middle-end: use MAX_FIXED_MODE_SIZE instead of precidion of TImode/DImode Message-ID: References: MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 3.1 on 10.11.54.9 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-3.4 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: Jakub Jelinek Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1777540458385455175 X-GMAIL-MSGID: 1777540458385455175 Hi! On Tue, Sep 19, 2023 at 05:50:59PM +0100, Richard Sandiford wrote: > How about using MAX_FIXED_MODE_SIZE for things like this? Seems like a good idea. The following patch does that. Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk? 2023-09-20 Jakub Jelinek * match.pd ((x << c) >> c): Use MAX_FIXED_MODE_SIZE instead of GET_MODE_PRECISION of TImode or DImode depending on whether TImode is supported scalar mode. * gimple-lower-bitint.cc (bitint_precision_kind): Likewise. * expr.cc (expand_expr_real_1): Likewise. * tree-ssa-sccvn.cc (eliminate_dom_walker::eliminate_stmt): Likewise. * ubsan.cc (ubsan_encode_value, ubsan_type_descriptor): Likewise. Jakub --- gcc/match.pd.jj 2023-09-19 19:47:23.969430272 +0200 +++ gcc/match.pd 2023-09-19 20:08:17.341559409 +0200 @@ -4124,9 +4124,7 @@ (define_operator_list SYNC_FETCH_AND_AND (with { int width = element_precision (type) - tree_to_uhwi (@1); tree stype = NULL_TREE; - scalar_int_mode mode = (targetm.scalar_mode_supported_p (TImode) - ? TImode : DImode); - if (width <= GET_MODE_PRECISION (mode)) + if (width <= MAX_FIXED_MODE_SIZE) stype = build_nonstandard_integer_type (width, 0); } (if (stype && (width == 1 || type_has_mode_precision_p (stype))) --- gcc/gimple-lower-bitint.cc.jj 2023-09-08 11:29:20.105768005 +0200 +++ gcc/gimple-lower-bitint.cc 2023-09-19 20:01:50.927782331 +0200 @@ -100,21 +100,19 @@ bitint_precision_kind (int prec) small_max_prec = prec; return bitint_prec_small; } - scalar_int_mode arith_mode = (targetm.scalar_mode_supported_p (TImode) - ? TImode : DImode); if (!large_min_prec - && GET_MODE_PRECISION (arith_mode) > GET_MODE_PRECISION (limb_mode)) - large_min_prec = GET_MODE_PRECISION (arith_mode) + 1; + && GET_MODE_PRECISION (limb_mode) < MAX_FIXED_MODE_SIZE) + large_min_prec = MAX_FIXED_MODE_SIZE + 1; if (!limb_prec) limb_prec = GET_MODE_PRECISION (limb_mode); if (!huge_min_prec) { - if (4 * limb_prec >= GET_MODE_PRECISION (arith_mode)) + if (4 * limb_prec >= MAX_FIXED_MODE_SIZE) huge_min_prec = 4 * limb_prec; else - huge_min_prec = GET_MODE_PRECISION (arith_mode) + 1; + huge_min_prec = MAX_FIXED_MODE_SIZE + 1; } - if (prec <= GET_MODE_PRECISION (arith_mode)) + if (prec <= MAX_FIXED_MODE_SIZE) { if (!mid_min_prec || prec < mid_min_prec) mid_min_prec = prec; --- gcc/expr.cc.jj 2023-09-08 11:29:20.101768059 +0200 +++ gcc/expr.cc 2023-09-19 20:00:12.788108832 +0200 @@ -11044,17 +11044,11 @@ expand_expr_real_1 (tree exp, rtx target scalar_int_mode limb_mode = as_a (info.limb_mode); unsigned int limb_prec = GET_MODE_PRECISION (limb_mode); - if (prec > limb_prec) + if (prec > limb_prec && prec > MAX_FIXED_MODE_SIZE) { - scalar_int_mode arith_mode - = (targetm.scalar_mode_supported_p (TImode) - ? TImode : DImode); - if (prec > GET_MODE_PRECISION (arith_mode)) - { - /* Emit large/huge _BitInt INTEGER_CSTs into memory. */ - exp = tree_output_constant_def (exp); - return expand_expr (exp, target, VOIDmode, modifier); - } + /* Emit large/huge _BitInt INTEGER_CSTs into memory. */ + exp = tree_output_constant_def (exp); + return expand_expr (exp, target, VOIDmode, modifier); } } --- gcc/tree-ssa-sccvn.cc.jj 2023-09-18 15:14:48.987358112 +0200 +++ gcc/tree-ssa-sccvn.cc 2023-09-19 20:02:53.160941163 +0200 @@ -7004,10 +7004,7 @@ eliminate_dom_walker::eliminate_stmt (ba && !type_has_mode_precision_p (TREE_TYPE (lhs))) { if (TREE_CODE (TREE_TYPE (lhs)) == BITINT_TYPE - && (TYPE_PRECISION (TREE_TYPE (lhs)) - > (targetm.scalar_mode_supported_p (TImode) - ? GET_MODE_PRECISION (TImode) - : GET_MODE_PRECISION (DImode)))) + && TYPE_PRECISION (TREE_TYPE (lhs)) > MAX_FIXED_MODE_SIZE) lookup_lhs = NULL_TREE; else if (TREE_CODE (lhs) == COMPONENT_REF || TREE_CODE (lhs) == MEM_REF) --- gcc/ubsan.cc.jj 2023-09-08 11:29:20.136767581 +0200 +++ gcc/ubsan.cc 2023-09-19 20:06:56.118657251 +0200 @@ -136,13 +136,10 @@ ubsan_encode_value (tree t, enum ubsan_e } else { - scalar_int_mode arith_mode - = (targetm.scalar_mode_supported_p (TImode) ? TImode : DImode); - if (TYPE_PRECISION (type) > GET_MODE_PRECISION (arith_mode)) + if (TYPE_PRECISION (type) > MAX_FIXED_MODE_SIZE) return build_zero_cst (pointer_sized_int_node); - type - = build_nonstandard_integer_type (GET_MODE_PRECISION (arith_mode), - TYPE_UNSIGNED (type)); + type = build_nonstandard_integer_type (MAX_FIXED_MODE_SIZE, + TYPE_UNSIGNED (type)); t = fold_build1 (NOP_EXPR, type, t); } } @@ -381,14 +378,9 @@ ubsan_type_descriptor (tree type, enum u { /* Temporary hack for -fsanitize=shift with _BitInt(129) and more. libubsan crashes if it is not TK_Integer type. */ - if (TREE_CODE (type) == BITINT_TYPE) - { - scalar_int_mode arith_mode - = (targetm.scalar_mode_supported_p (TImode) - ? TImode : DImode); - if (TYPE_PRECISION (type) > GET_MODE_PRECISION (arith_mode)) - type3 = build_qualified_type (type, TYPE_QUAL_CONST); - } + if (TREE_CODE (type) == BITINT_TYPE + && TYPE_PRECISION (type) > MAX_FIXED_MODE_SIZE) + type3 = build_qualified_type (type, TYPE_QUAL_CONST); if (type3 == type) pstyle = UBSAN_PRINT_NORMAL; } @@ -523,16 +515,10 @@ ubsan_type_descriptor (tree type, enum u tkind = 0x0000; break; case BITINT_TYPE: - { - /* FIXME: libubsan right now only supports _BitInts which - fit into DImode or TImode. */ - scalar_int_mode arith_mode = (targetm.scalar_mode_supported_p (TImode) - ? TImode : DImode); - if (TYPE_PRECISION (eltype) <= GET_MODE_PRECISION (arith_mode)) - tkind = 0x0000; - else - tkind = 0xffff; - } + if (TYPE_PRECISION (eltype) <= MAX_FIXED_MODE_SIZE) + tkind = 0x0000; + else + tkind = 0xffff; break; case REAL_TYPE: /* FIXME: libubsan right now only supports float, double and @@ -553,9 +539,7 @@ ubsan_type_descriptor (tree type, enum u if (pstyle == UBSAN_PRINT_FORCE_INT) { tkind = 0x0000; - scalar_int_mode arith_mode = (targetm.scalar_mode_supported_p (TImode) - ? TImode : DImode); - tree t = lang_hooks.types.type_for_mode (arith_mode, + tree t = build_nonstandard_integer_type (MAX_FIXED_MODE_SIZE, TYPE_UNSIGNED (eltype)); tinfo = get_ubsan_type_info_for_type (t); }