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

--- Comment #3 from pietro <pietro.gcc at sociotechnical dot xyz> ---
The following peehole:

(define_peephole
  [(set (match_operand:SI 0 "arith_reg_dest")
        (plus:SI (match_dup 0)
             (match_operand:SI 1 "arith_reg_operand")))
        (set (match_operand:SI 2 "arith_reg_dest")
        (plus:SI (match_dup 2)
             (const_int 1)))]
  "TARGET_SH1
   && REGNO (operands[0]) == REGNO (operands[2])"
{
  return "sett" "\n"
        "\taddc %1,%0";
})

generates:

        cmp/eq  r5,r4
        mov     r5,r1
        sett
        addc    r6,r1
        rts     
        movt    r0

I tried this one too:

(define_peephole2
  [(set (match_operand:SI 0 "arith_reg_dest")
        (plus:SI (match_dup 0)
             (match_operand:SI 1 "arith_reg_operand")))
        (set (match_operand:SI 2 "arith_reg_dest")
        (plus:SI (match_dup 2)
             (const_int 1)))]
  "TARGET_SH1
   && REGNO (operands[0]) == REGNO (operands[2])"
   [(const_int 0)]
{
        emit_insn (gen_sett ());
        emit_insn (gen_addc (operands[0], operands[0], operands[1]));
})

but then the cmp/eq is swallowed:

        sett
        mov     r5,r1
        addc    r6,r1
        rts     
        movt    r0
  • [Bug target/59291] [SH] ... pietro.gcc at sociotechnical dot xyz via Gcc-bugs

Reply via email to