3 msgLoop optimizations cheatsheet
1 msgsummary of the loop-optimizations BOF
2 msgiit bombay workshop link
1 msgICE: in explow.c:326 while compiling libgfortan
5 msgRe: Difficulties compiling under Irix...
5 msgInstalling gcc-3.2
1 msgstd::string::operator==/!= optimization
14 msgOverload resolution compilation error
3 msgTemplates + Inheritance problem
4 msggcc for Intel 8086 family

g++ 4.3, troubles with C++ indexing idioms
\ tbp (19 Jul 2007)
. \ Richard Guenther (19 Jul 2007)
. . \ tbp (19 Jul 2007)
. . . \ Joel Dice (19 Jul 2007)
. . . \ Richard Guenther (19 Jul 2007)
. . . . \ tbp (19 Jul 2007)
. . . . \ tbp (21 Jul 2007)
. . . . . \ Richard Guenther (24 Jul 2007)
. . . . . . \ tbp (25 Jul 2007)
. . . . . . \ Paolo Bonzini (25 Jul 2007)
. . . . . . . \ Richard Guenther (25 Jul 2007)
. \ Dave Korn (19 Jul 2007)
. . \ tbp (19 Jul 2007)
. . . \ Dave Korn (19 Jul 2007)

3 msgproblem about generating data section in g++ 4.2
1 msgFortran benchmark for vectorizer
1 msgauto increment in simple mac loop is not created.
3 msgFRE - SCCVN problem with initialized global var...
2 msgError referencing symbols in gdb when compiled ...
3 msg-dv -fdump-rtl-all question
2 msgExecute test fails in gcc testsuite
1 msg4.2 branch frozen for release
1 msgYou've received a greeting ecard from a Family ...
Subject:g++ 4.3, troubles with C++ indexing idioms
Group:Gcc
From:tbp
Date:19 Jul 2007


I have that usual heavy duty 3 fp components class that needs to be
reasonably efficient and takes this form for g++
struct vec_t {
float x,y,z;
const float &operator()(const uint_t i) const { return *(&x + i); }
float &operator()(const uint_t i) { return *(&x + i); } // <-- guilty
[snip ctors, operators & related cruft]
};

I use this notation because g++ does silly things with straight arrays
(and C++ gets in the way), doesn't like
union vec_t {
struct { float x,y,z; };
float f[3];
const float &operator()(const uint_t i) const { return m[i]; }
float &operator()(const uint_t i) { return m[i]; }
};
much either, and seems to enjoy the first form (+ ctors with
initializer lists) much. So far, so good.

Alas, somewhere between gcc-4.3-20070608 (ok) and gcc-4.3-20070707
(not ok ever since), the non const indexing started to trigger bogus
codegen with some skipped stores on x86-64, but of course only in
convoluted situations. So, i can't produce a simple testcase. I can
kludge around either by:
. marking it __attribute__((noinline))
. turning it into a "set" operation doing a "std::memcpy(&x + i, &f,
sizeof(float))"
. annoying the optimizer with the entertaining
union vec_t {
struct { float x,y,z; };
float f[3];
const float &operator()(const uint_t i) const { return *(&x + i); }
float &operator()(const uint_t i) { return *(&x + i); }
};

At this point i'd need some guidance from compiler developers because
the compiler itself provides none (no warning whatsoever in any of
those variations) and what i thought was acceptable apparently isn't
anymore.
What kind of idiom am i supposed to write such thing in to get back
efficient and correct code?


© 2004-2008 readlist.com