[Bug tree-optimization/57742] memset(malloc(n),0,n) -> calloc(n,1)
rguenth at gcc dot gnu.org
gcc-bugzilla@gcc.gnu.org
Wed Oct 16 14:11:00 GMT 2013
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57742
--- Comment #12 from Richard Biener <rguenth at gcc dot gnu.org> ---
(In reply to Marc Glisse from comment #11)
> (In reply to Richard Biener from comment #9)
> > because of points-to analysis being not context sensitive.
>
> Is "context sensitivity" the thing that is missing to perform the obvious
> optimization (i=3) on the following code without adding restrict to q? If
> so, I assume I don't need to file a PR about it... (there are too many PRs
> that mention alias analysis, I can't find anything)
Yes, the fact that the return value p cannot be equal to q inside the
function is not exposable.
> int i;
> int* g(int n,int*q){
> int*p=__builtin_malloc(n);
> p[2]=3;
> *q=5;
> i=p[2];
> return p;
> }
>
> (the "easy" cases are when we don't return p (no "global" var) or when p and
> q have incompatible types (but malloc+memset seems to lose any type I could
> try to force on the pointer))
More information about the Gcc-bugs
mailing list