This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/66512] New: PRE fails to optimize calls to pure functions in C++, ok in C
- From: "amonakov at gcc dot gnu.org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Thu, 11 Jun 2015 15:06:06 +0000
- Subject: [Bug tree-optimization/66512] New: PRE fails to optimize calls to pure functions in C++, ok in C
- Auto-submitted: auto-generated
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<p>} (0003) }
+exp_gen[3] := { }
phi_gen[3] := { }