https://bugzilla.novell.com/show_bug.cgi?id=462457


           Summary: Simd instructions fail under some optimization levels.
           Product: Mono: Runtime
           Version: 2.2.x
          Platform: x86
        OS/Version: Mac OS X 10.5
            Status: NEW
          Severity: Major
          Priority: P5 - None
         Component: misc
        AssignedTo: [email protected]
        ReportedBy: [email protected]
         QAContact: [email protected]
          Found By: Development


When compiling a program using the new Mono.Simd library, and no optimizations
turned on, the output of my test program is what I expected it to be.

But, when running with optimizations (all or ssa or ssapre, perhaps others) the
output is very much incorrect.

For instance, when the application is compiled with the command line:

gmcs -reference:Mono.Simd.dll -d:SIMD -out:NN.exe *.cs

and run with:

mono NN.exe or mono --optimize:sse2,simd NN.exe

the results are as expected;

1 1 1 1
2 2 2 2
3 3 3 3
4 4 4 4
5 5 5 5
6 6 6 6
7 7 7 7
8 8 8 8
9 9 9 9
10 10 10 10
11 11 11 11
12 12 12 12



But, if run with --optimize:ssa I get:


1 1 1 1
2 2 2 2
1 1 -0.999629 1
1 1 -0.999629 1
1 1 -0.999629 1
1 1 -0.999629 1
1 1 -0.999629 1
1 1 -0.999629 1
1 1 -0.999629 1
1 1 -0.999629 1
1 1 -0.999629 1
1 1 -0.999629 1


Those first two lines that show the correct answer we're done as single inline
add statements, the failures occurs inside a simple for loop.  the program is
attached, but the code in question is below:


Vector4f sum = new Vector4f(0,0,0,0);
Vector4f add = new Vector4f(1.0F,1.0F,1.0F,1.0F);

sum = sum + add;
Console.WriteLine("{0} {1} {2} {3}", sum.X, sum.Y, sum.Z, sum.W);
// Looks OK

sum = sum + add;
Console.WriteLine("{0} {1} {2} {3}", sum.X, sum.Y, sum.Z, sum.W);
// Looks OK

for (int i = 0; i < 10; ++i)
{
        sum = sum + add;
        Console.WriteLine("{0} {1} {2} {3}", sum.X, sum.Y, sum.Z, sum.W);
        // Fails on optimizations
}


Surprisingly, as the problem only shows up in loops, i tried it with loop
optimization on, but the error wasn't there.  I am not sure if other
optimizations or combinations cause the problem or not, though I suspect they
do, as I did a --optimize=all,-ssa,-ssapre and the error showed up.


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.
You are the assignee for the bug.
_______________________________________________
mono-bugs maillist  -  [email protected]
http://lists.ximian.com/mailman/listinfo/mono-bugs

Reply via email to