From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21571 invoked by alias); 16 Oct 2013 14:11:49 -0000 Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-bugs-owner@gcc.gnu.org Received: (qmail 21506 invoked by uid 48); 16 Oct 2013 14:11:44 -0000 From: "rguenth at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/57742] memset(malloc(n),0,n) -> calloc(n,1) Date: Wed, 16 Oct 2013 14:11:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: changed X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: X-Bugzilla-Severity: enhancement X-Bugzilla-Who: rguenth at gcc dot gnu.org X-Bugzilla-Status: NEW X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: Message-ID: In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 X-SW-Source: 2013-10/txt/msg01099.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57742 --- Comment #12 from Richard Biener --- (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))