Bug 24102

Summary: floatdisf2_internal2 broken
Product: gcc Reporter: Mikael Vidstedt <mikael.vidstedt>
Component: targetAssignee: Alan Modra <amodra>
Status: RESOLVED FIXED    
Severity: normal CC: gcc-bugs
Priority: P2 Keywords: wrong-code
Version: 3.4.3   
Target Milestone: 3.4.5   
Host: Target: powerpc64-*-*
Build: Known to work: 3.4.3 4.1.0 4.0.3 3.4.5
Known to fail: 4.0.0 3.4.4 Last reconfirmed: 2005-09-28 15:54:13

Description Mikael Vidstedt 2005-09-28 13:32:28 UTC
The floatdisf2_internal2 is broken since 2004-11-26, which will result in broken
rounding for float casts.

   long long l = (((1L << 24) + 1) << 29) + 1;
   float f = (float)l;

will eg. lead to
f=9007199254740992.000000
instead of
f=9007200328482816.000000

If I'm not mistaken, rs6000.md:5239 should read (const_int 2) instead of
(const_int 3).
Comment 1 Mikael Vidstedt 2005-09-28 13:34:45 UTC
This is on AIX/PowerPC. If there is anything else you need to know, please just ask.
Comment 2 Andrew Pinski 2005-09-28 13:38:42 UTC
Caused by:

        PR rtl-optimization/16356
        * config/rs6000/rs6000.md (floatdisf2_internal2): Rewrite with
        separate output register and one less jump.  Enable for powerpc64.
        (floatdisf2): Adjust for above.
Comment 3 Alan Modra 2005-09-28 15:54:12 UTC
Uhh, yes, it's a typo.  The (const_int 3) in floatdisf2_internal2 should indeed
be (const_int 2).
Comment 4 Alan Modra 2005-09-28 16:01:20 UTC
Bootstrapping the obvious fix.
Comment 5 GCC Commits 2005-09-29 00:21:23 UTC
Subject: Bug 24102

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	amodra@gcc.gnu.org	2005-09-29 00:16:16

Modified files:
	gcc            : ChangeLog 
	gcc/config/rs6000: rs6000.md 

Log message:
	PR target/24102
	* config/rs6000/rs6000.md (floatdisf2_internal2): Correct range
	check for numbers that need no bit twiddle.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.10042&r2=2.10043
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/rs6000/rs6000.md.diff?cvsroot=gcc&r1=1.411&r2=1.412

Comment 6 Wolfgang Bangerth 2005-09-29 00:25:50 UTC
How about the other branches? 
W. 
Comment 7 Andrew Pinski 2005-09-29 00:51:13 UTC
(In reply to comment #6)
> How about the other branches? 
4.0 is frozen right now and you really don't want a 3.4.5 (which sounds like will be released before 
4.0.3) to have a fix before 4.0.x has it.
Comment 8 GCC Commits 2005-09-29 04:43:52 UTC
Subject: Bug 24102

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	amodra@gcc.gnu.org	2005-09-29 04:43:44

Modified files:
	gcc            : ChangeLog 
	gcc/config/rs6000: rs6000.md 

Log message:
	PR target/24102
	* config/rs6000/rs6000.md (floatdisf2_internal2): Correct range
	check for numbers that need no bit twiddle.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=2.7592.2.436&r2=2.7592.2.437
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/rs6000/rs6000.md.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.350.2.5&r2=1.350.2.6

Comment 9 GCC Commits 2005-09-29 04:49:01 UTC
Subject: Bug 24102

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-branch
Changes by:	amodra@gcc.gnu.org	2005-09-29 04:48:45

Modified files:
	gcc            : ChangeLog 
	gcc/config/rs6000: rs6000.md 

Log message:
	PR target/24102
	* config/rs6000/rs6000.md (floatdisf2_internal2): Correct range
	check for numbers that need no bit twiddle.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=2.2326.2.917&r2=2.2326.2.918
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/rs6000/rs6000.md.diff?cvsroot=gcc&only_with_tag=gcc-3_4-branch&r1=1.284.4.19&r2=1.284.4.20

Comment 10 Alan Modra 2005-09-29 04:51:47 UTC
Fixed all active branches