https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105753

Georg-Johann Lay <gjl at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|target                      |rtl-optimization

--- Comment #15 from Georg-Johann Lay <gjl at gcc dot gnu.org> ---
The error is in the combine pass.

Prior to combine, we have the followng insn for divmod (from -da init-regs
dump):

(insn 9 7 11 3 (parallel [
            (set (reg:SI 50)
                (udiv:SI (reg/v:SI 47 [ n ])
                    (reg:SI 51)))
            (set (reg:SI 49)
                (umod:SI (reg/v:SI 47 [ n ])
                    (reg:SI 51)))
            (clobber (reg:SI 18 r18))
            (clobber (reg:SI 22 r22))
            (clobber (reg:HI 26 r26))
            (clobber (reg:HI 30 r30))
        ]) "bug.c":6:15 403 {udivmodsi4}
     (expr_list:REG_UNUSED (reg:HI 30 r30)
        (expr_list:REG_UNUSED (reg:HI 26 r26)
            (expr_list:REG_UNUSED (reg:SI 22 r22)
                (expr_list:REG_UNUSED (reg:SI 18 r18)
                    (nil))))))

This basically encodes a transparent libgcc call to __udivmodsi4 (insn
"*udivmodsi4_call").

The combine dump however reads:

(insn 9 7 11 3 (set (reg:SI 49)
        (umod:SI (reg/v:SI 47 [ n ])
            (reg:SI 51))) "bug.c":6:15 403 {udivmodsi4}
     (expr_list:REG_UNUSED (reg:HI 30 r30)
        (expr_list:REG_UNUSED (reg:HI 26 r26)
            (expr_list:REG_UNUSED (reg:SI 22 r22)
                (expr_list:REG_UNUSED (reg:SI 18 r18)
                    (nil))))))
(insn 11 9 14 3 (set (reg/v:SI 45 [ n ])
        (reg/v:SI 47 [ n ])) 119 {*movsi_split}
     (expr_list:REG_DEAD (reg/v:SI 47 [ n ])
        (nil)))
(insn 14 11 15 3 (set (reg/v:SI 47 [ n ])
        (udiv:SI (reg/v:SI 47 [ n ])
            (reg:SI 51))) "bug.c":7:7 119 {*movsi_split}
     (expr_list:REG_DEAD (reg:SI 50)
        (nil)))

These udiv and umod insn do not exist and are unrecognizable.  Combine should
never have split the original udivmodsi4.

I used the original test case from comment #0 with 

$ avr-gcc bug.c -S -O1 -mmcu=atmega8 -da 

where avr-gcc is from 2023-03-03 master (future v13).

With -fdisable-rtl-combine no ICE occurs.

Reply via email to