cavs.c DECLARE_ALIGNED in ff_cavs_filter
Hello, currently there is this code in cavs.c: DECLARE_ALIGNED_8(uint8_t, bs[8]); The reason for it is that kind of code:
*((uint64_t *)bs) = 0x0202020202020202ULL; if( *((uint64_t *)bs) ) {
I thought of "solving" this via a union, but is this code really this speed critical that we need such a mess? Can't we just use memset for the writes and e.g. AV_RN64 for the read?
Reimar D?ffinger <Reimar.Doeffinger at gmx.de> writes:
Hello, currently there is this code in cavs.c: DECLARE_ALIGNED_8(uint8_t, bs[8]); The reason for it is that kind of code:
*((uint64_t *)bs) = 0x0202020202020202ULL; if( *((uint64_t *)bs) ) {
I thought of "solving" this via a union, but is this code really this speed critical that we need such a mess? Can't we just use memset for the writes and e.g. AV_RN64 for the read?
Such huge literals are fairly inefficient anyway on most CPUs. -- M?ns Rullg?rd mans at mansr.com
On Mon, 25 May 2009, M?ns Rullg?rd wrote:
Reimar D?ffinger <Reimar.Doeffinger at gmx.de> writes:
currently there is this code in cavs.c: DECLARE_ALIGNED_8(uint8_t, bs[8]); The reason for it is that kind of code:
*((uint64_t *)bs) = 0x0202020202020202ULL; if( *((uint64_t *)bs) ) {
I thought of "solving" this via a union, but is this code really this speed critical that we need such a mess? Can't we just use memset for the writes and e.g. AV_RN64 for the read?
Are you complaining about the aliasing, or trying to simplify the code?
Such huge literals are fairly inefficient anyway on most CPUs.
As opposed to what? The compiler should emit the same code for memset as for *(uint64_t*), and gcc on x86 does. --Loren Merritt
On Mon, May 25, 2009 at 10:10:39AM +0000, Loren Merritt wrote:
On Mon, 25 May 2009, M?ns Rullg?rd wrote:
Reimar D?ffinger <Reimar.Doeffinger at gmx.de> writes:
currently there is this code in cavs.c: DECLARE_ALIGNED_8(uint8_t, bs[8]); The reason for it is that kind of code:
*((uint64_t *)bs) = 0x0202020202020202ULL; if( *((uint64_t *)bs) ) {
I thought of "solving" this via a union, but is this code really this speed critical that we need such a mess? Can't we just use memset for the writes and e.g. AV_RN64 for the read?
Are you complaining about the aliasing, or trying to simplify the code?
Actually about the DECLARE_ALIGNED_8 for a stack variable. 8 seems more unlikely to cause issues than 16, but I am still trying to remove that kind of stuff.
Such huge literals are fairly inefficient anyway on most CPUs.
As opposed to what? The compiler should emit the same code for memset as for *(uint64_t*), and gcc on x86 does.
which would be an argument to use memset for simplicity, the read is a slightly different question. Btw. I know h264.c has the same code, but I don't want to mess with that.
Loren Merritt <lorenm at u.washington.edu> writes:
On Mon, 25 May 2009, M?ns Rullg?rd wrote:
Reimar D?ffinger <Reimar.Doeffinger at gmx.de> writes:
currently there is this code in cavs.c: DECLARE_ALIGNED_8(uint8_t, bs[8]); The reason for it is that kind of code:
*((uint64_t *)bs) = 0x0202020202020202ULL; if( *((uint64_t *)bs) ) {
I thought of "solving" this via a union, but is this code really this speed critical that we need such a mess? Can't we just use memset for the writes and e.g. AV_RN64 for the read?
Are you complaining about the aliasing, or trying to simplify the code?
Such huge literals are fairly inefficient anyway on most CPUs.
As opposed to what?
memset() or repeated stores of a smaller value.
The compiler should emit the same code for memset as for *(uint64_t*),
I thought we'd already established that compilers suck.
and gcc on x86 does.
Impressive. What about other targets? -- M?ns Rullg?rd mans at mansr.com
Hi, Reimar D?ffinger wrote:
Hello, currently there is this code in cavs.c: DECLARE_ALIGNED_8(uint8_t, bs[8]); The reason for it is that kind of code:
*((uint64_t *)bs) = 0x0202020202020202ULL; if( *((uint64_t *)bs) ) {
I thought of "solving" this via a union, but is this code really this speed critical that we need such a mess?
My impression is that in lavc code that is on the macroblock level or smaller units is usually considered speed-critical enough to make such things acceptable.
Can't we just use memset for the writes and e.g. AV_RN64 for the read?
Would moving bs to the context and keeping the DECLARE_ALIGNED_8 be an option? Stefan
Stefan Gehrer wrote:
Hi,
Reimar D?ffinger wrote:
Hello, currently there is this code in cavs.c: DECLARE_ALIGNED_8(uint8_t, bs[8]); The reason for it is that kind of code:
*((uint64_t *)bs) = 0x0202020202020202ULL; if( *((uint64_t *)bs) ) {
I thought of "solving" this via a union, but is this code really this speed critical that we need such a mess?
My impression is that in lavc code that is on the macroblock level or smaller units is usually considered speed-critical enough to make such things acceptable.
Can't we just use memset for the writes and e.g. AV_RN64 for the read?
I benchmarked it (on x86) to not make a difference, so I followed Reimar's suggestion to use memset and AV_RN64. Stefan
participants (4)
-
lorenm@u.washington.edu -
mans@mansr.com -
Reimar.Doeffinger@gmx.de -
stefan.gehrer@gmx.de