rcri.h
LBT intrinsic · group: LBT Integer
Synopsis
Instruction: rcri.h rd, rj, imm
CPU Flags: LBT
Description
Rotate 16-bit value in rj and CF (in EFLAGS) together as a 17-bit ring right by immediate imm. The result is written to rd.
Operation
uint16_t v = (uint16_t)a;
unsigned c = (unsigned)imm % (16 + 1);
// Rotate [CF, v] right by c, write low 16 bits to rd
uint64_t ring_hi = EFLAGS.CF;
uint64_t ring_lo = v;
uint64_t r;
if (c == 0) {
r = v;
} else {
uint64_t tmp_hi = ring_hi, tmp_lo = ring_lo;
for (unsigned i = 0; i < c; i++) {
uint64_t new_lo = (tmp_lo >> 1) | (tmp_hi << (16 - 1));
uint64_t new_hi = tmp_lo & 1;
tmp_lo = new_lo;
tmp_hi = new_hi;
}
r = tmp_lo & ((1ULL << 16) - 1);
}
dst = sext(r, 16);
Tested on real machine.
Latency and Throughput
| CPU | µarch | Latency | Throughput (IPC) |
|---|---|---|---|
| 3C5000 | LA464 | 2 | 1 |
| 3C6000 | LA664 | 2 | 1 |