diff options
author | Mikael Pettersson <mikpelinux@gmail.com> | 2024-01-19 16:05:34 -0700 |
---|---|---|
committer | Jeff Law <jlaw@ventanamicro.com> | 2024-01-19 16:05:34 -0700 |
commit | a834414794d80f21550dd0591e260fc833f49eb9 (patch) | |
tree | 69fd8cd69b8991b9b64303343d2556e92f5f5599 /gcc/config/m68k | |
parent | 07b392550f37bd9bb146dcef3d110111fb3ad114 (diff) | |
download | gcc-a834414794d80f21550dd0591e260fc833f49eb9.zip gcc-a834414794d80f21550dd0591e260fc833f49eb9.tar.gz gcc-a834414794d80f21550dd0591e260fc833f49eb9.tar.bz2 |
[PATCH] Avoid ICE in single-bit logical RMWs on m68k-uclinux [PR108640]
When generating RMW logical operations on m68k, the backend
recognizes single-bit operations and rewrites them as bit
instructions on operands adjusted to address the intended byte.
When offsetting the addresses the backend keeps the modes as
SImode, even though the actual access will be in QImode.
The uclinux target defines M68K_OFFSETS_MUST_BE_WITHIN_SECTIONS_P
which adds a check that the adjusted operand is within the bounds
of the original object. Since the address has been offset it is
not, and the compiler ICEs.
The bug is that the modes of the adjusted operands should have been
narrowed to QImode, which is that this patch does. Nearby code
which narrows to HImode gets that right.
Bootstrapped and regression tested on m68k-linux-gnu.
Ok for master? (Note: I don't have commit rights.)
gcc/
PR target/108640
* config/m68k/m68k.cc (output_andsi3): Use QImode for
address adjusted for 1-byte RMW access.
(output_iorsi3): Likewise.
(output_xorsi3): Likewise.
gcc/testsuite/
PR target/108640
* gcc.target/m68k/pr108640.c: New test.
Diffstat (limited to 'gcc/config/m68k')
-rw-r--r-- | gcc/config/m68k/m68k.cc | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/gcc/config/m68k/m68k.cc b/gcc/config/m68k/m68k.cc index e932568..6cd45b5 100644 --- a/gcc/config/m68k/m68k.cc +++ b/gcc/config/m68k/m68k.cc @@ -5471,7 +5471,7 @@ output_andsi3 (rtx *operands) operands[1] = GEN_INT (logval); else { - operands[0] = adjust_address (operands[0], SImode, 3 - (logval / 8)); + operands[0] = adjust_address (operands[0], QImode, 3 - (logval / 8)); operands[1] = GEN_INT (logval % 8); } return "bclr %1,%0"; @@ -5510,7 +5510,7 @@ output_iorsi3 (rtx *operands) operands[1] = GEN_INT (logval); else { - operands[0] = adjust_address (operands[0], SImode, 3 - (logval / 8)); + operands[0] = adjust_address (operands[0], QImode, 3 - (logval / 8)); operands[1] = GEN_INT (logval % 8); } return "bset %1,%0"; @@ -5548,7 +5548,7 @@ output_xorsi3 (rtx *operands) operands[1] = GEN_INT (logval); else { - operands[0] = adjust_address (operands[0], SImode, 3 - (logval / 8)); + operands[0] = adjust_address (operands[0], QImode, 3 - (logval / 8)); operands[1] = GEN_INT (logval % 8); } return "bchg %1,%0"; |