[Bug target/54236] [SH] Improve addc and subc insn utilization
olegendo at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Sun Jul 19 06:47:00 GMT 2015
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=54236
--- Comment #16 from Oleg Endo <olegendo at gcc dot gnu.org> ---
Created attachment 36012
--> https://gcc.gnu.org/bugzilla/attachment.cgi?id=36012&action=edit
addsicc pattern
(In reply to Oleg Endo from comment #9)
> The following function compiled with -O2
>
> unsigned int check (unsigned int x)
> {
> return x == 0 ? 1 : x;
> }
>
> results in:
> tst r4,r4
> bt/s .L7
> mov #1,r0
> mov r4,r0
> .L7:
> rts
> nop
>
>
> Writing it as:
> unsigned int check (unsigned int x)
> {
> return x + (x == 0);
> }
>
> results in:
> tst r4,r4
> mov #0,r0
> rts
> addc r4,r0
>
> It seems that ifcvt is trying to utilize the 'add<mode>cc' standard name
> pattern. If the 2nd operand of the conditional addition is a constant 1 or
> -1 the addcc insn can be implemented via addc or subc without a branch.
The attached patch adds support for the addsicc pattern and a few other
improvements. However, the first case above doesn't see any improvement. It
seems that it's a missed ifcvt optimization.
More information about the Gcc-bugs
mailing list