https://gcc.gnu.org/bugzilla/show_bug.cgi?id=116649
--- Comment #4 from Jeevitha <jeevitha at gcc dot gnu.org> ---
(In reply to Segher Boessenkool from comment #3)
> There are way more places we could usefully generate set[n]bc[r] insns. For
> example, consider
>
> int f(int a, int b, int x) { return a < b ? x+5 : x+6; }
>
> We currently generate a branchy thing for that, I actually expected an isel
> thing, but we could likely do better with setbc even.
>
> So if you find anything more, please let us know!
Currently, this code emits the following sequence:
f:
cmpw 0,3,4
bge 0,.L2
addi 3,5,5
extsw 3,3
blr
.L2:
addi 3,5,6
extsw 3,3
blr
A better sequence using isel could be:
cmpw %r3,%r4
li %r3,6
li %r4,5
isel %r3,%r4,%r3,0
add %r3,%r3,%r5
extsw %r3,%r3
blr
No idea with set[n]bc[r] insns.
Do we have a PR for this missed optimisation?