public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/32572] New: Small C++ function fails to inline with large negative badness
@ 2007-07-01 18:10 astrange at ithinksw dot com
2007-07-02 6:18 ` [Bug tree-optimization/32572] " astrange at ithinksw dot com
` (2 more replies)
0 siblings, 3 replies; 4+ messages in thread
From: astrange at ithinksw dot com @ 2007-07-01 18:10 UTC (permalink / raw)
To: gcc-bugs
The code below doesn't get image::set inlined into set_test at -O3, though it's
trivial.
Is it an integer overflow problem?
> /usr/local/gcc43/bin/g++ -v
Using built-in specs.
Target: i386-apple-darwin8.10.1
Configured with: ../gcc/configure --prefix=/usr/local/gcc43 --disable-multilib
--with-arch=pentium-m --with-tune=nocona --enable-target-optspace
--disable-bootstrap --with-gmp=/sw --with-system-zlib
--enable-languages=c,c++,objc,obj-c++
Thread model: posix
gcc version 4.3.0 20070701 (experimental)
> /usr/local/gcc43/bin/g++ -O3 -c -fdump-ipa-all -fdump-tree-final_cleanup rt-inline-overflow.cpp
>From the .inline dump:
Deciding on inlining. Starting with 39 insns.
Inlining always_inline functions:
Deciding on smaller functions:
Considering inline candidate void image::set(size_t, size_t, f_pixel, f_real).
Considering void image::set(size_t, size_t, f_pixel, f_real) with 15 insns
to be inlined into void set_test(image*, int, int, f_pixel&, double)
Estimated growth after inlined into all callees is -21 insns.
Estimated badness is -2147483642, frequency 1.00.
Not inlining into void set_test(image*, int, int, f_pixel&, double):function
not considered for inlining.
Deciding on functions called once:
Inlined 3 calls, eliminated 2 functions, 39 insns turned to 39 insns.
typedef unsigned int size_t;
typedef float f_real;
template <typename T> struct triple
{
union {
T val[3];
struct {T x,y,z;};
struct {T r,g,b;};
};
T pad;
triple(const T v[3]) {for (int i = 0; i < 3; i++) val[i] = v[i];}
triple(T a_, T b_=0., T c_=0.) {x = a_; y = b_; z = c_;}
triple() {}
triple(const triple<T> &t) {x=t.x;y=t.y;z=t.z;}
triple(const triple<T> *t) {x=t->x;y=t->y;z=t->z;}
triple<T> operator=(const triple<T> &t) {x=t.x;y=t.y;z=t.z; return *this;}
} __attribute__((aligned));
typedef triple<f_real> f_pixel;
struct image
{
f_pixel *buf;
f_real *depth_buf;
f_pixel minv, maxv;
size_t w, h;
image(size_t w, size_t h);
~image();
void write_to_bmp(const char *path);
inline void set(size_t x, size_t y, const f_pixel p, f_real depth) {
buf[y*w + x] = p;
depth_buf[y*w + x] = depth;
}
};
void set_test(image *target, int x, int y, f_pixel &c, double dist)
{
target->set(x,y,c,dist);
}
--
Summary: Small C++ function fails to inline with large negative
badness
Product: gcc
Version: 4.3.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: tree-optimization
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: astrange at ithinksw dot com
GCC build triplet: i386-apple-darwin8.10.1
GCC host triplet: i386-apple-darwin8.10.1
GCC target triplet: i386-apple-darwin8.10.1
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32572
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/32572] Small C++ function fails to inline with large negative badness
2007-07-01 18:10 [Bug tree-optimization/32572] New: Small C++ function fails to inline with large negative badness astrange at ithinksw dot com
@ 2007-07-02 6:18 ` astrange at ithinksw dot com
2007-07-16 19:52 ` astrange at ithinksw dot com
2007-09-15 23:47 ` astrange at ithinksw dot com
2 siblings, 0 replies; 4+ messages in thread
From: astrange at ithinksw dot com @ 2007-07-02 6:18 UTC (permalink / raw)
To: gcc-bugs
------- Comment #1 from astrange at ithinksw dot com 2007-07-02 06:18 -------
This is a regression from Apple gcc 4.0:
Considering void image::set(size_t, size_t, f_pixel, f_real) with 29 insns
Estimated growth is -21 insns.
Inlined into void set_test(image*, int, int, f_pixel&, double) which now has
32
insns.
Inlined for a net change of -21 insns.
and probably from earlier 4.3.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32572
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/32572] Small C++ function fails to inline with large negative badness
2007-07-01 18:10 [Bug tree-optimization/32572] New: Small C++ function fails to inline with large negative badness astrange at ithinksw dot com
2007-07-02 6:18 ` [Bug tree-optimization/32572] " astrange at ithinksw dot com
@ 2007-07-16 19:52 ` astrange at ithinksw dot com
2007-09-15 23:47 ` astrange at ithinksw dot com
2 siblings, 0 replies; 4+ messages in thread
From: astrange at ithinksw dot com @ 2007-07-16 19:52 UTC (permalink / raw)
To: gcc-bugs
------- Comment #2 from astrange at ithinksw dot com 2007-07-16 19:51 -------
Seems to work now in r126689.
--
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32572
^ permalink raw reply [flat|nested] 4+ messages in thread
* [Bug tree-optimization/32572] Small C++ function fails to inline with large negative badness
2007-07-01 18:10 [Bug tree-optimization/32572] New: Small C++ function fails to inline with large negative badness astrange at ithinksw dot com
2007-07-02 6:18 ` [Bug tree-optimization/32572] " astrange at ithinksw dot com
2007-07-16 19:52 ` astrange at ithinksw dot com
@ 2007-09-15 23:47 ` astrange at ithinksw dot com
2 siblings, 0 replies; 4+ messages in thread
From: astrange at ithinksw dot com @ 2007-09-15 23:47 UTC (permalink / raw)
To: gcc-bugs
------- Comment #3 from astrange at ithinksw dot com 2007-09-15 23:47 -------
It's more like it was accidentally fixed and the underlying cause is still
there, but it is fixed.
--
astrange at ithinksw dot com changed:
What |Removed |Added
----------------------------------------------------------------------------
Status|UNCONFIRMED |RESOLVED
Resolution| |FIXED
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=32572
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2007-09-15 23:47 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-01 18:10 [Bug tree-optimization/32572] New: Small C++ function fails to inline with large negative badness astrange at ithinksw dot com
2007-07-02 6:18 ` [Bug tree-optimization/32572] " astrange at ithinksw dot com
2007-07-16 19:52 ` astrange at ithinksw dot com
2007-09-15 23:47 ` astrange at ithinksw dot com
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).