This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/68529] New: scev failed for while(i--)
- From: "majun4950646 at 163 dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Wed, 25 Nov 2015 03:02:24 +0000
- Subject: [Bug tree-optimization/68529] New: scev failed for while(i--)
- Auto-submitted: auto-generated
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=68529
Bug ID: 68529
Summary: scev failed for while(i--)
Product: gcc
Version: 5.2.1
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
Assignee: unassigned at gcc dot gnu.org
Reporter: majun4950646 at 163 dot com
Target Milestone: ---
loop distribution failed to generate memset library call for the following
example:
#include <stdio.h>
#include <stdlib.h>
int main(){
char c[10000]={};
unsigned int nchar=9999;
while(nchar--!=0)
{
c[nchar]='A';
}
printf("%s\n",c);
return 0;
}
Compiled with
gcc -O3 -march=core2 -fdump-tree-ldist-details t.c -o t
From the ldist dump:
...
Creating dr for c[nchar_24]
analyze_innermost: failed: evolution of offset is not affine.
base_address:
offset from base address:
constant offset from base address:
step:
aligned to:
base_object: c
Access function 0: {9998, +, 4294967295}_1
...
and it failed to transform the while loop to memset
=====
However, it successed by change while(nchar--!=0) to for(;nchar !=0;nchar--):
#include <stdio.h>
#include <stdlib.h>
int main(){
char c[10000]={};
unsigned int nchar=9999;
for(;nchar!=0;nchar--)
{
c[nchar]='A';
}
printf("%s\n",c);
return 0;
}
...
Creating dr for c[nchar_21]
analyze_innermost: success.
base_address: &c
offset from base address: 0
constant offset from base address: 9999
step: -1
aligned to: 128
base_object: c
Access function 0: {9999, +, 4294967295}_1
...
and generate memset library call stmt:
__builtin_memset (&MEM[(void *)&c + 1B], 65, 9999);
I also testd in gcc4.8.4 and trunk, both failed.
--Jun