From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id 1DD013844079; Fri, 3 Jul 2020 17:38:14 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 1DD013844079 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1593797894; bh=KVRtTx2Bolg36FPHP5vDWbNEm9svuidmtuwcdBuARa8=; h=From:To:Subject:Date:From; b=wTEfAFedxGk3UvDpo5YopS9JfAZBEc0zhLyCHM/wKllaUDjUUnMo461hRW/u9/mqR KDYW9Eew/cmm3bKoanBdFG4h2dBeGPuW2tchYtnqBSJSLw8aTBZ08mY5jCfR+eUmSR gO+BCHtFqvFmb4ooIPv/G4y05ll1RyD1AsLujsZY= From: "imachug at gmail dot com" To: gcc-bugs@gcc.gnu.org Subject: [Bug target/96050] New: PDP-11: 32-bit MOV from offset(Rn) overrides Rn Date: Fri, 03 Jul 2020 17:38:13 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: target X-Bugzilla-Version: 10.1.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: imachug at gmail dot com X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status bug_severity priority component assigned_to reporter target_milestone Message-ID: 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 X-BeenThere: gcc-bugs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-bugs mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 03 Jul 2020 17:38:14 -0000 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D96050 Bug ID: 96050 Summary: PDP-11: 32-bit MOV from offset(Rn) overrides Rn Product: gcc Version: 10.1.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: target Assignee: unassigned at gcc dot gnu.org Reporter: imachug at gmail dot com Target Milestone: --- Consider the following code: struct { unsigned long a, b; } structure; void calc() { unsigned long x =3D structure.a; unsigned long y =3D structure.b; asm volatile(""::"r"(x), "r"(y)); } ("asm volatile" is just to stop GCC from removing x and y completely) When this source is compiled with "-Os -S", GCC erroneously generates the following assembly to load structure members to registers: mov $_structure,r0 mov (r0),r2 mov 02(r0),r3 mov 04(r0),r0 mov 06(r0),r1 "mov 04(r0), r0" overrides r0, which the next instruction assumes to contain the old non-overwritten value. I think this has to do with disabled early clobbering on movsi insn, but ad= ding "&" to lines 529, 536 in pdp11.md (i.e. changing "=3Dr,r,g,g" to "=3D&r,r,g= ,g" in "[(set (match_operand:SI 0 "nonimmediate_operand" "=3Dr,r,g,g")") didn't fi= x the bug for me. $ ./tools/bin/pdp11-aout-gcc -v Using built-in specs. COLLECT_GCC=3D./tools/bin/pdp11-aout-gcc-10.1.0 COLLECT_LTO_WRAPPER=3D/[redacted]/tools/libexec/gcc/pdp11-aout/10.1.0/lto-w= rapper Target: pdp11-aout Configured with: ../configure --prefix /[redacted]/tools --target pdp11-aout --enable-languages=3Dc --with-gnu-as --with-gnu-ld --without-headers --disable-libssp Thread model: single Supported LTO compression algorithms: zlib gcc version 10.1.0 (GCC)=20 $ uname -a Linux [redacted] 5.3.0-59-generic #53-Ubuntu SMP Wed Jun 3 15:52:15 UTC 2020 x86_64 x86_64 x86_64 GNU/Linux=