From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 455 invoked by alias); 21 Oct 2013 04:12:08 -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 377 invoked by uid 48); 21 Oct 2013 04:12:02 -0000 From: "glisse at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/58817] New: optimize alloca with constant size Date: Mon, 21 Oct 2013 04:12:00 -0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: tree-optimization X-Bugzilla-Version: 4.9.0 X-Bugzilla-Keywords: missed-optimization X-Bugzilla-Severity: enhancement X-Bugzilla-Who: glisse at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED 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: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter Message-ID: 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/msg01432.txt.bz2 http://gcc.gnu.org/bugzilla/show_bug.cgi?id=58817 Bug ID: 58817 Summary: optimize alloca with constant size Product: gcc Version: 4.9.0 Status: UNCONFIRMED Keywords: missed-optimization Severity: enhancement Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: glisse at gcc dot gnu.org Hello, I thought gcc already had this optimization but apparently not. We don't produce the same code with alloca and with arrays: void f(int*); void g(){ #if 1 const int n=4; int a[n]; #elif 1 int a[4]; #else int*a=__builtin_alloca(16); #endif f(a); } possibly because arrays give alloca_with_align, not alloca. There may be reasons why the transformation would be illegal though, I am not sure.