From patchwork Mon Jan 15 13:34:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Richard Biener X-Patchwork-Id: 188164 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2614:b0:101:6a76:bbe3 with SMTP id mm20csp1707384dyc; Mon, 15 Jan 2024 05:40:14 -0800 (PST) X-Google-Smtp-Source: AGHT+IH4fBJDyjLGeUGhfgB+cTLGUcf45UAHNWe+rq9sVqRfizRYSd6FNzqUU6EVMHm2Qi4a6Xyu X-Received: by 2002:a05:620a:55b6:b0:781:428b:78be with SMTP id vr22-20020a05620a55b600b00781428b78bemr6211195qkn.134.1705326013785; Mon, 15 Jan 2024 05:40:13 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705326013; cv=pass; d=google.com; s=arc-20160816; b=Q9iwCuM16QUgeuMzFB8QOAJl/w/MY2TklW3JT2l//vlWgw7VsT/J8dM1N9qq1tXaEW ds13viF2Yv3uqKlqf8Mkzgv/UkuzX0RHOdi5CVK8C/OKJosyZ/oFon7BudUEukPq9yAm /ONr200uR0T4P2u/CtXVLJkkNzYlLtvNQRqDmRVPD+hZZv+mZ2IGcbQtAVY+mtwB7Cqu daLfKsq9J1pS92x8FtZhkXfMS+AUGbl8Hca4WYsbL8nwmtAL4fHlnS540T75tP20byWm K4DoxzxOeMQk9Erub5RxZs76sORitwPEdEJUYx5RucYwFl99C1m04BOzo2x8BQaQK8z/ 8DdQ== 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:cc:to:from:date:dkim-signature:dkim-signature :dkim-signature:dkim-signature:arc-filter:dmarc-filter:delivered-to; bh=2M7U7TCMtOL+qn2haQDHrHyrktpb/DMFcGk6937LPZ4=; fh=4icfLXwwrMRy3raFm7E1ipqC3Cpq+fl6ViI9AtytY8I=; b=pPODli/KEMV2fvbLxiKKmvwusE+J4LsKCJ0ove2LWTWhCODLNnewzqYjfXYdArQIjP VflXuiGxp5EkjzgEwCZYzViC2HpEQfdfWAxBiR2e00yXB8RWiMZxbFNRWglYBJBqRFRe 0vNINA099Wq5gwJN4VHzTehs7fLkf44MUxW2amwBFtgwpSsQkzeZ95rhmWNt8G5gqLeB saoTXJulKH5VCmQYLX9SqenOy46i+ybqpVH9KCSfSIaeHO42VFte+Mz5D1Na8dddwojk hTVxTHQKrvhfyQvukUV8aPlK1BMCyvlc8Py1ixH4K+hLzOsr9o82UqIsTffymh1UlgXY cYsw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=MP6ym8Dp; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=I4VzoCLS; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=MP6ym8Dp; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1); 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=suse.de Received: from server2.sourceware.org (server2.sourceware.org. [2620:52:3:1:0:246e:9693:128c]) by mx.google.com with ESMTPS id j24-20020a05620a0a5800b0078366fee510si1134qka.166.2024.01.15.05.40.13 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 15 Jan 2024 05:40:13 -0800 (PST) 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=@suse.de header.s=susede2_rsa header.b=MP6ym8Dp; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519 header.b=I4VzoCLS; dkim=pass header.i=@suse.de header.s=susede2_rsa header.b=MP6ym8Dp; dkim=neutral (no key) header.i=@suse.de header.s=susede2_ed25519; arc=pass (i=1); 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=suse.de Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 752A73858C54 for ; Mon, 15 Jan 2024 13:40:13 +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 [IPv6:2a07:de40:b251:101:10:150:64:2]) by sourceware.org (Postfix) with ESMTPS id 8B15B3858D1E for ; Mon, 15 Jan 2024 13:39:29 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 8B15B3858D1E 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 8B15B3858D1E Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=2a07:de40:b251:101:10:150:64:2 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705325971; cv=none; b=fUhWF5DunKUludmfxalDGXT1t33EPrQ2qX6DLYtADp8HQxvtvZGiL2tplJ9e4lIGvpSIBAtTRML9vJvERsdsm1ZUIhZBVjDefAa1ycaHEcErGlf2kSj6Hf8p7eGYQ7fz40YUDVUmoLwtICT3YyWK2Ue1QKsEf7g2p4wzTq/ls6s= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1705325971; c=relaxed/simple; bh=3UmL34aT8OIiNJteW/LRIVCBRpArj6CIkiYl8EL1cbM=; h=DKIM-Signature:DKIM-Signature:DKIM-Signature:DKIM-Signature:Date: From:To:Subject:MIME-Version; b=Sb8WuTcFplmWw7J6Hh/Tgj8/Bk8GukT07ymEA+G1+p1DzXyczozUkqtR5RGyi7VXC2TmZMRezhXQrixekR6Ph7fdGqj8JKNBDUViwJXweC89IVEceUTlpPe4DGC6GkOyaDI/aL8ZW3wOJK+reg1eTegLBjtKHm2kUxY3Xpkt0qk= 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 79A301F88D; Mon, 15 Jan 2024 13:39:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1705325968; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=2M7U7TCMtOL+qn2haQDHrHyrktpb/DMFcGk6937LPZ4=; b=MP6ym8DpdZBD5gEwHmek+YKRaujGyNrZO0LgQNSlBos2+Lb0HWY5IEtxo332fnCNXG9WTY mUXno4Xae9ZsirBiZ7GbdViNTjUQXy9jqDrp/G/GN9dtF38+myUgBpnJ07W8LZMLcIlSCO wOchy9EOfdmBmmaxQo4yGIgeYi9w/a8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1705325968; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=2M7U7TCMtOL+qn2haQDHrHyrktpb/DMFcGk6937LPZ4=; b=I4VzoCLSdDKjpB5OErlXNJWHWD96/t+iIWnYfDiRLR7Xb0ulGyOS1AAd0oyiE43YIVDStr Vd8+LPF7U6kxhmCw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1705325968; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=2M7U7TCMtOL+qn2haQDHrHyrktpb/DMFcGk6937LPZ4=; b=MP6ym8DpdZBD5gEwHmek+YKRaujGyNrZO0LgQNSlBos2+Lb0HWY5IEtxo332fnCNXG9WTY mUXno4Xae9ZsirBiZ7GbdViNTjUQXy9jqDrp/G/GN9dtF38+myUgBpnJ07W8LZMLcIlSCO wOchy9EOfdmBmmaxQo4yGIgeYi9w/a8= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1705325968; h=from:from:reply-to:date:date:to:to:cc:cc:mime-version:mime-version: content-type:content-type; bh=2M7U7TCMtOL+qn2haQDHrHyrktpb/DMFcGk6937LPZ4=; b=I4VzoCLSdDKjpB5OErlXNJWHWD96/t+iIWnYfDiRLR7Xb0ulGyOS1AAd0oyiE43YIVDStr Vd8+LPF7U6kxhmCw== Date: Mon, 15 Jan 2024 14:34:23 +0100 (CET) From: Richard Biener To: gcc-patches@gcc.gnu.org cc: jlaw@ventanamicro.com, ebotcazou@adacore.com, Jakub Jelinek Subject: [PATCH 1/2] rtl-optimization/113255 - base_alias_check vs. pointer difference MIME-Version: 1.0 Authentication-Results: smtp-out2.suse.de; none X-Spamd-Result: default: False [-0.60 / 50.00]; ARC_NA(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[4]; TO_DN_SOME(0.00)[]; TO_MATCH_ENVRCPT_ALL(0.00)[]; MIME_GOOD(-0.10)[text/plain]; 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(-3.00)[100.00%] X-Spam-Level: X-Spam-Score: -0.60 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: <20240115134013.752A73858C54@sourceware.org> X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788163929965492189 X-GMAIL-MSGID: 1788163929965492189 When the x86 backend generates code for cpymem with the rep_8byte strathegy for the 8 byte aligned main rep movq it needs to compute an adjusted pointer to the source after doing a prologue aligning the destination. It computes that via src_ptr + (dest_ptr - orig_dest_ptr) which is perfectly fine. On RTL this is then 8: r134:DI=const(`g'+0x44) 9: {r133:DI=frame:DI-0x4c;clobber flags:CC;} REG_UNUSED flags:CC 56: r129:DI=const(`g'+0x4c) 57: {r129:DI=r129:DI&0xfffffffffffffff8;clobber flags:CC;} REG_UNUSED flags:CC REG_EQUAL const(`g'+0x4c)&0xfffffffffffffff8 58: {r118:DI=r134:DI-r129:DI;clobber flags:CC;} REG_DEAD r134:DI REG_UNUSED flags:CC REG_EQUAL const(`g'+0x44)-r129:DI 59: {r119:DI=r133:DI-r118:DI;clobber flags:CC;} REG_DEAD r133:DI REG_UNUSED flags:CC but as written find_base_term happily picks the first candidate it finds for the MINUS which means it picks const(`g') rather than the correct frame:DI. This way find_base_term (but also the unfixed find_base_value used by init_alias_analysis to initialize REG_BASE_VALUE) performs pointer analysis isn't sound. The following restricts the handling of multi-operand operations to the case we know only one can be a pointer. This for example causes gcc.dg/tree-ssa/pr94969.c to miss some RTL PRE (I've opened PR113395 for this). A more drastic patch, removing base_alias_check results in only gcc.dg/guality/pr41447-1.c regressing (so testsuite coverage is bad). I've looked at gcc.dg/tree-ssa tests and mostly scheduling changes are present, the cc1plus .text size is only 230 bytes worse. With the this less drastic patch below most scheduling changes are gone. x86_64 might not the very best target to test for impact, but test coverage on other targets is unlikely to be very much better. Bootstrapped and tested on x86_64-unknown-linux-gnu (together with 2/2). Jeff, can you maybe throw this on your tester? Jakub, you did the PR64025 fix which was for a similar issue. OK for trunk? Thanks, Richard. PR rtl-optimization/113255 * alias.cc (find_base_term): Remove PLUS/MINUS handling when both operands are not CONST_INT_P. * gcc.dg/torture/pr113255.c: New testcase. --- gcc/alias.cc | 28 +++++-------------------- gcc/testsuite/gcc.dg/torture/pr113255.c | 27 ++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 23 deletions(-) create mode 100644 gcc/testsuite/gcc.dg/torture/pr113255.c diff --git a/gcc/alias.cc b/gcc/alias.cc index 99008b0390d..bdc119822b4 100644 --- a/gcc/alias.cc +++ b/gcc/alias.cc @@ -2077,31 +2077,13 @@ find_base_term (rtx x, vec= 0) + { + r++; + e[1].y++; + } + g[1] = e[1]; + return r; +} + +int +main () +{ + test (1); + if (g[1].y != 1) + __builtin_abort (); + return 0; +}