From: olegendo Date: Tue, 29 May 2012 20:55:58 +0000 (+0000) Subject: PR target/51340 X-Git-Tag: upstream/4.9.2~12420 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=de9013acca003caf01bbbb74c18c6a2eb1a104f4;p=platform%2Fupstream%2Flinaro-gcc.git PR target/51340 * config/sh/sh.c (sh_option_override): Set TARGET_FMAC if flag_unsafe_math_optimizations is set. * doc/invoke.texi (SH Options): Add -mno-fused-madd description. Update description of -mfused-madd. PR target/51340 * gcc.target/sh/pr51340-1.c: New. * gcc.target/sh/pr51340-2.c: New. * gcc.target/sh/pr51340-3.c: New. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@187988 138bc75d-0d04-0410-961f-82ee72b054a4 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 26382f6..078ad6d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,13 @@ 2012-05-29 Oleg Endo + PR target/51340 + * config/sh/sh.c (sh_option_override): Set TARGET_FMAC if + flag_unsafe_math_optimizations is set. + * doc/invoke.texi (SH Options): Add -mno-fused-madd description. + Update description of -mfused-madd. + +2012-05-29 Oleg Endo + PR target/52941 * config/sh/predicates.md (atomic_arith_operand, atomic_logical_operand): New predicates. diff --git a/gcc/config/sh/sh.c b/gcc/config/sh/sh.c index 3c9a7e9..20e67c6 100644 --- a/gcc/config/sh/sh.c +++ b/gcc/config/sh/sh.c @@ -876,6 +876,13 @@ sh_option_override (void) align_functions = min_align; } + /* Enable fmac insn for "a * b + c" SFmode calculations when -ffast-math + is enabled and -mno-fused-madd is not specified by the user. + The fmac insn can't be enabled by default due to the implied + FMA semantics. See also PR target/29100. */ + if (global_options_set.x_TARGET_FMAC == 0 && flag_unsafe_math_optimizations) + TARGET_FMAC = 1; + if (sh_fixed_range_str) sh_fix_range (sh_fixed_range_str); diff --git a/gcc/doc/invoke.texi b/gcc/doc/invoke.texi index efab516..1102aff 100644 --- a/gcc/doc/invoke.texi +++ b/gcc/doc/invoke.texi @@ -885,8 +885,8 @@ See RS/6000 and PowerPC Options. -mdivsi3_libfunc=@var{name} -mfixed-range=@var{register-range} @gol -mindexed-addressing -mgettrcost=@var{number} -mpt-fixed @gol -maccumulate-outgoing-args -minvalid-symbols -msoft-atomic -mhard-atomic @gol --mbranch-cost=@var{num} -mcbranchdi -mcmpeqdi -mfused-madd -mpretend-cmove @gol --menable-tas} +-mbranch-cost=@var{num} -mcbranchdi -mcmpeqdi -mfused-madd -mno-fused-madd @gol +-mpretend-cmove -menable-tas} @emph{Solaris 2 Options} @gccoptlist{-mimpure-text -mno-impure-text @gol @@ -18250,11 +18250,17 @@ Emit the @code{cmpeqdi_t} instruction pattern even when @option{-mcbranchdi} is in effect. @item -mfused-madd +@itemx -mno-fused-madd @opindex mfused-madd -Allow the usage of the @code{fmac} instruction (floating-point -multiply-accumulate) if the processor type supports it. Enabling this -option might generate code that produces different numeric floating-point -results compared to strict IEEE 754 arithmetic. +@opindex mno-fused-madd +If the processor type supports it, setting @code{-mfused-madd} will allow the +usage of the @code{fmac} instruction (floating-point multiply-accumulate) for +regular calculations. Enabling this option might generate faster code but also +produce different numeric floating-point results compared to strict IEEE 754 +arithmetic. @code{-mfused-madd} is enabled by default by option +@option{-funsafe-math-optimizations}. Setting @code{-mno-fused-madd} will +disallow the usage of the @code{fmac} instruction for regular calculations +even if @option{-funsafe-math-optimizations} is in effect. @item -mpretend-cmove @opindex mpretend-cmove diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 56bb5ab..ea8b09d 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2012-05-29 Oleg Endo + + PR target/51340 + * gcc.target/sh/pr51340-1.c: New. + * gcc.target/sh/pr51340-2.c: New. + * gcc.target/sh/pr51340-3.c: New. + 2012-05-29 Richard Guenther PR tree-optimization/53516 diff --git a/gcc/testsuite/gcc.target/sh/pr51340-1.c b/gcc/testsuite/gcc.target/sh/pr51340-1.c new file mode 100644 index 0000000..337d502 --- /dev/null +++ b/gcc/testsuite/gcc.target/sh/pr51340-1.c @@ -0,0 +1,13 @@ +/* Check that the fmac insn is generated when -funsafe-math-optimizations + is specified. */ +/* { dg-do compile { target "sh*-*-*" } } */ +/* { dg-options "-O1 -funsafe-math-optimizations" } */ +/* { dg-skip-if "" { "sh*-*-*" } { "-m1" "-m2" "-m4al" "*nofpu" "-m4-340*" "-m4-400*" "-m4-500*" "-m5*" } { "" } } */ +/* { dg-final { scan-assembler "fmac" } } */ + +float +test_func (float a, float b, float c, float d, float e, float f) +{ + return a * b + c * d + e * f; +} + diff --git a/gcc/testsuite/gcc.target/sh/pr51340-2.c b/gcc/testsuite/gcc.target/sh/pr51340-2.c new file mode 100644 index 0000000..ef9622e --- /dev/null +++ b/gcc/testsuite/gcc.target/sh/pr51340-2.c @@ -0,0 +1,12 @@ +/* Check that the fmac insn is not generated when -mno-fused-madd is specified. */ +/* { dg-do compile { target "sh*-*-*" } } */ +/* { dg-options "-O1 -funsafe-math-optimizations -mno-fused-madd" } */ +/* { dg-skip-if "" { "sh*-*-*" } { "-m1" "-m2" "-m4al" "*nofpu" "-m4-340*" "-m4-400*" "-m4-500*" "-m5*" } { "" } } */ +/* { dg-final { scan-assembler-not "fmac" } } */ + +float +test_func (float a, float b, float c, float d, float e, float f) +{ + return a * b + c * d + e * f; +} + diff --git a/gcc/testsuite/gcc.target/sh/pr51340-3.c b/gcc/testsuite/gcc.target/sh/pr51340-3.c new file mode 100644 index 0000000..d641ae3 --- /dev/null +++ b/gcc/testsuite/gcc.target/sh/pr51340-3.c @@ -0,0 +1,12 @@ +/* Check that the fmac insn is generated when -mfused-madd is specified. */ +/* { dg-do compile { target "sh*-*-*" } } */ +/* { dg-options "-O1 -mfused-madd" } */ +/* { dg-skip-if "" { "sh*-*-*" } { "-m1" "-m2" "-m4al" "*nofpu" "-m4-340*" "-m4-400*" "-m4-500*" "-m5*" } { "" } } */ +/* { dg-final { scan-assembler "fmac" } } */ + +float +test_func (float a, float b, float c, float d, float e, float f) +{ + return a * b + c * d + e * f; +} +