Re: [eigen] Bug in Mercury version ?

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


Hi,

thanks a lot for reporting this very hard to spot bug ! Actually this
is a GCC's bug. Here is the generated ASM:

	movsd	272(%rsp), %xmm0
	movl	$3, 280(%rsp)
	movl	$4, 284(%rsp)
	movl	$1, 272(%rsp)
	movhps	280(%rsp), %xmm0
	movl	$2, 276(%rsp)
	movdqa	%xmm0, 256(%rsp)

as you can see it first loads the first two integers of "data" in
%xmm0 before initializing data itself !

This is probably because GCC gets confused by the use of floating
point instructions to load integer values in ei_ploadu(int*). I used
them because they are faster). Using the cleaner _mm_loadu_si128
intrinsics in ei_ploadu(int*) fixes the issue. I'll commit the fix
very soon.

gael.

On Tue, Jun 23, 2009 at 8:04 PM, Helmut
Jarausch<jarausch@xxxxxxxxxxxxxxxxxxx> wrote:
> Hi,
>
> I've tried the following test case with today's Mercury version of Eigen
> (taken from the documentation, except braces around 1,2,3,4 are missing
>  in the documentation.)
>
> #include <iostream>
> #include <Eigen/Core>
> // import most common Eigen types
> USING_PART_OF_NAMESPACE_EIGEN
>
> // first column of mat2x2 contains garbage if the following line is commented out
> //#define THIS_WORKS
> int main() {
>  int data[4] = {1, 2, 3, 4};
> #ifdef THIS_WORKS
>    std::cout << data[0] << '|' << data[1] << '|'
>              << data[2] << '|' << data[3] << std::endl;
> #endif
>  Matrix2i mat2x2(data);
>  std::cout << mat2x2 << std::endl;
> }
>
>
> If THIS_WORKS is undefined, I get an output where the first column
> of mat2x2 contains garbage.
>
> Am I missing something?
>
> (I'm using gcc-4.3.3 on a Gentoo Linux AMD64 machine)
> compiler options:
> -O3 -mtune=native -msse2
>
> Compiling without these options gives a running binary.
> Is this an Eigen or a g++ bug?
>
> (The same problem occurs with gcc-4.4.0)
>
>
> Thanks for any hints,
> Helmut.
>
> --
> Helmut Jarausch
>
> Lehrstuhl fuer Numerische Mathematik
> RWTH - Aachen University
> D 52056 Aachen, Germany
>
>
>



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