вс, 15 сент. 2024 г. в 19:32, Georg-Johann Lay <a...@gjlay.de>:
>
> Unsigned comparisons may skip comparing the lower bytes when
> the according bytes of the constant are all zeros.  For example,
>
>      uint16 >= 0x1200
>
> is true iff
>
>      hi8 (uint16) >= hi8 (0x1200)
>
> and similar for uint16 < 0x1200.  Some comparisons against constants
> that are an integral power of 256 where already handled in the split
> preparation.  That code has been outsourced to new avr_maybe_cmp_lsr()
> which may change the operands such that the resulting insns become
> a comparison of the high bytes against 0 plus a EQ / NE branch.
> For example,
>
>      uint32 >= 0x10000
>
> can be rewritten as
>
>      (uint32 >> 16) != 0.
>
> The according asm output is performed by new avr_out_cmp_lsr().
>
> Ok for trunk?

Please apply.

Denis.

>
> Johann
>
> --
>
> gcc/
>         * config/avr/avr-protos.h (avr_out_cmp_lsr, avr_maybe_cmp_lsr): New.
>         * config/avr/avr.cc (avr_maybe_cmp_lsr, avr_out_cmp_lsr): New 
> functions.
>         (avr_out_compare) [GEU, LTU]: Start output at byte CTZ(xval) / 8.
>         (avr_adjust_insn_length) [ADJUST_LEN_CMP_LSR]: Handle case.
>         * config/avr/avr.md (adjust_len) <cmp_lsr>: New attr value.
>         (*cmp<mode>_lsr): New define_insn_and_split.
>         (cbranch<mode>4_insn): When splitting, run avr_maybe_cmp_lsr()
>         which may map the operands to *cmp<mode>_lsr.
> gcc/testsuite/
>         * gcc.target/avr/torture/cmp-lsr-u16.c: New test.
>         * gcc.target/avr/torture/cmp-lsr-u24.c: New test.
>         * gcc.target/avr/torture/cmp-lsr-u32.c: New test.
>         * gcc.target/avr/torture/cmp-lsr-u64.c: New test.

Reply via email to