diff options
author | Oleg Endo <olegendo@gcc.gnu.org> | 2012-05-29 20:55:58 +0000 |
---|---|---|
committer | Oleg Endo <olegendo@gcc.gnu.org> | 2012-05-29 20:55:58 +0000 |
commit | 2df2ce3f78cc3213b703fc87ec2cccbf1721dfdb (patch) | |
tree | 232a604a7727185b7aee464bb2b66c1fc81f3832 /gcc | |
parent | c11394f8eddda4ee9f06d66d8431ddad6ef76666 (diff) | |
download | gcc-2df2ce3f78cc3213b703fc87ec2cccbf1721dfdb.zip gcc-2df2ce3f78cc3213b703fc87ec2cccbf1721dfdb.tar.gz gcc-2df2ce3f78cc3213b703fc87ec2cccbf1721dfdb.tar.bz2 |
re PR target/51340 (SH Target: Make -mfused-madd enabled by default)
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.
From-SVN: r187988
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/config/sh/sh.c | 7 | ||||
-rw-r--r-- | gcc/doc/invoke.texi | 18 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 7 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/sh/pr51340-1.c | 13 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/sh/pr51340-2.c | 12 | ||||
-rw-r--r-- | gcc/testsuite/gcc.target/sh/pr51340-3.c | 12 |
7 files changed, 71 insertions, 6 deletions
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 <olegendo@gcc.gnu.org> + 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 <olegendo@gcc.gnu.org> + 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 <olegendo@gcc.gnu.org> + + 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 <rguenther@suse.de> 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; +} + |