On Wednesday, 11 November 2026 at 3:15 AM, Andrea Pinski <[email protected]> wrote: > > On Tue, Nov 10, 2026 at 8:20 AM Jeff Law <[email protected]> wrote: > > > > > > > > On 11/4/26 8:35 AM, Andrew DeRosier wrote: > > > r16-160-ge6f89d78c1a752 made a change to simplify-rtx that exposes an > > > existing latent bug in gen_lowpart_if_possible, which widens a MEM with > > > byte_lowpart_offset. That offset is negative on big-endian targets, > > > so on m68k a byte load from foo becomes a longword load from foo-3, > > > causing an address error. > > > > > > Based on how gen_lowpart_for_combine refuses to widen a MEM, this patch > > > makes gen_lowpart_if_possible return NULL_RTX for a paradoxical lowpart. > > > > > > Bootstrapped and regtested on x86_64-pc-linux-gnu. Also tested on > > > m68k-elf with a Musashi-based 68000 simulator, where it fixes address > > > errors in 20040709-2.c, 20040709-3.c, pr57875.c and pr79737-1.c at > > > several optimization levels, with no regressions. > > > > > > gcc/ChangeLog: > > > > > > PR rtl-optimization/125728 > > > * rtlhooks.cc (gen_lowpart_if_possible): Return NULL_RTX for a > > > paradoxical lowpart of a MEM instead of widening the access. > > > > > > gcc/testsuite/ChangeLog: > > > > > > PR rtl-optimization/125728 > > > * gcc.target/m68k/pr125728.c: New test. > > > > > > Signed-off-by: Andrew DeRosier <[email protected]> > > Changes in these routines are always tricky, so before even thinking > > hard about the patch I threw it into my tester and multiple targets are > > throwing errors during self-test. So I don't *think* you need a full > > cross environment. You should be able to configure a cross compiler for > > one of these targets and try to build. What you'll be looking for is > > something like this: > > > > > > > > > > > > cc1: internal compiler error: in gen_rtx_SUBREG, at emit-rtl.cc:1062 > > 0x1f4939d internal_error(char const*, ...) > > ../../..//gcc/gcc/diagnostic-global-context.cc:787 > > 0x892d3d fancy_abort(char const*, int, char const*) > > ../../..//gcc/gcc/diagnostics/context.cc:1813 > > 0x661e02 gen_rtx_SUBREG(machine_mode, rtx_def*, poly_int<1u, unsigned long>) > > ../../..//gcc/gcc/emit-rtl.cc:1062 > > 0x661e02 gen_rtx_SUBREG(machine_mode, rtx_def*, poly_int<1u, unsigned long>) > > ../../..//gcc/gcc/emit-rtl.cc:1060 > > 0xbaa785 test_output_operand_modifier_operand > > ../../..//gcc/gcc/final.cc:4798 > > 0xbaa785 selftest::final_cc_tests() > > ../../..//gcc/gcc/final.cc:4820 > > 0x1eaabbb selftest::run_tests() > > ../../..//gcc/gcc/selftest-run-tests.cc:109 > > 0xff471a toplev::run_self_tests() > > ../../..//gcc/gcc/toplev.cc:2287 > > > > This is from H8 I think, but the others I spot checked had similar > > behavior (microblaze-linux, moxie-elf, iq2000-elf, h8300-elf). > > Yes I was very much worried about fallout here even. I did try to warn > about this fallout in > https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125728#c5 but I could > have been more verbose there. > > Thanks, > Andrea > > > > > Jeff > > > > Jeff >
Pulled e26706962, set up an h8300-elf cross compiler... and the self tests passed. It looks like the failing test from that trace (test_output_operand_modifier_operand) is new (f90f14685) and something was fixed about it in 0f8ee5980. After reverting that commit I reproduced the ICE on h8300 and even m68k without this patch. Based on the commit message, I'm thinking the big endian targets were broken in that 4 hour window. https://gcc.gnu.org/cgit/gcc/commit/?id=0f8ee5980094f46eb7ef6398beda7ffe125e7608 Thanks, Andrew
