The only thing I could find out was that ashift is 32-bit aligned but
sf->Ashift isn’t:
I don’t think it’s an alignment issue, since GCC should be smart enough
to get it into a register even if unaligned…however, sf->AShift is 8
bits, and ashift is 32, which is probably why you get different
results…it probably landed in (say) %al instead of %eax, leaving junk
in the rest of the register’s bits.
./src/video/SDL_blit_A.c: In function ‘BlitRGBtoRGBPixelAlphaMMX3DNOW’:
./src/video/SDL_blit_A.c:1571: error: memory input 1 is not directly
addressable
In any case I guess GCC should be smart enough to make this work as
expected, whether it’s an alignment issue or a data size issue. GCC bug
maybe?
--Gabriel
El mar, 21-11-2006 a las 16:30 -0500, Ryan C. Gordon escribi?:> > The only thing I could find out was that ashift is 32-bit aligned but
sf->Ashift isn’t:
I don’t think it’s an alignment issue, since GCC should be smart enough
to get it into a register even if unaligned…however, sf->AShift is 8
bits, and ashift is 32, which is probably why you get different
results…it probably landed in (say) %al instead of %eax, leaving junk
in the rest of the register’s bits.
the original code takes the address of the sf->Ashift variable and passes
this address to the assembler, because the ‘m’ constraint is used! Therefore
the movd instruction will not only load the content of sf->Ashift into
the mm5 register but also the following bits of the SDL_Pixelformat
structure (the lower three bytes of Rmask). The original propose of using the
local ashift variable (which is 32 bits wide) as input for the assembler
statement was correct.
To force gcc to load sf->Amask into a register you could also use
FrankOn Tuesday 21 November 2006 22:51, Gabriel Gambetta wrote:
Thanks for listening
The patch you sent doesn’t even compile -
./src/video/SDL_blit_A.c: In function ‘BlitRGBtoRGBPixelAlphaMMX3DNOW’:
./src/video/SDL_blit_A.c:1571: error: memory input 1 is not directly
addressable
In any case I guess GCC should be smart enough to make this work as
expected, whether it’s an alignment issue or a data size issue. GCC bug
maybe?
–Gabriel
El mar, 21-11-2006 a las 16:30 -0500, Ryan C. Gordon escribi?:
The only thing I could find out was that ashift is 32-bit aligned but
sf->Ashift isn’t:
I don’t think it’s an alignment issue, since GCC should be smart enough
to get it into a register even if unaligned…however, sf->AShift is 8
bits, and ashift is 32, which is probably why you get different
results…it probably landed in (say) %al instead of %eax, leaving junk
in the rest of the register’s bits.
This bug is actually my fault, and I just stumbled upon it myself a couple
days ago. I apologize for that, as I should have known better to
double-check the data type of Ashift.
IMHO, Frank’s and Ryan’s version of the fix is better with some minor
modifications to allows the compiler a bit more freedom. Also another
function has to be patched in a similar way – the pure MMX (non-3DNow!)
one, gcc version of BlitRGBtoRGBPixelAlphaMMX.
In light of all this I propose the following patch (also attached):
----- Original Message -----
From: sdl-bounces+avcp-sdlmail=usa.net@libsdl.org
[mailto:sdl-bounces+avcp-sdlmail=usa.net at libsdl.org] On Behalf Of Ryan C.
Gordon
Sent: Tuesday, November 21, 2006 6:35 PM
To: A list for developers using the SDL library. (includes SDL-announce)
Subject: Re: [SDL] Alpha blending bug - fixed?
We’ll go with Gabriel’s patch.
…which is now Subversion revision #2914 for the 1.2 branch, and #2915
for the 1.3 branch.
Hi Alex,On Saturday 02 December 2006 00:32, Alex Volkov wrote:
This bug is actually my fault, and I just stumbled upon it myself a couple
days ago. I apologize for that, as I should have known better to
double-check the data type of Ashift.
IMHO, Frank’s and Ryan’s version of the fix is better with some minor
modifications to allows the compiler a bit more freedom. Also another
function has to be patched in a similar way – the pure MMX (non-3DNow!)
one, gcc version of BlitRGBtoRGBPixelAlphaMMX.
In light of all this I propose the following patch (also attached):
“rm” is senseless as the compiler can never choose “m”.
It must choose “r” since using “m” he would complain
memory input 1 is not directly addressable
That is not entirely correct, Frank. The compiler may elect to pre-calculate
((Uint32) sf->Ashift) and put it in a temp stack var to be used later in the
MOVD. That is if the compiler decides it would make code faster, for
example, not that it would make any difference in this case.
Yes, you are right, it seems that compiler is able to do that. Just tested
with an appropriate test case. However, it is interesting that gcc > 3.4
refuses to compile the same statement without ‘r’ . gcc-3.3 and 3.4 would
warn in this case
warning: use of memory input without lvalue in asm operand 0 is deprecated
while gcc-4.0 and gcc-4.1 would refuse to compile.
Kind regards,
FrankOn Monday 04 December 2006 18:51, Alex Volkov wrote:
“rm” is senseless as the compiler can never choose “m”.
It must choose “r” since using “m” he would complain
memory input 1 is not directly addressable
That is not entirely correct, Frank. The compiler may elect to
pre-calculate ((Uint32) sf->Ashift) and put it in a temp stack var to be
used later in the MOVD. That is if the compiler decides it would make code
faster, for example, not that it would make any difference in this case.
–
Dept. of Computer Science, Dresden University of Technology, Germany