This is the mail archive of the mailing list for the GCC project.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [PATCH] Optimize manual byte swap implementations -refreshed

Hi Michael,

I'm just wondering out loud whether it would be useful to add tests of bswap
from a memory location in addition to a register (rs6000's main bswap is
load from and store to memory, and from, it looks like the s390 also
has a bswap from memory).  Most of the other bswap targets like the x86 are
register only, so presumably it would would work also.

Yes that works. On S/390 the memory variants will be used when having a bswap implementation with a memory source operand.
For the bswap pass it doesn't matter where the bswap source comes
from. The pass currently just looks if the back-end provides a bswap
pattern at all and does the replacement if possible.
I think combine or already at RTL expansion the mem will be propagated into the bswap pattern if the back-end accepts such an operand.

More tests certainly wouldn't hurt but I don't think they are really necessary. The existing testcases make sure that the recognition works and this shouldn't change if there is a DXXXX = *input just before the rest of bswap code which has to be recognized.
Perhaps it make sense to search for the resulting instructions in the asm output in order to make sure that the mem is successfully propagated into the builtin operand later, but such tests anyway have to be target specific.

Now, I can certainly put in extra powerpc tests, but I'm wondering if it would
be useful to add the tests as global tests.

Also, getting back to the issue raised in my latest bswap patches, I wonder
whether it would be useful to move bswap16 to generic, and add bswaphi support
to your patches?  I know the powerpc would find it useful, and IIRC, you could
do a 16-bit rotate on x86.

Don't we already fold a >> 8 | a << 8 on a 16bit mode quantity to a rotate on tree level? On the other hand extending the pass to deal with HImode bswap should be very easy.



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]