From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 22757385E451; Fri, 15 Mar 2024 23:29:18 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 22757385E451 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1710545358; bh=ri66lwXtUm9GsIomGisKmz0DBijlJomkPkSy7W2x70A=; h=From:To:Subject:Date:In-Reply-To:References:From; b=f8ufMH6jBmxDHJzgxdneDMhU9cwnjsqjkYpMKHsfGgfZuiwYx1YsDauTzvYhyroTG P4PxwfDSYrVV1uXgaYis2hbIvR3Bijvo/QviRksGiT8KPoFEA0HmmFL5VpbKp3Siw3 J9oTYDy7zwpj5ZWDDhkGwJvjhyZ5AkTluQEheFnk= From: "cvs-commit at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug rtl-optimization/114211] [13 Regression] wrong code with -O -fno-tree-coalesce-vars since r13-1907 Date: Fri, 15 Mar 2024 23:29:15 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: rtl-optimization X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: wrong-code X-Bugzilla-Severity: normal X-Bugzilla-Who: cvs-commit at gcc dot gnu.org X-Bugzilla-Status: ASSIGNED X-Bugzilla-Resolution: X-Bugzilla-Priority: P2 X-Bugzilla-Assigned-To: jakub at gcc dot gnu.org X-Bugzilla-Target-Milestone: 13.3 X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D114211 --- Comment #10 from GCC Commits --- The releases/gcc-13 branch has been updated by Jakub Jelinek : https://gcc.gnu.org/g:df3994a1be3565ad450d552dc94b696748a7807a commit r13-8447-gdf3994a1be3565ad450d552dc94b696748a7807a Author: Jakub Jelinek Date: Tue Mar 5 10:32:38 2024 +0100 lower-subreg: Fix ROTATE handling [PR114211] On the following testcase, we have (insn 10 7 11 2 (set (reg/v:TI 106 [ h ]) (rotate:TI (reg/v:TI 106 [ h ]) (const_int 64 [0x40]))) "pr114211.c":8:5 1042 {rotl64ti2_doubleword} (nil)) before subreg1 and the pass decides to use (reg:DI 127 [ h ]) / (reg:DI 128 [ h+8 ]) register pair instead of (reg/v:TI 106 [ h ]). resolve_operand_for_swap_move_operator implements it by pretending it is an assignment from (concatn (reg:DI 127 [ h ]) (reg:DI 128 [ h+8 ])) to (concatn (reg:DI 128 [ h+8 ]) (reg:DI 127 [ h ])) The problem is that if the rotate argument is the same as destination or if there is even an overlap between the first half of the destination w= ith second half of the source we emit incorrect code, because the store to (reg:DI 128 [ h+8 ]) overwrites what we need for source of the second move. The following patch detects that case and uses a temporary pseudo to hold the original (reg:DI 128 [ h+8 ]) value across the first store. 2024-03-05 Jakub Jelinek PR rtl-optimization/114211 * lower-subreg.cc (resolve_simple_move): For double-word rotates by BITS_PER_WORD if there is overlap between source and destination use a temporary. * gcc.dg/pr114211.c: New test. (cherry picked from commit aed445b0fd0c7ed16124c61e7eb732992426f103)=