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

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |law at gcc dot gnu.org,
                   |                            |segher at gcc dot gnu.org

--- Comment #4 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
I think this boils down whether it is valid to have REG_EQUAL note on a REG_INC
insn or not.
The documentation says:
"This note is only valid on an insn that sets only one register"
but REG_INC insns actually set two registers, the result and
increment/decrement some other register.
The combiner has code to count the autoincs before/after transformation and
punts if they disagree, but because of the REG_EQUAL note the:
1498                      /* Temporarily replace the set's source with the
1499                         contents of the REG_EQUAL note.  The insn will
1500                         be deleted or recognized by try_combine.  */
...
code just replaces the
(insn 7 29 8 2 (set (reg:TI 95 [ D.3590 ])
        (mem/u/c:TI (post_inc:DI (reg/f:DI 106)) [0  S16 A128]))
"pr94873.c":11:48 58 {*movti_aarch64}
     (expr_list:REG_INC (reg/f:DI 106)
        (expr_list:REG_EQUAL (const_wide_int 0x0f4409395252b9560)
            (nil))))
insn so that it is
(insn 7 29 8 2 (set (reg:TI 95 [ D.3590 ])
        (const_wide_int 0x0f4409395252b9560)) "pr94873.c":11:48 58
{*movti_aarch64}
     (expr_list:REG_INC (reg/f:DI 106)
        (expr_list:REG_EQUAL (const_wide_int 0x0f4409395252b9560)
            (nil))))
and when counting auto_inc on that, we don't find anything, so happily drop the
 auto-inc side-effect.

So, if REG_EQUAL is invalid on REG_INC insns, the auto-inc pass should throw
away those notes from insns which it optimizes, if it is not invalid, combiner
needs to ignore REG_EQUAL notes on REG_INC insns or something similar (or count
the auto-inc effects on the original vs. replacement and if they disagree,
punt).

Reply via email to