public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug target/96050] New: PDP-11: 32-bit MOV from offset(Rn) overrides Rn
@ 2020-07-03 17:38 imachug at gmail dot com
  2021-03-19 22:10 ` [Bug target/96050] " pkoning at gcc dot gnu.org
  2023-07-13 20:42 ` pkoning at gcc dot gnu.org
  0 siblings, 2 replies; 3+ messages in thread
From: imachug at gmail dot com @ 2020-07-03 17:38 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96050

            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 = structure.a;
        unsigned long y = 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 adding
"&" to lines 529, 536 in pdp11.md (i.e. changing "=r,r,g,g" to "=&r,r,g,g" in
"[(set (match_operand:SI 0 "nonimmediate_operand" "=r,r,g,g")") didn't fix the
bug for me.


$ ./tools/bin/pdp11-aout-gcc -v
Using built-in specs.
COLLECT_GCC=./tools/bin/pdp11-aout-gcc-10.1.0
COLLECT_LTO_WRAPPER=/[redacted]/tools/libexec/gcc/pdp11-aout/10.1.0/lto-wrapper
Target: pdp11-aout
Configured with: ../configure --prefix /[redacted]/tools --target pdp11-aout
--enable-languages=c --with-gnu-as --with-gnu-ld --without-headers
--disable-libssp
Thread model: single
Supported LTO compression algorithms: zlib
gcc version 10.1.0 (GCC) 

$ 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

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug target/96050] PDP-11: 32-bit MOV from offset(Rn) overrides Rn
  2020-07-03 17:38 [Bug target/96050] New: PDP-11: 32-bit MOV from offset(Rn) overrides Rn imachug at gmail dot com
@ 2021-03-19 22:10 ` pkoning at gcc dot gnu.org
  2023-07-13 20:42 ` pkoning at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pkoning at gcc dot gnu.org @ 2021-03-19 22:10 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96050

pkoning at gcc dot gnu.org changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Last reconfirmed|                            |2021-03-19
             Status|UNCONFIRMED                 |ASSIGNED
     Ever confirmed|0                           |1

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [Bug target/96050] PDP-11: 32-bit MOV from offset(Rn) overrides Rn
  2020-07-03 17:38 [Bug target/96050] New: PDP-11: 32-bit MOV from offset(Rn) overrides Rn imachug at gmail dot com
  2021-03-19 22:10 ` [Bug target/96050] " pkoning at gcc dot gnu.org
@ 2023-07-13 20:42 ` pkoning at gcc dot gnu.org
  1 sibling, 0 replies; 3+ messages in thread
From: pkoning at gcc dot gnu.org @ 2023-07-13 20:42 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96050

--- Comment #1 from pkoning at gcc dot gnu.org ---
There certainly are some missing earlyclobbers in the MD file.  Someone else
reported bad code from this and a patch to add the missing "&" fixed those. 
Curious that it doesn't for your test case; it suggests that there is an
additional issue that needs to be understood.

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-07-13 20:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-07-03 17:38 [Bug target/96050] New: PDP-11: 32-bit MOV from offset(Rn) overrides Rn imachug at gmail dot com
2021-03-19 22:10 ` [Bug target/96050] " pkoning at gcc dot gnu.org
2023-07-13 20:42 ` pkoning at gcc dot gnu.org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).