Pretty sure it's [bug] https://sourceforge.net/p/fbc/bugs/572 [/bug]
I know FBC is free software by volunteers, but it's still pretty frustrating.
Anyway; Doing my bit to help so here is the offending code reduced to some easy (not minimal) test-cases:
Code: Select all
'Compile with -fpu sse -vec 2
'#DEFINE TRY_NAMESPACE 'A namespace doesn't trigger the issue. Seems to be specific to UDTs
#Ifdef TRY_NAMESPACE
namespace X
dim as single h0,h1,h2
end namespace
#ELSE
type vec
as single h0,h1,h2
end type
dim as vec X
#endif
dim as single f0,f1,f2
dim as double d0
X.h0 = 1f:X.h1 = 2f:X.h2 =3f
f0 = X.h0+X.h1+X.h2
f1 = X.h0+X.h2
f2 = X.h2+X.h1+X.h0
d0 = X.h0+X.h1+X.h2
print X.h0;" +";X.h1;" +";X.h2;" =",f0 'in_order Expected:6, Got: 1
print X.h0;" +";X.h2;" =",f1 'Skipped Expected:4, Got: 4
print X.h2;" +";X.h1;" +";X.h0;" =",f2 'inverted Expected:6, Got: 6
print X.h0;" +";X.h1;" +";X.h2;" =",d0 'Double Expected:6, Got: 1
print X.h0;" +";X.h1;" +";X.h2;" =",X.h0+X.h1+X.h2 'in_order_but_passed_to_a_function Expected:6, Got: 6
sleep:end
What's really bad about this bug, is how silent it is. Unless you are doing FP math to calculate Ptrs or some other shenanigans that might segfault (Although texture lookup might actually do that so it's not that far-fetched actually.), you might never even notice that somethings is wrong. It'll just give you the wrong result. You'd have to check your computers Math. And how many people do that?
Oh yeah, tested with fbc-1.04.0-win32 & fbc-1.07.1-win64 The change-log for 1.07.2/1.07.3 doesn't mention a vector optimization bug-fix, and issue 572 is still open on Sourceforge so I didn't bother downloading them to test.