Re: [patch] AVR: Tweak reg == const and reg != const compares if const = 0 mod 256

Denis Chertykov <[email protected]>
Newsgroups gmane.comp.gcc.patches
Message-ID <CADOs=zZjcu2fGsDCApQgWVU3fgso5Z7=r+ZBtMUAsWj6x5NoZg@mail.gmail.com>
чт, 13 авг. 2026 г. в 22:03, Georg-Johann Lay <[email protected]>:
>
> This patch tweaks the EQ and NE comparison of a register against
> a const_int or const_fixed by one instruction in the case where
> the constant is 0 mod 256.  For example, take the comparison in
>
> _Accum cmp (_Accum x)
> {
>     if (x != 1.0k)
>        x += 2.0k;
>     return x;
> }
>
> which improves from
>
>     cpi r22,0
>     ldi r18,-128
>     cpc r23,r18
>     cpc r24,r22
>     cpc r25,r22
>
> to
>
>     cpi r23,-128
>     cpc r22,__zero_reg__
>     cpc r24,__zero_reg__
>     cpc r25,__zero_reg__
>
> One unsolved problem is that the latter sequence doesn't need
> a scratch reg but is still allocating one.
>
> Ok for trunk?

Ok. Please apply.
>
> p.s.: There are also some Binutils patches which seems to have sneaked
> past your attention:
> https://sourceware.org/pipermail/binutils/2026-July/149967.html
> https://sourceware.org/pipermail/binutils/2026-August/150739.html

You can apply both.

Denis.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.