[Bug middle-end/36578] cast to long double not taken into account when result stored to a double

2009-02-25 Thread janis at gcc dot gnu dot org


--- Comment #6 from janis at gcc dot gnu dot org  2009-02-25 22:09 ---
Subject: Bug 36578

Author: janis
Date: Wed Feb 25 22:08:55 2009
New Revision: 144436

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=144436
Log:
2009-02-25  Janis Johnson  janis...@us.ibm.com

gcc/
Backport from mainline:
2008-10-29  Joseph Myers  jos...@codesourcery.com

PR middle-end/36578
* convert.c (convert_to_real): Do not optimize conversions of
binary arithmetic operations between binary and decimal
floating-point types.  Consider mode of target type in determining
decimal type for arithmetic.  Unless
flag_unsafe_math_optimizations, do not optimize binary conversions
where this may change rounding behavior.
* real.c (real_can_shorten_arithmetic): New.
* real.h (real_can_shorten_arithmetic): Declare.

gcc/testsuite/
Backport from mainline:
2008-10-29  Joseph Myers  jos...@codesourcery.com

PR middle-end/36578
* gcc.dg/dfp/convert-bfp-13.c, gcc.dg/dfp/convert-bfp-14.c,
gcc.dg/dfp/convert-dfp-fold-2.c, gcc.target/i386/pr36578-1.c,
gcc.target/i386/pr36578-2.c: New tests.

Added:
branches/gcc-4_3-branch/gcc/testsuite/gcc.dg/dfp/convert-bfp-13.c
branches/gcc-4_3-branch/gcc/testsuite/gcc.dg/dfp/convert-bfp-14.c
branches/gcc-4_3-branch/gcc/testsuite/gcc.dg/dfp/convert-dfp-fold-2.c
branches/gcc-4_3-branch/gcc/testsuite/gcc.dg/dfp/pr39034.c
branches/gcc-4_3-branch/gcc/testsuite/gcc.target/i386/pr36578-1.c
branches/gcc-4_3-branch/gcc/testsuite/gcc.target/i386/pr36578-2.c
Modified:
branches/gcc-4_3-branch/gcc/ChangeLog
branches/gcc-4_3-branch/gcc/convert.c
branches/gcc-4_3-branch/gcc/real.c
branches/gcc-4_3-branch/gcc/real.h
branches/gcc-4_3-branch/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36578



[Bug middle-end/36578] cast to long double not taken into account when result stored to a double

2008-10-29 Thread jsm28 at gcc dot gnu dot org


--- Comment #4 from jsm28 at gcc dot gnu dot org  2008-10-29 17:06 ---
Subject: Bug 36578

Author: jsm28
Date: Wed Oct 29 17:05:42 2008
New Revision: 141432

URL: http://gcc.gnu.org/viewcvs?root=gccview=revrev=141432
Log:
PR middle-end/36578
* convert.c (convert_to_real): Do not optimize conversions of
binary arithmetic operations between binary and decimal
floating-point types.  Consider mode of target type in determining
decimal type for arithmetic.  Unless
flag_unsafe_math_optimizations, do not optimize binary conversions
where this may change rounding behavior.
* real.c (real_can_shorten_arithmetic): New.
* real.h (real_can_shorten_arithmetic): Declare.

testsuite:
* gcc.dg/dfp/convert-bfp-13.c, gcc.dg/dfp/convert-bfp-14.c,
gcc.dg/dfp/convert-dfp-fold-2.c, gcc.target/i386/pr36578-1.c,
gcc.target/i386/pr36578-2.c: New tests.

Added:
trunk/gcc/testsuite/gcc.dg/dfp/convert-bfp-13.c
trunk/gcc/testsuite/gcc.dg/dfp/convert-bfp-14.c
trunk/gcc/testsuite/gcc.dg/dfp/convert-dfp-fold-2.c
trunk/gcc/testsuite/gcc.target/i386/pr36578-1.c
trunk/gcc/testsuite/gcc.target/i386/pr36578-2.c
Modified:
trunk/gcc/ChangeLog
trunk/gcc/convert.c
trunk/gcc/real.c
trunk/gcc/real.h
trunk/gcc/testsuite/ChangeLog


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36578



[Bug middle-end/36578] cast to long double not taken into account when result stored to a double

2008-10-29 Thread jsm28 at gcc dot gnu dot org


--- Comment #5 from jsm28 at gcc dot gnu dot org  2008-10-29 17:12 ---
Fixed for 4.4.


-- 

jsm28 at gcc dot gnu dot org changed:

   What|Removed |Added

 Status|NEW |RESOLVED
 Resolution||FIXED
   Target Milestone|--- |4.4.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36578



[Bug middle-end/36578] cast to long double not taken into account when result stored to a double

2008-06-21 Thread rguenth at gcc dot gnu dot org


--- Comment #2 from rguenth at gcc dot gnu dot org  2008-06-21 16:41 ---
Testcase

double foo (double x, double y)
{
  return (long double)x * (long double)y;
}

where we fold the multiplication to x * y.  This is only ok with
-funsafe-math-optimizations (like any other conversions removing
FP operations).  It is of course also ok if we for some reason
know that x * y is exactly representable in both double and
long double.

It is convert_to_real doing this optimization.


-- 

rguenth at gcc dot gnu dot org changed:

   What|Removed |Added

 CC||rguenth at gcc dot gnu dot
   ||org
 Status|UNCONFIRMED |NEW
 Ever Confirmed|0   |1
   Keywords||wrong-code
   Last reconfirmed|-00-00 00:00:00 |2008-06-21 16:41:36
   date||


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36578



[Bug middle-end/36578] cast to long double not taken into account when result stored to a double

2008-06-21 Thread joseph at codesourcery dot com


--- Comment #3 from joseph at codesourcery dot com  2008-06-21 16:58 ---
Subject: Re:  cast to long double not taken into account
 when result stored to a double

On Sat, 21 Jun 2008, rguenth at gcc dot gnu dot org wrote:

 It is convert_to_real doing this optimization.

convert_to_real is also responsible for the problematic conversions in 
bug 35202.  I didn't try to argue the double rounding issues for those 
conversions, only the errno issue, since I don't have an example for the 
double rounding affecting those function call conversions (and right now 
implementations of many of the functions will not typically be correctly 
rounding - but that could change if C1x follows the new IEEE 754 
revision's recommendation of many more correctly rounded functions).  But 
it is potentially an issue for the conversions of function calls as well 
as the plain arithmetic example of this bug.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36578



[Bug middle-end/36578] cast to long double not taken into account when result stored to a double

2008-06-19 Thread vincent at vinc17 dot org


--- Comment #1 from vincent at vinc17 dot org  2008-06-19 14:37 ---
To make things clear, perhaps I should have added:

#if __STDC__ == 1  __STDC_VERSION__ = 199901  defined(__STDC_IEC_559__)
#pragma STDC FP_CONTRACT OFF
  printf (__STDC_IEC_559__ defined:\n
  The implementation shall conform to the IEEE-754 standard.\n
  FLT_EVAL_METHOD is %d (see ISO/IEC 9899, 5.2.4.2.2#7).\n\n,
  (int) FLT_EVAL_METHOD);
#endif

which outputs:

__STDC_IEC_559__ defined:
The implementation shall conform to the IEEE-754 standard.
FLT_EVAL_METHOD is 0 (see ISO/IEC 9899, 5.2.4.2.2#7).

So, one can't even say that the value of d is correct because it is the same as
the exact result rounded to double precision. The fact that the double rounding
doesn't occur is a bug here.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=36578