diff options
author | Georg-Johann Lay <avr@gjlay.de> | 2024-09-15 16:58:09 +0200 |
---|---|---|
committer | Georg-Johann Lay <avr@gjlay.de> | 2024-09-16 14:05:23 +0200 |
commit | 7fb1117310def905f8d151196b8655247dff68ee (patch) | |
tree | cc38602938e39f4fd9f255dde2427bc02d4e6339 /gcc/tree-ssa-phiopt.cc | |
parent | 952df9c50b30cc6f849c422b84592a81524f8ef7 (diff) | |
download | gcc-7fb1117310def905f8d151196b8655247dff68ee.zip gcc-7fb1117310def905f8d151196b8655247dff68ee.tar.gz gcc-7fb1117310def905f8d151196b8655247dff68ee.tar.bz2 |
AVR: Tweak >= and < compares with consts that are 0 mod 256.
The >= and < 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().
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-i32.c: New test.
* 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.
Diffstat (limited to 'gcc/tree-ssa-phiopt.cc')
0 files changed, 0 insertions, 0 deletions