https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126121
Bug ID: 126121
Summary: m68k: wrong code generated with 8-bit bset
Product: gcc
Version: 17.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: target
Assignee: unassigned at gcc dot gnu.org
Reporter: kristerw at gcc dot gnu.org
Blocks: 118443
Target Milestone: ---
Target: m68k-elf-gcc
The following function is miscompiled for m68k with -O1:
void foo(char *a, int b) {
char c = 1 << b;
*a |= c;
}
The generated code is:
foo:
move.l 4(%sp),%a0
move.l 8(%sp),%d0
bset %d0,(%a0)
rts
This is incorrect when b > 7. For example, if b is 8, the generated code sets
bit 0 of *a, where the original function does not modify the memory.
Referenced Bugs:
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118443
[Bug 118443] [Meta bug] Bugs triggered by and blocking more smtgcc testing