Hey fellow twittettes. What's the quickest way to do an endian swap on RV32I ?
-
-
Yeah, I couldn't make it less than 11 either. Guess the only optimizations left is minimizing data deps for long pipelines
Thanks. Twitter will use this to make your timeline better. UndoUndo
-
-
-
For 11 instructions there’s no need for a mask. Just (x << 24) | (x >> 24) | (x << 8 >> 24 << 8) | (x >> 8 << 24 >> 8)
-
In practice I think minimizing shifts could be beneficial if the CPU doesn't have barrel shifters but this is of course all very hypothetical
- Show replies
New conversation -
-
-
I did it like this btw slli a1, a0, 24 srli t1, a0, 8 andi t1, t1, 0xff slli t1, t1, 16 or a1, a1, t1 srli t1, a0, 16 andi t1, t1, 0xff slli t1, t1, 8 or a1, a1, t1 srli t1, a0, 24 or a1, a1, t1
-
That’s what the macroized version I was already typing and tweeted one minute later optimizes to :-) It’s a total of 96 bit shifts vs 128 for the slam/slam/slam version and 56 for the 32 bit mask version.
End of conversation
New conversation -
Loading seems to be taking a while.
Twitter may be over capacity or experiencing a momentary hiccup. Try again or visit Twitter Status for more information.