public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug other/16796] New: PowerPC - Unnecessary Floating Point Register Copy
@ 2004-07-28 17:01 gcc-bugzilla at gcc dot gnu dot org
  2004-07-29  5:37 ` [Bug rtl-optimization/16796] " pinskia at gcc dot gnu dot org
                   ` (5 more replies)
  0 siblings, 6 replies; 10+ messages in thread
From: gcc-bugzilla at gcc dot gnu dot org @ 2004-07-28 17:01 UTC (permalink / raw)
  To: gcc-bugs

Description:
A non-optimal code sequence is illustraded.  A floating point register copy is unnecessary and could be eliminated.  Duplicate using gcc 3.5 and command line:

gcc -O3 -m64 -c test.c

Testcase:
static const double huge = 1.0e300;
typedef int int64_t __attribute__ ((__mode__ (__DI__)));
typedef unsigned int u_int64_t __attribute__ ((__mode__ (__DI__)));

double __floor(double x)
{
  union {
    double dbl_val;
    long int long_val;
  } temp;

  int64_t i0,j0;
  u_int64_t i;
  temp.dbl_val = x;
  i0 = temp.long_val;

  j0 = ((i0>>52)&0x7ff)-0x3ff;
  if(j0<52) {
    if(j0<0) {
      if(huge+x>0.0) {
        if(i0>=0) {i0=0;}
        else if((i0&0x7fffffffffffffff)!=0)
        { i0=0xbff0000000000000;}
      }
    } else {
      i = (0x000fffffffffffff)>>j0;
      if((i0&i)==0) return x;
      if(huge+x>0.0) {
        if(i0<0) i0 += (0x0010000000000000)>>j0;
        i0 &= (~i);
      }
    }
  } else {
    if (j0==0x400)
      return x+x;
    else
      return x;
  }
  temp.long_val = i0;
  x = temp.dbl_val;
  return x;
}

Assembly:
.__floor:
	stfd 1,-16(1)
	ld 0,-16(1)
	rldicl 9,0,12,53
	mr 11,0
	addi 9,9,-1023
	cmpdi 7,9,51
	bgt- 7,.L2
	cmpdi 7,9,0
	blt- 7,.L20
	li 0,-1
	extsw 9,9
	rldicl 0,0,0,12
	srad 10,0,9
	and. 0,10,11
	beqlr- 0
	lfd 0,.LC0@toc(2)
	lfd 13,.LC1@toc(2)
	fadd 0,1,0
	fcmpu 7,0,13
	bng- 7,.L6
	cmpdi 7,11,0
	blt- 7,.L21
.L16:
	andc 11,11,10
.L6:
	std 11,-16(1)
	lfd 0,-16(1) <-- Load directly into float reg 1 and
	fmr 1,0      <-- avoid subsequent copy.
	blr
.L2:
	cmpdi 7,9,1024
	bnelr+ 7
	fadd 1,1,1
	blr
.L20:
	lfd 0,.LC0@toc(2)
	lfd 13,.LC1@toc(2)
	fadd 0,1,0
	fcmpu 7,0,13
	bng- 7,.L6
	cmpdi 7,0,0
	blt- 7,.L22
	li 11,0
	b .L6
.L21:
	lis 0,0x10
	sldi 0,0,32
	srad 0,0,9
	add 11,11,0
	b .L16
.L22:
	rldicl. 0,11,0,1
	beq- 0,.L6
	lis 11,0xbff0
	sldi 11,11,32
	b .L6



-- 
           Summary: PowerPC - Unnecessary Floating Point Register Copy
           Product: gcc
           Version: 3.5.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P1
         Component: other
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: steinmtz at us dot ibm dot com
                CC: gcc-bugs at gcc dot gnu dot org,steinmtz at us dot ibm
                    dot com
 GCC build triplet: powerpc64-linux
  GCC host triplet: powerpc64-linux
GCC target triplet: powerpc64-linux


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


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2008-09-14  4:09 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <bug-16796-8614@http.gcc.gnu.org/bugzilla/>
2005-10-04  6:26 ` [Bug rtl-optimization/16796] PowerPC - Unnecessary Floating Point Register Copy pinskia at gcc dot gnu dot org
2005-11-02 17:16 ` pinskia at gcc dot gnu dot org
2006-06-08  6:10 ` pinskia at gcc dot gnu dot org
2008-09-14  4:09 ` pinskia at gcc dot gnu dot org
2004-07-28 17:01 [Bug other/16796] New: " gcc-bugzilla at gcc dot gnu dot org
2004-07-29  5:37 ` [Bug rtl-optimization/16796] " pinskia at gcc dot gnu dot org
2004-10-08 13:11 ` pinskia at gcc dot gnu dot org
2004-11-10 11:01 ` nathan at gcc dot gnu dot org
2004-11-10 12:28 ` nathan at gcc dot gnu dot org
2004-11-11  8:47 ` nathan at gcc dot gnu dot org
2004-11-11  8:49 ` cvs-commit at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).