From patchwork Fri Jun 23 08:26:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 111977 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp5616929vqr; Fri, 23 Jun 2023 01:27:39 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5RuYJQvMjypL6xFWWwx8GMcG/fq12w7nsR1kOmXxr20nJ/WysrjwQQL7fgg2SXNWMNVDSu X-Received: by 2002:a17:907:805:b0:989:450:e57d with SMTP id wv5-20020a170907080500b009890450e57dmr9049740ejb.73.1687508859271; Fri, 23 Jun 2023 01:27:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687508859; cv=none; d=google.com; s=arc-20160816; b=KBvc5wcPCMAWH4VhMoJwbGe85qaH3UNVGtm+LyWjjU5aKFvYLBlHwNH2dpwvgt/XG/ htUQDo9fy09BA6OEAazm3cD6CpR5YkH40V8hV0eaH1Zs71GYFX0tJEdYkleRo7qHj9rn 6mvLFRJ4sKHxI46QI6Q/nCv3R3iRlPQhKE/eyESlNskgPApExhQUsEK7NJW+Lxqgw6t/ WBcwFAOznrKLdNvsCcckne6Kp/pkyEGUcssR8wa8cfKOGjXE/tFt+/WM+HNZ91Q/uZ+2 A8WLt/WF/PLEbiTrULyfhRDAvKqoSLMdXGqgDj9/oRP2PTNwKDm0hhoQDeqaoUvAgPsJ 7XHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:message-id :mime-version:subject:cc:to:date:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=tVRVzH0imIlN0zOre0iPmouIYcfhc/vNpp/4FDE/YDY=; b=WC3wRdJWMXEED0moP/FP3ktqiBrjub57XmGaoDzN8djFi8/gcDQMHYN7OsIaoyx5/W iG3gOCk9zpXMLqSZaskygsk7o/umM7F8PPDMTR/twmXxyZbjSJQqFlqoK3ktGTvSizX3 BkL1OyqYTejm/aUvXp+6TK9GISI/QQZF9xyGDplIUKB6h8FzwIXQA5c4Juf8BvNIMPnC uPiqpbd/GLgF8LQZ/w7a8pVhNx231JbkeNLmVMOHA47BTmXHN9znAYB4iUJIEGdNb+zy 37VCm4AY0q6txAJVXi02C9Es6bY88wYfI8Es75uBQq6CSoI2DdDtesF8TsVrTWmNJ1Nq JwjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="NE1l/11T"; 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=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id m24-20020a1709062ad800b00987312f6d80si1341940eje.378.2023.06.23.01.27.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Jun 2023 01:27:39 -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=@gcc.gnu.org header.s=default header.b="NE1l/11T"; 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=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 575FB385770D for ; Fri, 23 Jun 2023 08:27:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 575FB385770D DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687508849; bh=tVRVzH0imIlN0zOre0iPmouIYcfhc/vNpp/4FDE/YDY=; h=Date:To:cc:Subject:List-Id:List-Unsubscribe:List-Archive: List-Post:List-Help:List-Subscribe:From:Reply-To:From; b=NE1l/11TJXZCgszjpA/wRbxDp7X1+3VdTx7Wvy3BgvbrczExZHW3z4gIQGFzZBBVl fqYC2w7+aEmkztDIAOJukvavSGDiPgkBEPBYEFTqAQkPYxjv9eAbfkGrNK8fcnTDUN tQJOCosdziFiY5oVpSAv8U/HePqwFDW6cJk5wftA= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id E1E793858288 for ; Fri, 23 Jun 2023 08:26:42 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org E1E793858288 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 21A6721B98; Fri, 23 Jun 2023 08:26:42 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 0811A1331F; Fri, 23 Jun 2023 08:26:42 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id Cx3EAEJXlWT3TAAAMHmgww (envelope-from ); Fri, 23 Jun 2023 08:26:42 +0000 Date: Fri, 23 Jun 2023 10:26:41 +0200 (CEST) To: gcc-patches@gcc.gnu.org cc: polacek@redhat.com Subject: [PATCH 1/6] Avoid shorten_binary_op on VECTOR_TYPE MIME-Version: 1.0 Message-Id: <20230623082642.0811A1331F@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769481289267596369?= X-GMAIL-MSGID: =?utf-8?q?1769481289267596369?= When we disallow TYPE_PRECISION on VECTOR_TYPEs it shows that shorten_binary_op performs some checks on that that are likely harmless in the end. The following bails out early for VECTOR_TYPE operations to avoid those questionable checks. Bootstrap and regtest ongoing on x86_64-unknown-linux-gnu. OK? gcc/c-family/ * c-common.cc (shorten_binary_op): Exit early for VECTOR_TYPE operations. --- gcc/c-family/c-common.cc | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gcc/c-family/c-common.cc b/gcc/c-family/c-common.cc index 9c8eed5442a..34566a342bd 100644 --- a/gcc/c-family/c-common.cc +++ b/gcc/c-family/c-common.cc @@ -1338,6 +1338,10 @@ shorten_binary_op (tree result_type, tree op0, tree op1, bool bitwise) int uns; tree type; + /* Do not shorten vector operations. */ + if (VECTOR_TYPE_P (result_type)) + return result_type; + /* Cast OP0 and OP1 to RESULT_TYPE. Doing so prevents excessive narrowing when we call get_narrower below. For example, suppose that OP0 is of unsigned int extended From patchwork Fri Jun 23 08:27:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 111978 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp5617100vqr; Fri, 23 Jun 2023 01:28:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7P3cduqagxz8vEgVMKGgHP0EYIEPc0VmG3CVxaw7ywFk5JxHJQMLXv3XrIhHI/+diPx/ok X-Received: by 2002:aa7:db47:0:b0:51a:512b:1b2 with SMTP id n7-20020aa7db47000000b0051a512b01b2mr10799290edt.5.1687508888284; Fri, 23 Jun 2023 01:28:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687508888; cv=none; d=google.com; s=arc-20160816; b=cAgBOQ9/htLZqBbSiOA6hQNrn3x11WqK7kWQIkx1C4d1IGcG/Oz8lQ3Wq/22UV1lKj AQKSC0i8U7gNXfCrjOt7yDtFAAXWWL0Z58cKe05HYuTj13QB+fFHxGEkJBR8DbBLoMiN 5Hr622FPdeHsGMaHqDTT2oLpkBh0ehM52gf8UGSr21RcWZfWOZOKUqhjqZrVwMpobK2J cCp6mZYo74/Qgi/m/OwwMK3wyrN+9PQF12QMg0xon2paHvA1mhivQSLssx6p9fn1WmQY 0hlDSAqyHjNg1omHM7CAcHQzB6jhR12XDhxviqV/I4TqowQxN7Plz37eFGmFNvsZxzjH jSJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:message-id :mime-version:subject:to:date:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=3wbHXJ4umxP50X8N4l6uxwnI3l0bXV8RpGPuHmCelQ8=; b=AD43rOBPu0MBd4nOfHrQXdncwtty+KDgx0yBHGySbD8hDiCDFAx0RTsyS8YP7NMNeG PcmXxyFVlOvbKDLhS0ab07r93WzAKK0u2j0IN2FbZvYF58hvC/w27+pqSzCmmXIfZ/3c cceeBQkf4/ZWwfIG/bCurEFPtSpDkhL9hGtye08zcEUiGh2Ci6LoNQtw64xPNILuVfFZ +ZcKr4ZQNjMTZ0Jz42GpeGEyx8k09et6/WcyMoLgczmrw1izLUKLxqMNBlMqlZt7eHqq p0wPsgfcgI54IcE2WxRm+Gm/u3Ac70UeIT1Wd2Asyjtb7EpTWBJ+iXi7b5HvJq3ozfN+ 2eRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=eCfuNNwE; 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=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id d9-20020aa7ce09000000b0051827a10497si4378076edv.212.2023.06.23.01.28.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Jun 2023 01:28:08 -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=@gcc.gnu.org header.s=default header.b=eCfuNNwE; 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=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id C22A63857025 for ; Fri, 23 Jun 2023 08:27:52 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org C22A63857025 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687508872; bh=3wbHXJ4umxP50X8N4l6uxwnI3l0bXV8RpGPuHmCelQ8=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=eCfuNNwEQ1VUHryxG7ZWTWUDaMUqkXxUaTqhk6Nu6rNdX4aMn4sN9hQ+Qxy4NN/ef z24kZykfZGwyKt1S4x+SXlW9n+OTkt9089Z/efdsAjXiPctOyTPgWb+jhIz/Ug+USr DdIJteM6Zt5/SLjmPh/828AL1iIDVXC42VhAISD8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 35C433858C2F for ; Fri, 23 Jun 2023 08:27:05 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 35C433858C2F Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 7037D21B9D for ; Fri, 23 Jun 2023 08:27:04 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 5D4AB1331F for ; Fri, 23 Jun 2023 08:27:04 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id XIScFVhXlWQRTQAAMHmgww (envelope-from ) for ; Fri, 23 Jun 2023 08:27:04 +0000 Date: Fri, 23 Jun 2023 10:27:04 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH 2/6] Fix TYPE_PRECISION use in hashable_expr_equal_p MIME-Version: 1.0 Message-Id: <20230623082704.5D4AB1331F@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769481320068363823?= X-GMAIL-MSGID: =?utf-8?q?1769481320068363823?= While the checks look unnecessary they probably are quick and thus done early. The following avoids using TYPE_PRECISION on VECTOR_TYPEs by making the code match the comment which talks about precision and signedness. An alternative would be to only retain the ERROR_MARK and TYPE_MODE checks or use TYPE_PRECISION_RAW (but I like that least). Bootstrap and regtest ongoing on x86_64-unknown-linux-gnu, OK? * tree-ssa-scopedtables.cc (hashable_expr_equal_p): Use element_precision. --- gcc/tree-ssa-scopedtables.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gcc/tree-ssa-scopedtables.cc b/gcc/tree-ssa-scopedtables.cc index 528ddf2a2ab..e698ef97343 100644 --- a/gcc/tree-ssa-scopedtables.cc +++ b/gcc/tree-ssa-scopedtables.cc @@ -574,7 +574,7 @@ hashable_expr_equal_p (const struct hashable_expr *expr0, && (TREE_CODE (type0) == ERROR_MARK || TREE_CODE (type1) == ERROR_MARK || TYPE_UNSIGNED (type0) != TYPE_UNSIGNED (type1) - || TYPE_PRECISION (type0) != TYPE_PRECISION (type1) + || element_precision (type0) != element_precision (type1) || TYPE_MODE (type0) != TYPE_MODE (type1))) return false; From patchwork Fri Jun 23 08:27:21 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 111980 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp5617572vqr; Fri, 23 Jun 2023 01:29:28 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ42Y+SicWZF6VJJwTy8iwfwaO7AXCBjn5A/62bEaFViqaUMlXp899vdkk8aA50960DpM8/b X-Received: by 2002:a05:6402:1d49:b0:51b:d59f:8518 with SMTP id dz9-20020a0564021d4900b0051bd59f8518mr9411110edb.16.1687508968593; Fri, 23 Jun 2023 01:29:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687508968; cv=none; d=google.com; s=arc-20160816; b=yAeZNexqs8U67vKCT0cZvP3y2XOW/dMSg/ujGgB19Zx9nDcYwMm/TOF+z4/IbtwuDn dDsUGW1HhqRaB467kGQQD2h9R6D4dPWxaQFXC7TgZREj5ymFszy5BZDOLfxkywfzHgwp 60rEyppErxJaJZ0xxNbtenWwOH+m9XoqJ/wA2hmoD3i0qyk4UDElUaBjzGlg8HawCb+d zruwNCLZHWJJjSW/lORob3toF+gNV1rgYBnXdfZpYWMJ1YyQorFuzYC2G9YCWuDURbLr 7nerrqJuFiEs/0FcmLJwGVW92gWlmwmvKXbwg1GGBgtmtQDUiYHjwn21PI4jNbe8NKn0 B1aA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:message-id :mime-version:subject:to:date:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=l+5wqZDic5y4gDZ+4mliu2qQjhMWi/E616BYO6Uswb8=; b=vc8tnfuh5RDQkMp3WJdm3JWFhsESRwwummZBMwgGgB79lPACtmJIabalQdsrFhbdJY x8Zc8pOK63O4P5W8XRSea42yFYj1AlRcNWHIcWuPZh5Hw3dOsVClNs0IyskQihoEz2nk ZHRmso9QdEvlcmZ8IHLuMzpv4bR2Pc1/gxNOxhjtXXKywOlIGnVO6l0n9jGTLLs/nRYG MIi7zjwUR+qOnrnaALDGrFpgceShoGrrVaUanuz/HRsx20ukDNGwB1gy+vj9YLIWpRIs qrdP+wAxrCSzM8GPTw3zQvx7oWVZIceWa+0jvpw5UF4E0CT5g0Wf5J7ETT6+nNe/CBNs 19Zg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=HDbUVZa7; 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=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id u21-20020a056402065500b005162dcfac46si4115406edx.300.2023.06.23.01.29.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Jun 2023 01:29:28 -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=@gcc.gnu.org header.s=default header.b=HDbUVZa7; 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=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E707B385662E for ; Fri, 23 Jun 2023 08:28:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org E707B385662E DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687508915; bh=l+5wqZDic5y4gDZ+4mliu2qQjhMWi/E616BYO6Uswb8=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=HDbUVZa7MKjoFlhmg3ThlvPCttD18kHN/bcNYB2jeED6n+wt7U1TdfLo3jtmipgpN sRYgdipK3tplsGK1uUDO3HfV29eMoxm8wUNfgNS92uT2/l4xxIxi/5rOa1aQPTnCZK oARu6UQ62NUBlKrTjrWNxbLgcf74on5pYJHeFtH8= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [IPv6:2001:67c:2178:6::1d]) by sourceware.org (Postfix) with ESMTPS id A894E3857711 for ; Fri, 23 Jun 2023 08:27:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A894E3857711 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id E1F761F45F for ; Fri, 23 Jun 2023 08:27:21 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id CF9571331F for ; Fri, 23 Jun 2023 08:27:21 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id W7VgMWlXlWQqTQAAMHmgww (envelope-from ) for ; Fri, 23 Jun 2023 08:27:21 +0000 Date: Fri, 23 Jun 2023 10:27:21 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH 3/6] Properly guard vect_look_through_possible_promotion MIME-Version: 1.0 Message-Id: <20230623082721.CF9571331F@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769481404103806570?= X-GMAIL-MSGID: =?utf-8?q?1769481404103806570?= The function ends up getting called on VECTOR_TYPEs which it really isn't prepared for and with the TYPE_PRECISION checking changes will ICE. The following exits early when the type to work on isn't scalar integral. Bootstrap and regtest ongoing on x86_64-unknown-linux-gnu, will push after that finished. * tree-vect-patterns.cc (vect_look_through_possible_promotion): Exit early when the type isn't scalar integral. --- gcc/tree-vect-patterns.cc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/gcc/tree-vect-patterns.cc b/gcc/tree-vect-patterns.cc index 60bc9be6819..a04accf3b03 100644 --- a/gcc/tree-vect-patterns.cc +++ b/gcc/tree-vect-patterns.cc @@ -398,8 +398,11 @@ vect_look_through_possible_promotion (vec_info *vinfo, tree op, vect_unpromoted_value *unprom, bool *single_use_p = NULL) { - tree res = NULL_TREE; tree op_type = TREE_TYPE (op); + if (!INTEGRAL_TYPE_P (op_type)) + return NULL_TREE; + + tree res = NULL_TREE; unsigned int orig_precision = TYPE_PRECISION (op_type); unsigned int min_precision = orig_precision; stmt_vec_info caster = NULL; @@ -3881,6 +3884,7 @@ vect_recog_vector_vector_shift_pattern (vec_info *vinfo, if (TREE_CODE (oprnd0) != SSA_NAME || TREE_CODE (oprnd1) != SSA_NAME || TYPE_MODE (TREE_TYPE (oprnd0)) == TYPE_MODE (TREE_TYPE (oprnd1)) + || !INTEGRAL_TYPE_P (TREE_TYPE (oprnd0)) || !type_has_mode_precision_p (TREE_TYPE (oprnd1)) || TYPE_PRECISION (TREE_TYPE (lhs)) != TYPE_PRECISION (TREE_TYPE (oprnd0))) From patchwork Fri Jun 23 08:27:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 111979 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp5617491vqr; Fri, 23 Jun 2023 01:29:14 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ4ftSqaWC8Iq2HO8J4rLuma1ucpNWC2bIZi0HoXpKUfuD7o2U/ztOGkan8JqnWRFH6JZphl X-Received: by 2002:a05:6402:45a:b0:51a:2013:583 with SMTP id p26-20020a056402045a00b0051a20130583mr13621144edw.13.1687508953843; Fri, 23 Jun 2023 01:29:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687508953; cv=none; d=google.com; s=arc-20160816; b=q2uIqB3Hk7eodPxZKHmm0z1offol7Tfg1U6PzaeN3lhFmpsZdRq0CBrWlZfGpJWAB6 PrqE3fHfwTybts+I0xkl9PuzfvZ9enfKZPkh4VJN/LgHWVQfrl8/pTqdoTBGWUGreO7w Mfg8qlQ3rCZ1hQtJ2idriAeRRf39JKckzfcNzrb2RLhnSZRzQO8Ml3mBisc6IYHFDyUh cOE104N8yp7WFNUFjzVhIuiEBd+AfjksUWNIgmQpNZ32ULf80RfqluVGSQhWwUe/UVlE fk+sVoeSG8PdJs6aBOd5s8KfVJ+h1534SrHtxgwCqDsDMRw/QxFKM/aE5AXKaEq5T62j CKHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:message-id :mime-version:subject:to:date:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=NdALLXJ6mPwu6z7NYwMIFA9jQt2KsIItE2hR5iMnhdY=; b=XPOh0WM2rGn2WX5cinZ+NP7v8VfKlC2DIWHID9eHhPLcmAIYTwVjpf4SQwNaPkTkTt Ocki2rvuKsZCY3EsWm3ENPUMZ8AdfNV7Q8TLNaAU4cs5thVECKSWB9i1sleIRiPfc01I YY8/zE/V6Zw3Lxi+55SJSmCZ6viUZgwFA7T+j1zZcuS1blt7+9XNKB5IiX0842JeNZlB QBTn0UXXTI35m6VZaUEvjdIBhRcLyzcHd6qnXeM0WJjnPS9k5larBL2i2f/Bu40386GN PWuEi31DCP+xudmrmPI/g9UT4eLW5SX81n6tv6s0ZnuTjeJVOxnlKRv2fzZ3jNAUp+Ix AX8A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="FBBB/Fcg"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id w17-20020a50fa91000000b00518a604e243si2157934edr.20.2023.06.23.01.29.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Jun 2023 01:29:13 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b="FBBB/Fcg"; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 5FBE8385842C for ; Fri, 23 Jun 2023 08:28:27 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 5FBE8385842C DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687508907; bh=NdALLXJ6mPwu6z7NYwMIFA9jQt2KsIItE2hR5iMnhdY=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=FBBB/Fcg0eNFV7ofUT06qjARDoDAAPT/NsmphUvrjCaIU2j8AYFYoZ9xpu4IGVRXN gtZiX+CjPeDT8K49AhkuQgLZh4O5IQpyv2nFc/4oJMzhKBHvUHn0yTolRCYk74rJDO L8ALptX1RNiphX6n/sR3muXPfq8tC3VFGYd78g+w= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [195.135.220.28]) by sourceware.org (Postfix) with ESMTPS id 681A73857C43 for ; Fri, 23 Jun 2023 08:27:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 681A73857C43 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 9F66921B9B for ; Fri, 23 Jun 2023 08:27:35 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 8C7AF1331F for ; Fri, 23 Jun 2023 08:27:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id qgQGIXdXlWRATQAAMHmgww (envelope-from ) for ; Fri, 23 Jun 2023 08:27:35 +0000 Date: Fri, 23 Jun 2023 10:27:35 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH 4/6] Fix tree_simple_nonnegative_warnv_p for VECTOR_TYPEs MIME-Version: 1.0 Message-Id: <20230623082735.8C7AF1331F@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769481388813964081?= X-GMAIL-MSGID: =?utf-8?q?1769481388813964081?= tree_simple_nonnegative_warnv_p ends up being called on VECTOR_TYPEs which I think even gets the wrong answer here for tcc_comparison since vector bools are signed. The following properly guards that with !VECTOR_TYPE_P. Bootstrap and regtest ongoing on x86_64-unknown-linux-gnu, will push after that finished. * fold-const.cc (tree_simple_nonnegative_warnv_p): Guard the truth_value_p case with !VECTOR_TYPE_P. --- gcc/fold-const.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc index 3aa6851acd5..7e35eda7140 100644 --- a/gcc/fold-const.cc +++ b/gcc/fold-const.cc @@ -14530,7 +14530,8 @@ tree_expr_maybe_real_minus_zero_p (const_tree x) static bool tree_simple_nonnegative_warnv_p (enum tree_code code, tree type) { - if ((TYPE_PRECISION (type) != 1 || TYPE_UNSIGNED (type)) + if (!VECTOR_TYPE_P (type) + && (TYPE_PRECISION (type) != 1 || TYPE_UNSIGNED (type)) && truth_value_p (code)) /* Truth values evaluate to 0 or 1, which is nonnegative unless we have a signed:1 type (where the value is -1 and 0). */ From patchwork Fri Jun 23 08:27:47 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 111982 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp5617824vqr; Fri, 23 Jun 2023 01:30:08 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7CLuRYi89Uj/NfnsFdYmyB9rv29/LC7ou9YOQigxW6/RnWMMENCzgtfrEN38BQC2c6+0gn X-Received: by 2002:a17:907:7d8a:b0:989:444b:725 with SMTP id oz10-20020a1709077d8a00b00989444b0725mr8344695ejc.26.1687509007920; Fri, 23 Jun 2023 01:30:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687509007; cv=none; d=google.com; s=arc-20160816; b=pueefGdFHC7AzIfD2UxgMFloxXDL5s8YwGJcBqhu9zmjarHktT9gUQsJcaqY5qVF/H C2ghheTkham08HsXtypuZdhhvAIE7/4WpniqoIcSCW7SCh+M4KL6hYQ4zSSUeSn0R+Qr QiQvrp5AmXi7uifYbi//aPxZYicGbIjI9QWa1Ccr/XxBmU0F9pQoS9QpMLqwJTkC537z w/gMDRh6nvbwatUinL9XzCwOho7zWkty/X/6Y46+MyFlSIx+1C5iTxVPwsgeOiPQvMg0 /BEKZQIaxWQJ3B/snNy/xdjLi21FM0CAvthQzXiMpsW3XxhX3iLSVOTXG0VAop22JZB6 D1Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:message-id :mime-version:subject:to:date:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=CpRboDesyFC9/qwIRLtK1jhj0KoygAV6G5KrAV7yXGg=; b=FWHDgkTRVUBbtANycCiR+n3WYgJxfwnizSiBJw0tusH3ARBBl7gIGn6ati+AWBoIst Sv7ckKGmyUO6qVrlnsq0YseV4oYV9CbchyZOLJu+VR1hfWcmJLcF4+6mf/7fJXUGKutL G7t+QNGmawIuYZz7lhVSQYTlOuuIjKV9hxqtVxFaiYiHvfjhTo3f14uwvQV6WLT/iuG1 JE0mn7e65Vtq7sjFDl6Fd/jHwQf8NvWtqJYQ7jGgVVAVaOnsTlyoLENub9W2R8nP211p YmP72Hk+ZBc/t9+gRuCkODjOt3g2WW3G4ji7vBP0waR6/+JABXPCWZDAA8YONkl++zXd O1SA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=fp5JmXum; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from sourceware.org (ip-8-43-85-97.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id ha12-20020a170906a88c00b0098932a90cdasi3864459ejb.255.2023.06.23.01.30.07 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Jun 2023 01:30:07 -0700 (PDT) Received-SPF: pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) client-ip=8.43.85.97; Authentication-Results: mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=fp5JmXum; spf=pass (google.com: domain of gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org designates 8.43.85.97 as permitted sender) smtp.mailfrom="gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 61A03385700F for ; Fri, 23 Jun 2023 08:29:13 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 61A03385700F DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687508953; bh=CpRboDesyFC9/qwIRLtK1jhj0KoygAV6G5KrAV7yXGg=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=fp5JmXumRiqemdeabHg5vWGiJtlt3dfyX7VPBB3AitAuwXVnOSybiqwc3JkBVJrwG 3dMN6voR7+L3BCkJRx9hehTQcaxohU4ZF9qPuReGWqn3SCukdgSnbtUkNgi+s2gjXI NiTY/fTevgIkWUPLo/NDqUKtbt4+MBWkrqffnQqo= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out1.suse.de (smtp-out1.suse.de [IPv6:2001:67c:2178:6::1c]) by sourceware.org (Postfix) with ESMTPS id DFA923858401 for ; Fri, 23 Jun 2023 08:27:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DFA923858401 Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out1.suse.de (Postfix) with ESMTPS id 2304821B9B for ; Fri, 23 Jun 2023 08:27:48 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 10FA71331F for ; Fri, 23 Jun 2023 08:27:48 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id jegNA4RXlWRWTQAAMHmgww (envelope-from ) for ; Fri, 23 Jun 2023 08:27:48 +0000 Date: Fri, 23 Jun 2023 10:27:47 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH 5/6] Bogus and missed folding on vector compares MIME-Version: 1.0 Message-Id: <20230623082748.10FA71331F@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769481445858864349?= X-GMAIL-MSGID: =?utf-8?q?1769481445858864349?= fold_binary tries to transform (double)float1 CMP (double)float2 into float1 CMP float2 but ends up using TYPE_PRECISION on the argument types. For vector types that compares the number of lanes which should be always equal (so it's harmless as to not generating wrong code). The following instead properly uses element_precision. The same happens in the corresponding match.pd pattern. Bootstrap and regtest ongoing on x86_64-unknown-linux-gnu, will push after that finished. * fold-const.cc (fold_binary_loc): Use element_precision when trying (double)float1 CMP (double)float2 to float1 CMP float2 simplification. * match.pd: Likewise. --- gcc/fold-const.cc | 4 ++-- gcc/match.pd | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gcc/fold-const.cc b/gcc/fold-const.cc index 7e35eda7140..ac90a594fcc 100644 --- a/gcc/fold-const.cc +++ b/gcc/fold-const.cc @@ -12564,10 +12564,10 @@ fold_binary_loc (location_t loc, enum tree_code code, tree type, tree targ1 = strip_float_extensions (arg1); tree newtype = TREE_TYPE (targ0); - if (TYPE_PRECISION (TREE_TYPE (targ1)) > TYPE_PRECISION (newtype)) + if (element_precision (TREE_TYPE (targ1)) > element_precision (newtype)) newtype = TREE_TYPE (targ1); - if (TYPE_PRECISION (newtype) < TYPE_PRECISION (TREE_TYPE (arg0))) + if (element_precision (newtype) < element_precision (TREE_TYPE (arg0))) return fold_build2_loc (loc, code, type, fold_convert_loc (loc, newtype, targ0), fold_convert_loc (loc, newtype, targ1)); diff --git a/gcc/match.pd b/gcc/match.pd index 2dd23826034..85d562a531d 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -6034,10 +6034,10 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) type1 = double_type_node; } tree newtype - = (TYPE_PRECISION (TREE_TYPE (@00)) > TYPE_PRECISION (type1) + = (element_precision (TREE_TYPE (@00)) > element_precision (type1) ? TREE_TYPE (@00) : type1); } - (if (TYPE_PRECISION (TREE_TYPE (@0)) > TYPE_PRECISION (newtype)) + (if (element_precision (TREE_TYPE (@0)) > element_precision (newtype)) (cmp (convert:newtype @00) (convert:newtype @10)))))))) From patchwork Fri Jun 23 08:27:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 111981 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:994d:0:b0:3d9:f83d:47d9 with SMTP id k13csp5617749vqr; Fri, 23 Jun 2023 01:29:59 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7QGERkYKeDjcpcsPlCpYwbbnqiLEi1tdpIZtmgTunkaPN6eOGlMxVI+Z7+PLd9RHsBaPsl X-Received: by 2002:a17:907:8a1f:b0:98d:3116:959c with SMTP id sc31-20020a1709078a1f00b0098d3116959cmr3869119ejc.0.1687508999239; Fri, 23 Jun 2023 01:29:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687508999; cv=none; d=google.com; s=arc-20160816; b=YDiNp1leIO4muFaQ63125ul09147qQMC9kchx+HbO/gR5XQ4Hf22HOqxPrIW751oft A5I/NnPUBKDUX00kIRq2BicKKlJd3HNLsUNYXAmaWdVKm4sF1/5JC82QuOtmNVAS7X17 tLyp48R1zsT7ULF3cK/gZUdJSKE7eNXSZlA2KTxSi+S1s4s2xsjkinTy7+px5xV26xrk SeVe9Ajqs6zbsJnHw5jG5fgT5dE8TS8Zt4rK16tPJ6oKaf3a7GjuR+Pkn35sdS4LOknt jTzSexZeJgz4u/R3xf5K3rp7rhKKwymp4k+BxlPb1VqJaVpxSrcY3D0iacTpVGAS9HgE X8jw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:from:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:message-id :mime-version:subject:to:date:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=R4Xpjp+m7akWZjVVg9tIe3M6OGTeWv4xTrZfKCKqcTw=; b=kDH323hNT1+jka4vy21fZ5qS+GRH7455+A8wLGBeRGtClx13ZToOpt8RQvBDv3UctD M/pcKrqMvz5atQMSt94YNNVmQzNQ3l6qZwR0W9tYDrZM4UzCfx3qbl7uNbJaF2tjqiQY /ju52GwtUkN5g2rMcOmsE+PBGldvyOY55+Q0YBFWA03qDenA6VM5B7O4oR/jL8XyU661 Z8/f+7ybwrag25B1pjnAjxzY54tUpALGHtsioblfoXpwoK2k7umTXpsoEDMy7jKiv+6c 4r8P7KF37zn3Xq2IQNCkeFIfjW+wiX9Rcqyll1v4RnISO8ghVLM9mZAZLTGl5T4XgBC5 jyjg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=OAhSzfWZ; 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=gnu.org Received: from sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id r23-20020a170906c29700b0098889bf7f86si5166854ejz.315.2023.06.23.01.29.58 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 23 Jun 2023 01:29:59 -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=@gcc.gnu.org header.s=default header.b=OAhSzfWZ; 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=gnu.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id F03793858002 for ; Fri, 23 Jun 2023 08:29:00 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org F03793858002 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1687508941; bh=R4Xpjp+m7akWZjVVg9tIe3M6OGTeWv4xTrZfKCKqcTw=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=OAhSzfWZ3xGIJMsPuntSFm9OQ+1O2fHHHKwv/OddKiqSCJK8DzCJMp7GXRy1SU2pj ghFzMfXkomRLMl2AdvdoOF84GH4gZ1CcQ9E1KS0JlulW9oFjB7utoy3KP7Gd08hWhX D2iDr0iJsOkViEr7XgilyB+A3jskTxzmJj+qg9o0= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.220.29]) by sourceware.org (Postfix) with ESMTPS id DFEF9385694E for ; Fri, 23 Jun 2023 08:27:59 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org DFEF9385694E Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 2265C1F45F for ; Fri, 23 Jun 2023 08:27:59 +0000 (UTC) Received: from imap2.suse-dmz.suse.de (imap2.suse-dmz.suse.de [192.168.254.74]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-521) server-digest SHA512) (No client certificate requested) by imap2.suse-dmz.suse.de (Postfix) with ESMTPS id 0DD281331F for ; Fri, 23 Jun 2023 08:27:59 +0000 (UTC) Received: from dovecot-director2.suse.de ([192.168.254.65]) by imap2.suse-dmz.suse.de with ESMTPSA id kuEqAo9XlWRoTQAAMHmgww (envelope-from ) for ; Fri, 23 Jun 2023 08:27:59 +0000 Date: Fri, 23 Jun 2023 10:27:58 +0200 (CEST) To: gcc-patches@gcc.gnu.org Subject: [PATCH 6/6] Use element_precision for match.pd arith conversion optimization MIME-Version: 1.0 Message-Id: <20230623082759.0DD281331F@imap2.suse-dmz.suse.de> X-Spam-Status: No, score=-11.5 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE 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.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-Patchwork-Original-From: Richard Biener via Gcc-patches From: Richard Biener Reply-To: Richard Biener Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Sender: "Gcc-patches" X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1769481436534309010?= X-GMAIL-MSGID: =?utf-8?q?1769481436534309010?= The simplification (outertype)((innertype0)a+(innertype1)b) to ((newtype)a+(newtype)b) ends up using TYPE_PRECISION to check whether it can elide a conversion but in some paths there can be VECTOR_TYPEs where this instead compares the number of lanes. The following fixes the missed optimizations and uses element_precision in those places. Bootstrap and regtest ongoing on x86_64-unknown-linux-gnu, will push after that finished. * match.pd ((outertype)((innertype0)a+(innertype1)b) -> ((newtype)a+(newtype)b)): Use element_precision where appropriate. --- gcc/match.pd | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/gcc/match.pd b/gcc/match.pd index 85d562a531d..48b76e6a051 100644 --- a/gcc/match.pd +++ b/gcc/match.pd @@ -7428,9 +7428,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) && newtype == type && types_match (newtype, type)) (op (convert:newtype @1) (convert:newtype @2)) - (with { if (TYPE_PRECISION (ty1) > TYPE_PRECISION (newtype)) + (with { if (element_precision (ty1) > element_precision (newtype)) newtype = ty1; - if (TYPE_PRECISION (ty2) > TYPE_PRECISION (newtype)) + if (element_precision (ty2) > element_precision (newtype)) newtype = ty2; } /* Sometimes this transformation is safe (cannot change results through affecting double rounding @@ -7453,9 +7453,9 @@ DEFINE_INT_AND_FLOAT_ROUND_FN (RINT) exponent range for the product or ratio of two values representable in the TYPE to be within the range of normal values of ITYPE. */ - (if (TYPE_PRECISION (newtype) < TYPE_PRECISION (itype) + (if (element_precision (newtype) < element_precision (itype) && (flag_unsafe_math_optimizations - || (TYPE_PRECISION (newtype) == TYPE_PRECISION (type) + || (element_precision (newtype) == element_precision (type) && real_can_shorten_arithmetic (TYPE_MODE (itype), TYPE_MODE (type)) && !excess_precision_type (newtype)))