This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/20231] New: missed optimization of loop IV modulus
- From: "astrange at ithinksw dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 27 Feb 2005 06:53:41 -0000
- Subject: [Bug tree-optimization/20231] New: missed optimization of loop IV modulus
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
[zebes:~] astrange% /usr/local/bin/gcc -v
Using built-in specs.
Target: powerpc-apple-darwin7.7.0
Configured with: ../configure --enable-threads=posix --with-threads=posix
Thread model: posix
gcc version 4.1.0 20050226 (experimental)
Command line: /usr/local/bin/gcc -O3 -mcpu=7400 -mtune=7400 -fdump-tree-optimized -c
mod_loop.c
Code:
void mod_loop(unsigned char *array, int len, unsigned char repeat)
{
unsigned char i;
for (i = 0; i < len; i++) array[i] = i%repeat;
}
void mod_loop2(unsigned char *array, int len, unsigned char repeat)
{
unsigned char i,i2=0;
for (i = 0; i < len; i++) {array[i] = i2++; if (i2 == repeat) i2 = 0;}
}
Although the two functions are equivalent and mod_loop2 is better (avoiding an expensive divide), GCC
doesn't transform the first into the second.
--
Summary: missed optimization of loop IV modulus
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: enhancement
Priority: P2
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: astrange at ithinksw dot com
CC: gcc-bugs at gcc dot gnu dot org
GCC build triplet: powerpc-apple-darwin7.7.0
GCC host triplet: powerpc-apple-darwin7.7.0
GCC target triplet: powerpc-apple-darwin7.7.0
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=20231