GCC Bugzilla has been upgraded from version 4.4.9 to 5.0rc3. If you see any problem, please report it to bug 64968.
Bug 43201 - Missed optimization with `-flto'
Summary: Missed optimization with `-flto'
Status: RESOLVED WONTFIX
Alias: None
Product: gcc
Classification: Unclassified
Component: lto (show other bugs)
Version: 4.5.0
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: alias, lto, missed-optimization
Depends on:
Blocks:
 
Reported: 2010-02-27 21:02 UTC by Dmitry Gorbachev
Modified: 2010-02-27 21:33 UTC (History)
1 user (show)

See Also:
Host: i686-pc-linux-gnu
Target: i686-pc-linux-gnu
Build: i686-pc-linux-gnu
Known to work:
Known to fail:
Last reconfirmed:


Attachments
Code produced by lto1 (220 bytes, text/plain)
2010-02-27 21:04 UTC, Dmitry Gorbachev
Details
Code compiled without `-flto' (202 bytes, text/plain)
2010-02-27 21:05 UTC, Dmitry Gorbachev
Details
C source (104 bytes, text/plain)
2010-02-27 21:06 UTC, Dmitry Gorbachev
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dmitry Gorbachev 2010-02-27 21:02:10 UTC
 
Comment 1 Dmitry Gorbachev 2010-02-27 21:04:53 UTC
Created attachment 19978 [details]
Code produced by lto1

Compiled with `-O2 -flto'
Comment 2 Dmitry Gorbachev 2010-02-27 21:05:42 UTC
Created attachment 19979 [details]
Code compiled without `-flto'
Comment 3 Dmitry Gorbachev 2010-02-27 21:06:20 UTC
Created attachment 19980 [details]
C source
Comment 4 Richard Biener 2010-02-27 21:33:10 UTC
This is because

  p = 0;

is not detected as dead store by tree DSE as in

  p = 0;
  r = *q;
  p = (T *) t[0];

*q may load from p because with LTO TBAA rules for pointers have been
relaxed (for a reason but also in a somewhat simple manner).  With
non-LTO void * and void ** have different alias-sets, with LTO they
do not (as especially mismatching void * and void ** is a very common
error that would lead to many spurious miscompiles with LTO).

Note that we really can't optimize this testcase without using TBAA
and by design we do not.