Given an 128-bit xmm register that is packed with two quadwords (i.e. two 64-bit integers):
╭──────────────────┬──────────────────╮
xmm0 │ ffeeddccbbaa9988 │ 7766554433221100 │
╰──────────────────┴──────────────────╯
How can i perform a rotate on the individual quadwords? For example:
prorqw xmm0, 32 // rotate right packed quadwords
╭──────────────────┬──────────────────╮
xmm0 │ bbaa9988ffeeddcc │ 3322110077665544 │
╰──────────────────┴──────────────────╯
I know SSE2 provides:
PSHUFW: shuffle packed words (16-bits)PSHUFD: shuffle packed doublewords (32-bits)
Although i don't know what the instructions do, nor is there a quadword (64-bit) version.
Bonus Question
How would you perform a ROR of an xmm register - assuming packed data of other sizes?
Rotate Right Packed doublewords by 16-bits:
╭──────────┬──────────┬──────────┬──────────╮ xmm0 │ ffeeddcc │ bbaa9988 │ 77665544 │ 33221100 │ ╰──────────┴──────────┴──────────┴──────────╯ ⇓ ╭──────────┬──────────┬──────────┬──────────╮ xmm0 │ ddccffee │ 9988bbaa │ 55447766 │ 11003322 │ ╰──────────┴──────────┴──────────┴──────────╯Rotate Right Packed Words by 8-bits:
╭──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────╮ xmm0 │ ffee │ ddcc │ bbaa │ 9988 │ 7766 │ 5544 │ 3322 │ 1100 │ ╰──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────╯ ⇓ ╭──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────╮ xmm0 │ eeff │ ccdd │ aabb │ 8899 │ 6677 │ 4455 │ 2233 │ 0011 │ ╰──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────╯
Extra bonus question
How would you perform the above if it was a 256-bit ymm register?
╭──────────────────────────────────┬──────────────────────────────────╮
ymm0 │ 2f2e2d2c2b2a29282726252423222120 │ ffeeddccbbaa99887766554433221100 │ packed doublequadwords
╰──────────────────────────────────┴──────────────────────────────────╯
╭──────────────────┬──────────────────┬──────────────────┬──────────────────╮
ymm0 │ 2f2e2d2c2b2a2928 │ 2726252423222120 │ ffeeddccbbaa9988 │ 7766554433221100 │ packed quadwords
╰──────────────────┴──────────────────┴──────────────────┴──────────────────╯
╭──────────┬──────────┬──────────┬──────────┬──────────┬──────────┬──────────┬──────────╮
ymm0 │ 2f2e2d2c │ 2b2a2928 │ 27262524 │ 23222120 │ ffeeddcc │ bbaa9988 │ 77665544 │ 33221100 │ packed doublewords
╰──────────┴──────────┴──────────┴──────────┴──────────┴──────────┴──────────┴──────────╯
╭──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────┬──────╮
ymm0 │ 2f2e │ 2d2c │ 2b2a │ 2928 │ 2726 │ 2524 │ 2322 │ 2120 │ ffee │ ddcc │ bbaa │ 9988 │ 7766 │ 5544 │ 3322 │ 1100 │ packed words
╰──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────┴──────╯





