From patchwork Thu Feb 1 14:20:59 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 195350 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2719:b0:106:209c:c626 with SMTP id hl25csp185913dyb; Thu, 1 Feb 2024 06:22:00 -0800 (PST) X-Google-Smtp-Source: AGHT+IFpgXZX/pTVHsZIarnjgWlzter2CZBRrgNSR3x1anyWBYiZDo/9ijTacNrNZwInPExnQvHW X-Received: by 2002:a05:6808:17a5:b0:3be:d299:b1bb with SMTP id bg37-20020a05680817a500b003bed299b1bbmr3937221oib.51.1706797320245; Thu, 01 Feb 2024 06:22:00 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706797320; cv=pass; d=google.com; s=arc-20160816; b=AZmLcizm6fsg5r5O9OtFjSMe4Y6ysZvXltAjJOMHVxSf28nO4cUHzgTR7Hi2YCHk0/ 6hU4Pf7pN1sL++4hgX8KDK+l2B06wcLwxFcsdW1CEUXED4efdSsaENIkEkI3QZP2dx31 b91OYklUWU3tK6JjBPTxbMTX+nZkt2TWlozfrw/mp9jMOM6hMMBo1OJiNp5GSFChg+Gl fywuxR69ucSYD9Rt8ihX2GZCtDfxwk4qj00tYTbAZopJNKt9lxwoYl3bpEarQkKzZuoB XhgP9AnLsNi8U7FA0uNfqh0ZJ63pII2+/qcGhbNPuhSSmlMJ1fCKVEinYxfM8mCqfrZW EwFA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=message-id:errors-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:mime-version :subject:to:from:date:dkim-signature:dkim-signature:dkim-signature :dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=EqqdQ4kZbYbt9CD0EQuxPRQ7O1UwA/NhtJNxPM0YlgQ=; fh=vTxTx/0NolrtFU793WkcxlP8EARBZP4m8ZRYnS1BfcI=; b=JWSml65yfJOfGu2gCm3NBe4nukHHJTS1LC7pUMwU5td8JuyvtepxP5ZuGqjqhXF+fd /xhcabxAmqD2Or3EO+Vc5rLAJqQ0nORIHeKAuhbIea/K89pumwclJ8dbuTS9tzlwWEbW FXfENi3n5r7QrlC7kxrr71H55p11k2ZZkNtgwsM/PYsn47sjQexDqJrfqTap3+Dt/lHW JOfbdmvcdsq5ifcLTAFwC5ofH0MrCb89Y0gqNQK3KB+Lp/WWX4tma37Z2BA4yqF2zgMh d3bM+DyM2mxOY7Qj9pg56g+0v1qS4w/Spu+sKH9q43zTK8XIYfRkrTjF8EhFdzu7F9IV rD9w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=EVp4NFJj; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=EVp4NFJj; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=k4vy7uJe; arc=pass (i=1); 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=suse.de X-Forwarded-Encrypted: i=1; AJvYcCUSfpmi8FCbugKl323lLw7F25i7OcYmQhqI+IJqlnEeB0p6vXq9ysvNPgWZJHV07B2WynTRKCbeq3Lq3O/nTs4nzKoRkA== Received: from server2.sourceware.org (server2.sourceware.org. [8.43.85.97]) by mx.google.com with ESMTPS id d18-20020a05622a05d200b0042bf84ef839si712660qtb.267.2024.02.01.06.22.00 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 01 Feb 2024 06:22:00 -0800 (PST) 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=@suse.de header.s=susede2_rsa header.b=EVp4NFJj; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=EVp4NFJj; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=k4vy7uJe; arc=pass (i=1); 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=suse.de Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id E219D3858036 for ; Thu, 1 Feb 2024 14:21:59 +0000 (GMT) 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.223.131]) by sourceware.org (Postfix) with ESMTPS id 2658F3858C2C for ; Thu, 1 Feb 2024 14:21:01 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 2658F3858C2C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=suse.de ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 2658F3858C2C Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=195.135.223.131 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706797263; cv=none; b=q4W052M/ZbZ9Udj50rlu80t1+XUcYjwPzNH0O7TdPtsRrEmdWwqZej5N9dCGTIcHgxnTmCImMaqGTz/Gh1UyF3Pv1xkeXr1F4niZ7HnSrGW/Qgw5e2bzJp6xkLS5P1fPoxAQJN+cCJqXStCjZHZB8Dp6Xm2m6wZFXuu/wjtg7/A= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1706797263; c=relaxed/simple; bh=5buFVQzfpvUlvUf/EbUyAXOk7LLKMMGPOGO8QTSzuo4=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version; b=NT0h+Vw6F7mSjOxth2ZUcKeSXy3sARg3UXGUZRrFOxn7tdgdJAmEzYsyLlcxklA6lTfGRVTDneRnwciYRLonX3iYdAKZX3eOagxPQguvO90THKdbWDPPo/zNwzL7AYwjXR4O2cNvdo0jjXTtdcQwneEy5CWKtAnEK/veSGte0M0= ARC-Authentication-Results: i=1; server2.sourceware.org Received: from [10.168.4.150] (unknown [10.168.4.150]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 4BFC71FBB3 for ; Thu, 1 Feb 2024 14:20:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706797259; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=EqqdQ4kZbYbt9CD0EQuxPRQ7O1UwA/NhtJNxPM0YlgQ=; b=EVp4NFJj0wQ6YSO+X3S/jpZI0CzMQLJ0RUlGGDT5Z6JGfwICky7X3YGBSdrT5SFXKyuGMe XTyfljKZdG5fCZz37HAqRPLVN3MhfNjHKSh7nbKo/tJYPB02pVwDvwNc7P8CaXtgQlVCq+ ybvZ4t2TIaK9/eUmFAdIcQ1A1eBqSVI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706797259; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=EqqdQ4kZbYbt9CD0EQuxPRQ7O1UwA/NhtJNxPM0YlgQ=; b=k4vy7uJeDg8afmC2haLdLMgnB/DUDnvuz2thZcFXMR47sgPO6gqRm8DiWLxbPwb23W52zd qKmsxdVIc8NV3EBQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1706797259; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=EqqdQ4kZbYbt9CD0EQuxPRQ7O1UwA/NhtJNxPM0YlgQ=; b=EVp4NFJj0wQ6YSO+X3S/jpZI0CzMQLJ0RUlGGDT5Z6JGfwICky7X3YGBSdrT5SFXKyuGMe XTyfljKZdG5fCZz37HAqRPLVN3MhfNjHKSh7nbKo/tJYPB02pVwDvwNc7P8CaXtgQlVCq+ ybvZ4t2TIaK9/eUmFAdIcQ1A1eBqSVI= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1706797259; h=from:from:reply-to:date:date:to:to:cc:mime-version:mime-version: content-type:content-type; bh=EqqdQ4kZbYbt9CD0EQuxPRQ7O1UwA/NhtJNxPM0YlgQ=; b=k4vy7uJeDg8afmC2haLdLMgnB/DUDnvuz2thZcFXMR47sgPO6gqRm8DiWLxbPwb23W52zd qKmsxdVIc8NV3EBQ== Date: Thu, 1 Feb 2024 15:20:59 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org Subject: [PATCH 2/2] rtl-optimization/113255 - avoid re-associating REG_POINTER MINUS MIME-Version: 1.0 Authentication-Results: smtp-out2.suse.de; none X-Spamd-Result: default: False [2.40 / 50.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; TO_DN_NONE(0.00)[]; RCPT_COUNT_ONE(0.00)[1]; MISSING_MID(2.50)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FUZZY_BLOCKED(0.00)[rspamd.com]; RCVD_COUNT_ZERO(0.00)[0]; FROM_EQ_ENVFROM(0.00)[]; MIME_TRACE(0.00)[0:+]; BAYES_HAM(-0.00)[15.96%] X-Spam-Score: 2.40 X-Spam-Status: No, score=-10.8 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, 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.30 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: gcc-patches-bounces+ouuuleilei=gmail.com@gcc.gnu.org Message-Id: <20240201142159.E219D3858036@sourceware.org> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1789706707258682330 X-GMAIL-MSGID: 1789706707258682330 The following avoids re-associating (minus:DI (reg/f:DI 119) (minus:DI (reg/f:DI 120) (reg/f:DI 114))) into (minus:DI (plus:DI (reg/f:DI 114) (reg/f:DI 119)) (reg/f:DI 120)) as that possibly confuses the REG_POINTER heuristics of RTL alias analysis. This happens to miscompile the PRs testcase during DSE which expands addresses via CSELIB which eventually simplifies what it substituted to. The original code does the innocent ptr - (ptr2 - ptr2'), bias a pointer by the difference of two other pointers. --- This is what I propose for the PR for branches, I have not made much progress with fixing the fallout on the RTL alias analysis change on trunk, so this is the alternative if we decide to revert that. Bootstrapped and tested on x86_64-unknown-linux-gnu on the gcc-13 branch, bootstrapped after reverting of the previous fix on x86_64-unknown-linux-gnu on trunk, testing is still ongoing there. OK? Any preference for trunk? Thanks, Richard. PR rtl-optimization/113255 * simplify-rtx.cc (simplify_context::simplify_binary_operation_1): Do not re-associate a MINUS with a REG_POINTER op0. --- gcc/simplify-rtx.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/gcc/simplify-rtx.cc b/gcc/simplify-rtx.cc index ee75079917f..0108d0aa3bd 100644 --- a/gcc/simplify-rtx.cc +++ b/gcc/simplify-rtx.cc @@ -3195,11 +3195,15 @@ simplify_context::simplify_binary_operation_1 (rtx_code code, canonicalize (minus A (plus B C)) to (minus (minus A B) C). Don't use the associative law for floating point. The inaccuracy makes it nonassociative, - and subtle programs can break if operations are associated. */ + and subtle programs can break if operations are associated. + Don't use the associative law when subtracting a MINUS from + a REG_POINTER as that can trick find_base_term into discovering + the wrong base. */ if (INTEGRAL_MODE_P (mode) && (plus_minus_operand_p (op0) - || plus_minus_operand_p (op1)) + || ((!REG_P (op0) || !REG_POINTER (op0)) + && plus_minus_operand_p (op1))) && (tem = simplify_plus_minus (code, mode, op0, op1)) != 0) return tem;