From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 101356 invoked by alias); 11 Jun 2015 15:06:10 -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 101324 invoked by uid 48); 11 Jun 2015 15:06:06 -0000 From: "amonakov at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug tree-optimization/66512] New: PRE fails to optimize calls to pure functions in C++, ok in C Date: Thu, 11 Jun 2015 15:06: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: unknown X-Bugzilla-Keywords: X-Bugzilla-Severity: normal X-Bugzilla-Who: amonakov at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: 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 bug_severity priority component assigned_to reporter target_milestone 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: 2015-06/txt/msg01111.txt.bz2 https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66512 Bug ID: 66512 Summary: PRE fails to optimize calls to pure functions in C++, ok in C Product: gcc Version: unknown Status: UNCONFIRMED Severity: normal Priority: P3 Component: tree-optimization Assignee: unassigned at gcc dot gnu.org Reporter: amonakov at gcc dot gnu.org Target Milestone: --- The following testcase: int p(void) __attribute__((const)); void g(int); void f() { for (;;) g(p()); } is optimized when compiled as C: f: pushq %rbx call p movl %eax, %ebx .L2: movl %ebx, %edi call g jmp .L2 and not optimized when compiled as C++: _Z1fv: subq $8, %rsp .L2: call _Z1pv movl %eax, %edi call _Z1gi jmp .L2 For C the motion is performed by the PRE pass; tree dumps for PRE diverge after: @@ -95,76 +95,52 @@ Value numbering .MEM_4 stmt = g (_3); Setting value number of .MEM_4 to .MEM_4 Processing SCC needed 3 iterations Value numbers: [...] avail_out[2] := { } -exp_gen[3] := { {call_expr

} (0003) } +exp_gen[3] := { } phi_gen[3] := { }