This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug other/17100] New: Missed opportunity for value range optimization
- 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: 19 Aug 2004 14:59:13 -0000
- Subject: [Bug other/17100] New: Missed opportunity for value range optimization
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
Description:
A non-optimal code sequence is illustraded. Duplicate using gcc 3.5 and
command line:
gcc -O3 -m64 -c test.c
Testcase:
int x;
int a[10];
void bar () {
printf("bar\n");
}
void foo ()
{
int i;
int j;
j = x;
for (i = 0; i < 10; i++)
{
j += a[i];
/* This block is successfully removed. GCC figures
out that 15 is out of the range of i (0-9) and
removes the block */
if (i == 15) bar ();
/* This block is not removed, but could be */
if (i == -5) bar ();
}
}
Assembly:
.foo:
mflr 0
std 31,-8(1)
li 31,0
std 0,16(1)
stdu 1,-128(1)
.L12:
addi 0,31,1
extsw 31,0
cmpwi 7,31,9
cmpwi 6,31,-5
bgt- 7,.L14
.L4:
bne+ 6,.L12
ld 3,.LC2@toc(2)
bl .puts
nop
addi 0,31,1
extsw 31,0
cmpwi 7,31,9
cmpwi 6,31,-5
ble+ 7,.L4
.L14:
addi 1,1,128
ld 0,16(1)
ld 31,-8(1)
mtlr 0
blr
--
Summary: Missed opportunity for value range optimization
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=17100