This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [patch,avr] Fix PR57516 fixed-point rounding in the overflow case
- From: Denis Chertykov <chertykov at gmail dot com>
- To: Georg-Johann Lay <avr at gjlay dot de>
- Cc: gcc-patches <gcc-patches at gcc dot gnu dot org>, Eric Weddington <eric dot weddington at atmel dot com>
- Date: Fri, 19 Jul 2013 14:51:49 +0400
- Subject: Re: [patch,avr] Fix PR57516 fixed-point rounding in the overflow case
- References: <51E7C634 dot 7020707 at gjlay dot de>
2013/7/18 Georg-Johann Lay <avr@gjlay.de>:
> Currently, the fixed-point rounding does not work correctly in the overflow
> case. This is because of misreading section 2.1.7.2 of TR 18037.
>
> Rounding builtins expand to saturated addition and AND so that the instruction
> sequence is
>
> add value1
> if not overflow goto 0
> load max value
> 0:
> and value2
>
> where the correct sequence reads
>
> add value1
> if not overflow goto 0
> load max value
> goto 1
> 0:
> and value2
> 1:
>
> This change is performed by the patch. The round expander is transformed to an
> insn that uses avr_out_plus and avr_out_bitop to print most of the instructions.
>
> Okay to apply?
>
> Johann
>
> gcc/
> PR target/57516
> * config/avr/avr-fixed.md (round<mode>3_const): Turn expander to insn.
> * config/avr/avr.md (adjust_len): Add `round'.
> * config/avr/avr-protos.h (avr_out_round): New prototype.
> (avr_out_plus): Add `out_label' argument.
> * config/avr/avr.c (avr_out_plus_1): Add `out_label' argument.
> (avr_out_plus): Pass down `out_label' to avr_out_plus_1.
> Handle the case where `insn' is just a pattern.
> (avr_out_bitop): Handle the case where `insn' is just a pattern.
> (avr_out_round): New function.
> (avr_adjust_insn_length): Handle ADJUST_LEN_ROUND.
>
> libgcc/
> PR target/57516
> * config/avr/lib1funcs-fixed.S (__roundqq3, __rounduqq3)
> (__round_s2_const, __round_u2_const)
> (__round_s4_const, __round_u4_const, __round_x8):
> Saturate result if addition result cannot be represented.
>
> gcc/testsuite/
> PR target/57516
> * gcc.target/avr/torture/builtins-4-roundfx.c (test2hr, test2k):
> Adjust to corrected rounding.
>
>
Approved.
Denis.