Message ID | CAK=A3=2PQh5RiuDWn9yGv-jxkC5G-s2JRSQTF0PEmaQSpsnyZg@mail.gmail.com |
---|---|
State | New |
Headers | show |
On Tue, 3 Sep 2013, Cong Hou wrote: > + CASE_MATHFN (SQRT) > + /* sqrtl(double) cannot be safely converted to sqrt(double). */ > + if (fcode == BUILT_IN_SQRTL && > + (TYPE_MODE (type) == TYPE_MODE (double_type_node)) && > + !flag_unsafe_math_optimizations) > + break; Please reread my previous messages on this subject and try again, with regard to both the patch itself and the accompanying analysis.
From Joseph: "The conversion is not safe for sqrt if the two types are double and long double and long double is x86 extended, for example." This is not reflected in the patch. David On Tue, Sep 3, 2013 at 2:27 PM, Joseph S. Myers <joseph@codesourcery.com> wrote: > On Tue, 3 Sep 2013, Cong Hou wrote: > >> + CASE_MATHFN (SQRT) >> + /* sqrtl(double) cannot be safely converted to sqrt(double). */ >> + if (fcode == BUILT_IN_SQRTL && >> + (TYPE_MODE (type) == TYPE_MODE (double_type_node)) && >> + !flag_unsafe_math_optimizations) >> + break; > > Please reread my previous messages on this subject and try again, with > regard to both the patch itself and the accompanying analysis. > > -- > Joseph S. Myers > joseph@codesourcery.com
On Tue, 3 Sep 2013, Xinliang David Li wrote: > >From Joseph: > > "The > conversion is not safe for sqrt if the two types are double and long > double and long double is x86 extended, for example." > > This is not reflected in the patch. No, the problem is that it tries to reflect it but hardcodes the specific example I gave, rather than following the logic I explained regarding the precisions of the types involved, which depend on the target. And since I only gave a simplified analysis, for two types when this function deals with cases involving three types, the patch submission needs to include its own analysis for the full generality of three types to justify the logic used (as inequalities involving the three precisions). (I suspect it reduces to the case of two types so you don't need to go into the details of reasoning about floating point to produce the more general analysis. But in any case, it's for the patch submitter to give the full explanation.)
Could you please tell me how to check the precision of long double in GCC on different platforms? Thank you! Cong On Tue, Sep 3, 2013 at 2:43 PM, Joseph S. Myers <joseph@codesourcery.com> wrote: > On Tue, 3 Sep 2013, Xinliang David Li wrote: > >> >From Joseph: >> >> "The >> conversion is not safe for sqrt if the two types are double and long >> double and long double is x86 extended, for example." >> >> This is not reflected in the patch. > > No, the problem is that it tries to reflect it but hardcodes the specific > example I gave, rather than following the logic I explained regarding the > precisions of the types involved, which depend on the target. And since I > only gave a simplified analysis, for two types when this function deals > with cases involving three types, the patch submission needs to include > its own analysis for the full generality of three types to justify the > logic used (as inequalities involving the three precisions). (I suspect > it reduces to the case of two types so you don't need to go into the > details of reasoning about floating point to produce the more general > analysis. But in any case, it's for the patch submitter to give the full > explanation.) > > -- > Joseph S. Myers > joseph@codesourcery.com
On Tue, 3 Sep 2013, Cong Hou wrote: > Could you please tell me how to check the precision of long double in > GCC on different platforms? REAL_MODE_FORMAT (TYPE_MODE (long_double_type_node))->p (but you should be referring to the relevant types - "type", the type being converted to, "itype", the type of the function being called in the source code, "TREE_TYPE (arg0)", the type of the argument after extensions have been removed, and "newtype", computed from those - so you should have expressions like the above with two or more of those four types, but not with long_double_type_node directly). The patch submission will need to include a proper analysis to justify to the reader why the particular inequality with particular types from those four is correct in all cases where the relevant code may be executed.
On 4 September 2013 00:17:00 Cong Hou <congh@google.com> wrote: > Could you please tell me how to check the precision of long double in > GCC on different platforms? I did not follow your discussion but.. http://uclibc.org/~aldot/precision_check.f Or something along those lines in your favourite language. HTH.. > Thank you! > > > Cong Sent with AquaMail for Android http://www.aqua-mail.com
=================================================================== --- gcc/convert.c (revision 201891) +++ gcc/convert.c (working copy) @@ -135,16 +135,24 @@ convert_to_real (tree type, tree expr) CASE_MATHFN (COS) CASE_MATHFN (ERF) CASE_MATHFN (ERFC) - CASE_MATHFN (FABS) CASE_MATHFN (LOG) CASE_MATHFN (LOG10) CASE_MATHFN (LOG2) CASE_MATHFN (LOG1P) - CASE_MATHFN (LOGB) CASE_MATHFN (SIN) - CASE_MATHFN (SQRT) CASE_MATHFN (TAN) CASE_MATHFN (TANH) + /* The above functions are not safe to do this conversion. */ + if (!flag_unsafe_math_optimizations) + break; + CASE_MATHFN (SQRT) + /* sqrtl(double) cannot be safely converted to sqrt(double). */ + if (fcode == BUILT_IN_SQRTL && + (TYPE_MODE (type) == TYPE_MODE (double_type_node)) && + !flag_unsafe_math_optimizations) + break; + CASE_MATHFN (FABS) + CASE_MATHFN (LOGB) #undef CASE_MATHFN { tree arg0 = strip_float_extensions (CALL_EXPR_ARG (expr, 0)); Index: gcc/testsuite/gcc.c-torture/execute/20030125-1.c =================================================================== --- gcc/testsuite/gcc.c-torture/execute/20030125-1.c (revision 201891) +++ gcc/testsuite/gcc.c-torture/execute/20030125-1.c (working copy) @@ -44,11 +44,11 @@ __attribute__ ((noinline)) double sin(double a) { - abort (); + return a; } __attribute__ ((noinline)) float sinf(float a) { - return a; + abort (); }