Bug 47896 - wrong code with -O -fno-early-inlining -fipa-pta -fno-tree-dominator-opts -fno-tree-forwprop
Summary: wrong code with -O -fno-early-inlining -fipa-pta -fno-tree-dominator-opts -fn...
Status: ASSIGNED
Alias: None
Product: gcc
Classification: Unclassified
Component: tree-optimization (show other bugs)
Version: 4.6.0
: P3 normal
Target Milestone: ---
Assignee: Richard Biener
URL:
Keywords: alias, wrong-code
Depends on:
Blocks: 48620
  Show dependency treegraph
 
Reported: 2011-02-25 19:09 UTC by Zdenek Sojka
Modified: 2011-04-15 12:52 UTC (History)
0 users

See Also:
Host: x86_64-pc-linux-gnu
Target: x86_64-pc-linux-gnu
Build:
Known to work:
Known to fail: 4.6.0
Last reconfirmed: 2011-02-27 15:01:42


Attachments
auto-reduced testcase (1.30 KB, text/plain)
2011-02-25 19:09 UTC, Zdenek Sojka
Details
reduced testcase (247 bytes, text/plain)
2011-02-26 23:16 UTC, Zdenek Sojka
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Zdenek Sojka 2011-02-25 19:09:03 UTC
Created attachment 23470 [details]
auto-reduced testcase

Output:
$ g++ -O -fno-early-inlining -fipa-pta -fno-tree-dominator-opts -fno-tree-forwprop testcase.C
$ ./a.out 
Aborted

Testcase was reduced from g++.dg/torture/pr37922.C, which fails with:
$ g++ -O -fno-early-inlining -fipa-pta -fschedule-insns2 -fno-tree-dominator-opts -fno-tree-forwprop -funroll-loops pr37922.ii
$ ./a.out 
Aborted

Tested revisions:
r170489 - fail
Comment 1 Zdenek Sojka 2011-02-26 23:16:32 UTC
Created attachment 23481 [details]
reduced testcase

$ g++ -O -fno-early-inlining -fipa-pta -fno-tree-dominator-opts -fno-tree-forwprop pr47896.C             
$ ./a.out 
Aborted

At the assembly level, the problematic line seems to be:
	mov	DWORD PTR [rsp+32], 9	# i9,
which directly stores the constant 9, instead of the updated value 8.
It doesn't seem to crash when compiled as C code.
Comment 2 Richard Biener 2011-02-27 15:01:42 UTC
Mine.
Comment 3 Richard Biener 2011-03-01 12:50:35 UTC
This is a failure to handle return-slot-optimization in IPA-PTA properly.  For

  D.2098 = foo (); [return slot optimization]

we have to make foos return function part point to D.2098.  That requires
some re-org, making the function result varinfo always a pointer,
making sure to use *result for result-decl uses (if not DECL_BY_REFERENCE).

I have a patch, but as this bug only affects IPA-PTA I'm defering it to 4.7
as the patch also touches non-IPA parts.