Georg-Johann Lay <a...@gjlay.de> writes: > There are occasions where knowledge about nonzero bits makes some > optimizations possible. For example, > > Rd |= Rn << Off > > can be implemented as > > SBRC Rn, 0 > ORI Rd, 1 << Off > > when Rn in { 0, 1 }, i.e. nonzero_bits (Rn) == 1. This patch adds some > patterns that exploit nonzero_bits() in some combiner patterns. > As insn conditions are not supposed to contain nonzero_bits(), the patch > splits such insns right after pass insn combine. > > The idea to split the patterns right after combine is from Jeff. > > The patch passes without new regressions. Ok for trunk?
Ok. Please apply. Denis > > Johann > > -- > > > AVR: target/119421 Better optimize some bit operations. > > There are occasions where knowledge about nonzero bits makes some > optimizations possible. For example, > > Rd |= Rn << Off > > can be implemented as > > SBRC Rn, 0 > ORI Rd, 1 << Off > > when Rn in { 0, 1 }, i.e. nonzero_bits (Rn) == 1. This patch adds some > patterns that exploit nonzero_bits() in some combiner patterns. > As insn conditions are not supposed to contain nonzero_bits(), the patch > splits such insns right after pass insn combine. > > PR target/119421 > gcc/ > * config/avr/avr.opt (-muse-nonzero-bits): New option. > * config/avr/avr-protos.h (avr_nonzero_bits_lsr_operands_p): New. > (make_avr_pass_split_nzb): New. > * config/avr/avr.cc (avr_nonzero_bits_lsr_operands_p): New function. > (avr_rtx_costs_1): Return costs for the new insns. > * config/avr/avr.md (nzb): New insn attribute. > (*nzb=1.<code>...): New insns to better support some bit > operations for <code> in AND, IOR, XOR. > * common/config/avr/avr-common.cc (avr_option_optimization_table): > Enable -muse-nonzero-bits for -O2 and higher. > * avr-passes.def (avr_pass_split_nzb): Insert pass atfer combine. > * avr-passes.cc (avr_pass_data_split_nzb). New pass data. > (avr_pass_split_nzb): New pass. > (make_avr_pass_split_nzb): New function. > * doc/invoke.texi (AVR Options): Document -muse-nonzero-bits. > gcc/testsuite/ > * gcc.target/avr/torture/pr119421-sreg.c: New test.