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/53976] [SH] Unnecessary clrt/sett after bt/bf


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

Oleg Endo <olegendo at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2014-08-13
            Summary|[SH] Unnecessary clrt after |[SH] Unnecessary clrt/sett
                   |bt                          |after bt/bf
     Ever confirmed|0                           |1

--- Comment #8 from Oleg Endo <olegendo at gcc dot gnu.org> ---
Another case that could be handled is trying to invert comparisons so that
conditional branches from multiple basic blocks have the same T bit value.

The following code:

static const int table[] = { 0, 1, 2, 3, 4, 9, 10, 42 };

int test (int n)
{
  return *std::lower_bound (std::begin (table), std::end (table), n);
}

compiled with -m2 -ml -Os:

        mov.l   .L37,r3
        mov     #8,r1
.L33:
        cmp/pl  r1
        bf.s    .L36
        mov     r1,r7
        shar    r7
        mov     r7,r2
        shll2   r2
        add     r3,r2
        mov.l   @r2,r6
        cmp/ge  r4,r6     <<<
        bt      .L35      <<<
        mov     r2,r3
        sett              <<<
        add     #4,r3
        bra     .L33
        subc    r7,r1
.L35:
        bra     .L33
        mov     r7,r1
.L36:
        rts    
        mov.l   @r3,r0
.L38:
        .align 2
.L37:
        .long    __ZN5test5L5tableE

In this case 'cmp/ge r4,r6; bt .L35' can be changed to 'cmp/gt r6,r4; bf .L35'
and the sett insn can be eliminated.


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