From patchwork Thu Apr 13 13:00:20 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 82950 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1013708vqo; Thu, 13 Apr 2023 06:01:26 -0700 (PDT) X-Google-Smtp-Source: AKy350Y7OORaxk5dovuQLbkvo5dpvgfcCPumOgbkA1CSK3r/a0ofFQ6uZFRNImjGBk4kAr2smgIP X-Received: by 2002:a17:906:3143:b0:94a:5819:5a2b with SMTP id e3-20020a170906314300b0094a58195a2bmr2708418eje.33.1681390886251; Thu, 13 Apr 2023 06:01:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681390886; cv=none; d=google.com; s=arc-20160816; b=LEf6uHOptR2GgOcqeGmAchTnpmR/Ur+BYOJ0VkZ2MnBvt4OO3tcNPhWPxzFY+mAMlv DVNhiu69Dck9dCzrZs2d+p2RcLzcP1bmLQhvuspXh7dVqjUdBj951QhUGA2MJ72tbbeq gF3GqIDvVnuVigvHFrt6TxGZf3iLKQfSoD4ZI9SujjfEcrjqwbDU/6FtG3SL6Bxoj/UQ S/KDpmVhXH/0ph8I9AmPN49J/ooUHYLtHtJX27Pboocwe3PIwKYSTs+JjDsffLpnzQ79 tblzk0XaL94OtrtzCPZx+ef9aNwnIYst9rTum9NCOkLvMtm0l7DV0mv+WxcCmsM++9lU ro4g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:sender:errors-to:reply-to:from:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:user-agent:subject:to:date:dmarc-filter:delivered-to :dkim-signature:dkim-filter; bh=FG0NoMTGwApsoNpSc3AjA1i3cl6+VxfPi54yBeGtn+Y=; b=WCuaFstrwfbLDqrW0apvgM44LWnJ/vSkuXvX/+0R63pmAMPOiue/tw6kLlHj/E04KN +dgWCeBfgFXyLbbSChF9MTm5UZG36sOc7O66zd6jKf1P+tHSCb9W9BYCbAK3pDrJ7Xd4 bPEjkUQJhitKXbAAGopwUG2TIizos22FUQtbwx5pvrLRmeIzA4hO+K8sv2rQ2agm0J4U 0NuotnDayccWgchQXz0dDBrXFlgdazYdLJnIy018UQg3PGgGHKQj23AGSNXTS3AK2Tcd 79kT1oJIdSmhSNVNYIH+T6cX6EiXWtqueACgQhJTX96WzfaKLkMfTgHL8buqgU8XWtCp c/Fw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gcc.gnu.org header.s=default header.b=GuoBCbvV; 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 bp7-20020a170907918700b0094ec925c92csi94207ejb.312.2023.04.13.06.01.25 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Apr 2023 06:01:26 -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=GuoBCbvV; 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 2925A3856DD2 for ; Thu, 13 Apr 2023 13:01:05 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 2925A3856DD2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1681390865; bh=FG0NoMTGwApsoNpSc3AjA1i3cl6+VxfPi54yBeGtn+Y=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=GuoBCbvViSmCv5TxDkN0GfwjMTJ/l5jKilOuxsvGf5PtkwkBOvEMVVMyng81I+WC3 x/fHffCDo0Ebndp5iCyRVkaH7UORPD9qUHrf8lXmU0uR5/vsn4NbzyRX0vdfjO1yl+ XCaYxIu7ptFCRbW7b+mRN7r/K8ruCAyjjZMt4Nmg= 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 A38A23858422 for ; Thu, 13 Apr 2023 13:00:21 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org A38A23858422 Received: from relay2.suse.de (relay2.suse.de [149.44.160.134]) by smtp-out2.suse.de (Postfix) with ESMTP id CCED41FD63 for ; Thu, 13 Apr 2023 13:00:20 +0000 (UTC) Received: from wotan.suse.de (wotan.suse.de [10.160.0.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by relay2.suse.de (Postfix) with ESMTPS id C25F52C143 for ; Thu, 13 Apr 2023 13:00:20 +0000 (UTC) Date: Thu, 13 Apr 2023 13:00:20 +0000 (UTC) To: gcc-patches@gcc.gnu.org Subject: [PATCH] tree-optimization/109491 - ICE in expressions_equal_p User-Agent: Alpine 2.22 (LSU 394 2020-01-19) MIME-Version: 1.0 X-Spam-Status: No, score=-10.6 required=5.0 tests=BAYES_00, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, MISSING_MID, SPF_HELO_NONE, SPF_PASS, 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.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" Message-Id: <20230413130105.2925A3856DD2@sourceware.org> X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1763066129777429910?= X-GMAIL-MSGID: =?utf-8?q?1763066129777429910?= At some point I elided the NULL pointer check in expressions_equal_p because it shouldn't be necessary not realizing that for example TARGET_MEM_REF has optional operands we cannot substitute with something non-NULL with the same semantics. The following does the simple thing and restore the check removed in r11-4982. Bootstrapped and tested on x86_64-unknown-linux-gnu, pushed. PR tree-optimization/109491 * tree-ssa-sccvn.cc (expressions_equal_p): Restore the NULL operands test. --- gcc/tree-ssa-sccvn.cc | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/gcc/tree-ssa-sccvn.cc b/gcc/tree-ssa-sccvn.cc index 99609538f54..9692911e31b 100644 --- a/gcc/tree-ssa-sccvn.cc +++ b/gcc/tree-ssa-sccvn.cc @@ -6407,6 +6407,13 @@ expressions_equal_p (tree e1, tree e2, bool match_vn_top_optimistically) && (e1 == VN_TOP || e2 == VN_TOP)) return true; + /* If only one of them is null, they cannot be equal. While in general + this should not happen for operations like TARGET_MEM_REF some + operands are optional and an identity value we could substitute + has differing semantics. */ + if (!e1 || !e2) + return false; + /* SSA_NAME compare pointer equal. */ if (TREE_CODE (e1) == SSA_NAME || TREE_CODE (e2) == SSA_NAME) return false;