This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug other/16795] New: PowerPC - Divide sequences by negative power of two could be more efficient
- 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:46 -0000
- Subject: [Bug other/16795] New: PowerPC - Divide sequences by negative power of two could be more efficient
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Description:
A non-optimal code sequence is illustraded. Dividing by a negative power of two could be more efficiently done. Duplicate using gcc 3.5 and command line:
gcc -O3 -m64 -c test.c
Testcase:
int x;
void foo1() {
x /= -0x2;
}
void foo2() {
x /= -0x4;
}
Assembly:
Code generated for "foo1" looks like this:
.foo:
ld 9,.LC0@toc(2)
lwz 5,0(9)
srwi 11,5,31
add 4,5,11
srawi 3,4,1
neg 0,3
stw 0,0(9)
blr
A better alternative would be this:
.foo:
ld 9,.LC0@toc(2)
lwz 5,0(9)
srawi 0,5,1
addze 3,0
neg 0,3
stw 0,0(9)
blr
Code generated for "foo2" looks like this:
.foo:
ld 9,.LC0@toc(2)
lwz 5,0(9)
srawi 6,5,31
srwi 11,6,30
add 4,5,11
srawi 3,4,2
neg 0,3
stw 0,0(9)
blr
More optimal sequence would be:
.foo:
ld 9,.LC0@toc(2)
lwz 5,0(9)
srawi 0,5,2
addze 3,0
neg 0,3
stw 0,0(9)
blr
--
Summary: PowerPC - Divide sequences by negative power of two
could be more efficient
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=16795