This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug target/59533] [SH] Missed cmp/pz opportunity


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

--- Comment #7 from Oleg Endo <olegendo at gcc dot gnu.org> ---
If a shll is followed by a cbranch:

unsigned int
test_09_0 (int x, unsigned int y, unsigned int z)
{
  return ~(x >> 31) ? y : z;
}

        shll    r4
        bf      .L4
        mov     r6,r5
.L4:
        rts
        mov    r5,r0

it's better to use cmp/pz and invert the branch condition.
Combine is looking for the following pattern:

Failed to match this instruction:
(set (pc)
    (if_then_else (ge (reg:SI 4 r4 [ x ])
            (const_int 0 [0]))
        (label_ref:SI 17)
        (pc)))

One option could be adding a pattern like:

(define_insn_and_split "*cbranch"
  [(set (pc)
        (if_then_else (match_operand 0 "treg_set_expr")
                      (label_ref (match_operand 1))
                      (pc)))
   (clobber (reg:SI T_REG))]


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]