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

--- Comment #5 from Oleg Endo <olegendo at gcc dot gnu.org> ---
(In reply to Segher Boessenkool from comment #4)
> 
> What are the original instructions it tried to combine here?

(insn 7 4 8 2 (parallel [
            (set (reg:SI 168 [ r ])
                (lshiftrt:SI (reg/v:SI 165 [ a ])
                    (const_int 31 [0x1f])))
            (clobber (reg:SI 147 t))
        ]) sh_tmp.cpp:6 136 {lshrsi3_n_clobbers_t}
     (expr_list:REG_DEAD (reg/v:SI 165 [ a ])
        (expr_list:REG_UNUSED (reg:SI 147 t)
            (nil))))

(insn 8 7 13 2 (parallel [
            (set (reg:SI 167)
                (ashift:SI (reg:SI 168 [ r ])
                    (const_int 31 [0x1f])))
            (clobber (reg:SI 147 t))
        ]) sh_tmp.cpp:7 118 {ashlsi3_n_clobbers_t}
     (expr_list:REG_DEAD (reg:SI 168 [ r ])
        (expr_list:REG_UNUSED (reg:SI 147 t)
            (nil))))


> If the
> combined insn does not match (as here), combine tries to split it into
> two in various ways, but only if it started out with more than two insns.
> Now that we also check for insn cost we could change that (allow combining
> 2->2 if that reduces the rtx cost), but this will of course need testing
> everywhere.  I'll see what I can do.

I was really thinking of just adding that special case for const_int vs. reg
operands.  I.e. if the created insn doesn't match, and has some const_int
operands, replace const_int with reg in the insn and try again -- taking the
cost of the constant load into account would be nice, too.  Not sure if other
targets would benefit from that...

Reply via email to