https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116780
Bug ID: 116780 Summary: [lra][avr] internal compiler error: output_operand: address operand requires constraint for X, Y, or Z register Product: gcc Version: 15.0 Status: UNCONFIRMED Severity: normal Priority: P3 Component: rtl-optimization Assignee: unassigned at gcc dot gnu.org Reporter: gjl at gcc dot gnu.org Target Milestone: --- Created attachment 59148 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=59148&action=edit pr64088.c: C test case $ avr-gcc pr64088.c -S -O1 -mlra -fdump-rtl-final during RTL pass: final dump file: pr64088.c.358r.final pr64088.c: In function 'setup_tone_curves_center_boost': pr64088.c:17:1: internal compiler error: output_operand: address operand requires constraint for X, Y, or Z register 17 | } | ^ 0x6f39cc output_operand_lossage(char const*, ...) ../../../source/gcc-master/gcc/final.cc:3190 0xdf09d8 ptrreg_to_str ../../../source/gcc-master/gcc/config/avr/avr.cc:2416 0xdf0ba2 avr_print_operand_address ../../../source/gcc-master/gcc/config/avr/avr.cc:2484 0xdf17d6 avr_print_operand ../../../source/gcc-master/gcc/config/avr/avr.cc:2694 0x6f479f output_operand(rtx_def*, int) ../../../source/gcc-master/gcc/final.cc:3632 0x6f42c2 output_asm_insn(char const*, rtx_def**) ../../../source/gcc-master/gcc/final.cc:3525 0xdf0960 avr_asm_len ../../../source/gcc-master/gcc/config/avr/avr.cc:2392 0xdf7db0 out_movhi_mr_r ../../../source/gcc-master/gcc/config/avr/avr.cc:5756 0xdf46a0 output_movhi(rtx_insn*, rtx_def**, int*) ../../../source/gcc-master/gcc/config/avr/avr.cc:3981 0x6f0e7c get_insn_template(int, rtx_insn*) ../../../source/gcc-master/gcc/final.cc:2027 0x6f2a2f final_scan_insn_1 ../../../source/gcc-master/gcc/final.cc:2773 0x6f2ea7 final_scan_insn(rtx_insn*, _IO_FILE*, int, int, int*) ../../../source/gcc-master/gcc/final.cc:2886 0x6f0ca3 final_1 ../../../source/gcc-master/gcc/final.cc:1977 0x6f59af rest_of_handle_final ../../../source/gcc-master/gcc/final.cc:4240 0x6f5d0e execute ../../../source/gcc-master/gcc/final.cc:4318 0x7f2d3446ed8f __libc_start_call_main ../sysdeps/nptl/libc_start_call_main.h:58 0x7f2d3446ee3f __libc_start_main_impl ../csu/libc-start.c:392 The reason why avr.cc::ptrreg_to_str() runs into output_operand_lossage() is that there are insns with invalid mem operands, like seen in the .final dump: (insn 27 2 28 (parallel [ (set (mem:HI (plus:HI (reg/f:HI 32 __SP_L__) (const_int 1 [0x1])) [1 b[0]+0 S2 A8]) (const_int 0 [0])) (clobber (reg:CC 36 cc)) ]) "pr64088.c":14:12 106 {*movhi} (expr_list:REG_UNUSED (reg:CC 36 cc) (nil))) The memory location is invalid because the stack pointer (regno __SP_L__) cannot be used to access stack slots. Indirect addressing and indirect addressing with offset must use one of the X, Y or Z registers (regno HI:26, HI:28, HI:30 respectively). The code from old reload (-mno-lra) is correct: It loads SP to reg:HI 30 (Z): (insn 28 2 29 (parallel [ (set (reg:HI 30 r30) (reg/f:HI 32 __SP_L__)) (clobber (reg:CC 36 cc)) ]) "pr64088.c":14:12 106 {*movhi} (expr_list:REG_UNUSED (reg:CC 36 cc) (nil))) (insn 29 28 30 (parallel [ (set (mem:HI (plus:HI (reg:HI 30 r30) (const_int 1 [0x1])) [1 b[0]+0 S2 A8]) (const_int 0 [0])) (clobber (reg:CC 36 cc)) ]) "pr64088.c":14:12 106 {*movhi} (expr_list:REG_UNUSED (reg:CC 36 cc) (nil))) Target: avr Configured with: ../../source/gcc-master/configure --target=avr --disable-nls --with-dwarf2 --with-gnu-as --with-gnu-ld --disable-shared --enable-languages=c,c++ Thread model: single Supported LTO compression algorithms: zlib gcc version 15.0.0 20240918 (experimental) (GCC)