https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116550
Bug ID: 116550 Summary: [lra][avr] internal compiler error: in final_scan_insn_1, at final.cc:2807 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 59030 --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=59030&action=edit lra-bug3.c: C test case from libgcc $ avr-gcc lra-bug3.c -mmcu=avr25 -Os -S -mlra -fnon-call-exceptions lra-bug3.c: In function '__divmoddi4': lra-bug3.c:214:1: error: could not split insn 214 | } | ^ (insn 528 1670 1671 (parallel [ (set (reg/v:SI 24 r24 [orig:146 __q1 ] [146]) (plus:SI (reg/v:SI 24 r24 [orig:146 __q1 ] [146]) (const_int -2 [0xfffffffffffffffe]))) (clobber (mem/c:QI (plus:HI (reg/f:HI 28 r28) (const_int 33 [0x21])) [6 %sfp+33 S1 A8])) ]) "lra-bug3.c":163:405 discrim 7 186 {addsi3} (nil)) during RTL pass: final dump file: lra-bug3.c.357r.final lra-bug3.c:214:1: internal compiler error: in final_scan_insn_1, at final.cc:2807 That insn is invalid, of course. With -da, the .ira dump reads: (insn 500 499 501 65 (parallel [ (set (reg/v:SI 146 [ __q1 ]) (plus:SI (reg/v:SI 146 [ __q1 ]) (const_int -2 [0xfffffffffffffffe]))) (clobber (scratch:QI)) ]) "lra-bug3.c":163:405 discrim 7 186 {addsi3} (nil)) so everything is fine (at least as far as the dump goes). .reload has then: (insn 1393 499 500 89 (set (reg/v:SI 18 r18 [orig:146 __q1 ] [146]) (mem/c:SI (plus:HI (reg/f:HI 28 r28) (const_int 33 [0x21])) [6 %sfp+33 S4 A8])) "lra-bug3.c":163:405 discrim 7 119 {*movsi_split} (nil)) (insn 500 1393 1394 89 (parallel [ (set (reg/v:SI 18 r18 [orig:146 __q1 ] [146]) (plus:SI (reg/v:SI 18 r18 [orig:146 __q1 ] [146]) (const_int -2 [0xfffffffffffffffe]))) (clobber (mem/c:QI (plus:HI (reg/f:HI 28 r28) (const_int 33 [0x21])) [6 %sfp+33 S1 A8])) ]) "lra-bug3.c":163:405 discrim 7 186 {addsi3} (nil)) As it seems, R146 has been spilled to FP+33, and insn 1393 is loading it to R18. The clobber operand looks like a colateral damage. FYI, the insn reads: ;; "addsi3" ;; "addsq3" "addusq3" ;; "addsa3" "addusa3" (define_insn_and_split "add<mode>3" [(set (match_operand:ALL4 0 "register_operand" "=??r,d ,r") (plus:ALL4 (match_operand:ALL4 1 "register_operand" "%0,0 ,0") (match_operand:ALL4 2 "nonmemory_operand" "r,i ,n Ynn"))) (clobber (match_scratch:QI 3 "=X,X ,&d"))] "" "#" "&& reload_completed" ...) A QImode scratch is only required when op0 ends up in a non-d register (REGNO < 16), hence the 2nd alternatice should match and op3 = scratch:QI. This ICE is relatively new; I don't see it with "gcc version 15.0.0 20240818". Target: avr Configured with: ../../source/gcc-master/configure --target=avr --disable-nls --with-dwarf2 --with-gnu-as --with-gnu-ld --disable-shared --with-long-double=64 --enable-languages=c,c++ gcc version 15.0.0 20240831 (experimental) (GCC)