Re: [eigen] Eigen code gets optimized away by avr-g++ - what to do?

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


On 30.06.2012 00:00, Christoph Hertzberg wrote:
On 29.06.2012 22:21, Ryan Pavlik wrote:
However, I am now seeing quite strange behavior. It looks like Eigen code
(and possibly the rest of the function in which it is used?) gets
optimized
out of the compiled binary.  (It's so efficient, it doesn't have any
code!
:D )  When built by the IDE, it uses -Os optimization (which is -O2
without
the ones deemed to potentially enlarge the code) which triggers the
issue.
-O1 optimization doesn't seem to trigger it (by looking at the
disassembly,
I actually see a call to sqrtf when my test program calls .norm() on a
vector) though I haven't actually run that code on a device.

The code looks simple enough that gcc can calculate the result of
v1.norm() at compile-time. You should pass an unknown vector to the
function, if you want see whether it actually does anything.


Looking a bit closer into the generated assembly, for O1 the sqrt implementation recursively calls itself in line 1970:
     f10:	0e 94 88 07 	call	0xf10	; 0xf10 <_ZSt4sqrtf>

In Os this seems to get optimized to an infinite loop (line 173):
 116:	ff cf       	rjmp	.-2      	; 0x116 <loop+0xc>

So I guess your sqrt implementation does not work ...

Christoph


--
----------------------------------------------
Dipl.-Inf. Christoph Hertzberg
Cartesium 0.049
Universität Bremen
Enrique-Schmidt-Straße 5
28359 Bremen

Tel: +49 (421) 218-64252
----------------------------------------------





Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/