This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug other/16796] New: PowerPC - Unnecessary Floating Point Register Copy
- From: "gcc-bugzilla at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 28 Jul 2004 17:00:49 -0000
- Subject: [Bug other/16796] New: PowerPC - Unnecessary Floating Point Register Copy
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
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