From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 24143 invoked by alias); 14 Oct 2013 11:48:26 -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 24104 invoked by uid 48); 14 Oct 2013 11:48:23 -0000 From: "glisse 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: Mon, 14 Oct 2013 11:48: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: glisse 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/msg00796.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57742 --- Comment #6 from Marc Glisse --- (In reply to Richard Biener from comment #5) > We have walk_aliased_vdefs for this. Basically the first callback > you receive has to be the malloc, otherwise there is an aliasing > stmt inbetween. Cool! Last time I looked into a similar optimization, I needed to look also at the memory reads, not just the writes, so it was significantly more complicated. walk_aliased_vdefs looks perfect here, both for malloc+memset where there is nothing to read before the memset, and for calloc+memset where reading before or after the memset returns the same :-)