This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug tree-optimization/41186] New: VN doesn't look through non-aliasing by offset memcpy
- From: "rguenth at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 29 Aug 2009 12:43:39 -0000
- Subject: [Bug tree-optimization/41186] New: VN doesn't look through non-aliasing by offset memcpy
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
The C++ FE now creates memcpy for class copies to avoid copying objects in
tail-padding.
struct Foo {
Foo() {};
int i;
short f;
};
struct Bar : public Foo {
Bar() {};
short b;
};
extern "C" void abort(void);
int main()
{
Bar b1, b2;
b2.i = 0;
b1.f = 0;
b1.b = 1;
b2.f = 1;
b2.b = 2;
static_cast<Foo&>(b1) = static_cast<Foo&>(b2);
if (b1.i != 0 || b1.b != 1)
abort ();
if (b1.f != 1)
abort ();
return 0;
}
The alias-oracle does consider the memcpy to clobber b1.b and the
look-through doesn't find b1.f or b1.i either.
Note that with combining the tests like
if (b1.i != 0 || b1.b != 1 || b1.f != 1)
abort ();
fold creates a BIT_FIELD_REF covering both b and f which confuses us
even more. But I have considered this a bad habit of fold earlier.
--
Summary: VN doesn't look through non-aliasing by offset memcpy
Product: gcc
Version: 4.5.0
Status: UNCONFIRMED
Keywords: missed-optimization, alias
Severity: enhancement
Priority: P3
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: rguenth at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=41186