Bug 25028 - TImode-to-floating conversions broken
Summary: TImode-to-floating conversions broken
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: other (show other bugs)
Version: 4.2.0
: P3 normal
Target Milestone: 4.2.0
Assignee: Not yet assigned to anyone
URL: http://gcc.gnu.org/ml/gcc-patches/200...
Keywords: patch
: 34473 (view as bug list)
Depends on:
Blocks:
 
Reported: 2005-11-25 01:27 UTC by Joseph S. Myers
Modified: 2010-05-22 17:20 UTC (History)
5 users (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2005-11-26 22:52:00


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Joseph S. Myers 2005-11-25 01:27:51 UTC
int printf(const char *, ...);
typedef int TItype __attribute__((mode(TI)));
TItype x = -1;
int main(void) { printf("%f %f\n", (float)x, (double)x); return 0; }

displays
0.000000 0.000000
on x86_64-unknown-linux-gnu.  The conversion functions in libgcc2.c work for converting DImode values on the presumption that SImode values can be converted exactly to DFmode and wider.  They don't work for converting TImode values to types which can't exactly represent all DImode values.

(I'd say these functions should have #if conditionals embodying their prerequisites about type precisions, to make build fail for unsupported combinations, but existing targets need fixing first.)
Comment 1 Andrew Pinski 2005-11-26 22:52:00 UTC
Confirmed.
Comment 2 Joseph S. Myers 2005-12-03 13:36:46 UTC
Patch posted <http://gcc.gnu.org/ml/gcc-patches/2005-12/msg00253.html> which fixes the problems except for on ia64-hpux, and includes a discussion of the problems on ia64-hpux and how they might be fixed.
Comment 3 Joseph S. Myers 2005-12-15 21:50:13 UTC
Subject: Bug 25028

Author: jsm28
Date: Thu Dec 15 21:50:10 2005
New Revision: 108598

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=108598
Log:
	PR other/25028
	* libgcc2.h (SF_SIZE, DF_SIZE, XF_SIZE, TF_SIZE): Define.
	* libgcc2.c (__floatdixf, __floatundixf, __floatditf,
	__floatunditf): Use #error if type sizes don't match requirements
	of implementation.
	(__floatdisf, __floatdidf): Unify.  Possibly use XFmode or TFmode
	as wider floating-point type.  Use #error if type sizes don't
	match requirements of implementation.  Avoid overflow in computing
	Wtype_MAXp1_F * Wtype_MAXp1_F.  When special casing conversion,
	shift one more bit.  Cast 1 to DWtype or UDWtype for shifting.
	(__floatundisf, __floatundidf): Likewise.
	* config/ia64/hpux.h (XF_SIZE, TF_SIZE): Define.
	* config/ia64/ia64.c (ia64_init_libfuncs): Use
	_U_Qfcnvfxt_quad_to_quad and _U_Qfcnvxf_quad_to_quad for
	TFmode-TImode conversions.
	* doc/tm.texi (SF_SIZE, DF_SIZE, XF_SIZE, TF_SIZE): Document.

testsuite:
	* gcc.dg/torture/fp-int-convert-timode.c: Only XFAIL for LP64 IA64
	HP-UX.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/ia64/hpux.h
    trunk/gcc/config/ia64/ia64.c
    trunk/gcc/doc/tm.texi
    trunk/gcc/libgcc2.c
    trunk/gcc/libgcc2.h
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/torture/fp-int-convert-timode.c

Comment 4 roger 2006-02-09 15:00:27 UTC
My recent fix for PR target/22209 adding TImode support for MIPS, just fixed this
PR's testcase for me on mips-sgi-irix6.5.  The new fix*.c and float*.c source files may be useful in resolving the remaining PR25028 issue on ia64/HPUX?
I'll investigate.
Comment 5 Jack Howarth 2006-08-24 21:44:09 UTC
The testcase presented here appears to work as expected on Darwin when gcc trunk is built with Geoff Keating's proposed patch to add TImode support to Darwin...

http://gcc.gnu.org/ml/gcc-patches/2006-08/msg00581.html

...producing the correct results of "-1.000000 -1.000000". FYI.
Comment 6 Jack Howarth 2006-08-24 22:12:01 UTC
Strangely, while the testcase first presented here...

int printf(const char *, ...);
typedef int TItype __attribute__((mode(TI)));
TItype x = -1;
int main(void) { printf("%f %f\n", (float)x, (double)x); return 0; }

works fine on Darwin with the proposed TImode support, the actual
fp-int-convert-timode.c  testcase aborts.
Comment 7 Jack Howarth 2006-08-25 01:36:30 UTC
Interestingly out of the lines in the fp-int-convert-timode testcase, the one that causes the abort is...

   TEST_I_F(TItype, UTItype, float, FLT_MANT_DIG); 

The other two lines for double and long double tests pass without complaint on Darwin ppc. The exact line in fp-int-convert.h where the aborts begin for the float type is...

  TEST_I_F_VAL (I, F, HVAL0S (P, I) + 1, P_OK (P, I));          \

Any suggestions on how to debug this further?
Comment 8 Jack Howarth 2006-08-25 03:59:09 UTC
After looking at this in detail, only six of the testcases for the single precision float conversions
in TEST_I_F(TItype, UTItype, float, FLT_MANT_DIG) fail. These are...

   TEST_I_F_VAL (I, F, HVAL0S (P, I) + 1, P_OK (P, I));          \
   TEST_I_F_VAL (I, F, HVAL1S (P, I) - 1, P_OK (P, I));          \
   TEST_I_F_VAL (I, F, -HVAL0S (P, I) - 1, P_OK (P, I));         \
   TEST_I_F_VAL (I, F, -HVAL1S (P, I) + 1, P_OK (P, I));         \
   TEST_I_F_VAL (U, F, HVAL0U (P, U) + 1, P_OK (P, U));          \
   TEST_I_F_VAL (U, F, HVAL1U (P, U) - 1, P_OK (P, U));          \

Might this in anyway give us some hints as to where we should look for the 
problem in the currently proposed TImode implementation for Darwin? This
patch is at...

http://gcc.gnu.org/ml/gcc-patches/2006-08/msg00581.html

as I mentioned earlier. On the positive side, we completely pass all of the
testcases for double and long double conversions.
Comment 9 Steve Ellcey 2006-11-07 19:14:38 UTC
Subject: Bug 25028

Author: sje
Date: Tue Nov  7 19:14:27 2006
New Revision: 118565

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118565
Log:
	PR other/25028
	* config/ia64/t-hpux (LIB1ASMFUNCS):  Filter out _fixtfdi,
	_fixunstfdi, and  _floatditf
	* gcc.dg/torture/fp-int-convert-float128-timode.c:  Do not XFAIL
	on HP-UX.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/ia64/t-hpux
    trunk/gcc/testsuite/ChangeLog
    trunk/gcc/testsuite/gcc.dg/torture/fp-int-convert-float128-timode.c

Comment 10 Steve Ellcey 2006-11-15 22:59:52 UTC
Subject: Bug 25028

Author: sje
Date: Wed Nov 15 22:59:41 2006
New Revision: 118869

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=118869
Log:
	PR other/25028
	* config/ia64/t-hpux (LIB1ASMFUNCS):  Filter out _fixtfdi,
	_fixunstfdi, and  _floatditf

Modified:
    branches/gcc-4_2-branch/gcc/ChangeLog
    branches/gcc-4_2-branch/gcc/config/ia64/t-hpux

Comment 11 Uroš Bizjak 2007-12-16 23:27:53 UTC
*** Bug 34473 has been marked as a duplicate of this bug. ***
Comment 12 Joseph S. Myers 2010-05-22 17:20:57 UTC
As far as I can tell, this (the bug originally described here)
was fixed for all targets.