x86mul.hu
LBT intrinsic · group: x86 Integer
Synopsis
Instruction: x86mul.hu rj, rk
CPU Flags: LBT
Description
x86-style multiply: multiply unsigned 16-bit values in rj and rk. Set CF and OF if overflow (result does not fit in 16-bits), clear other flags. Only EFLAGS (LBT4) is updated; the GPR is not modified.
Operation
uint16_t lhs = (uint16_t)a;
uint16_t rhs = (uint16_t)b;
unsigned __int128 product =
(unsigned __int128)(uint16_t)lhs * (unsigned __int128)(uint16_t)rhs;
bool overflow = (product >> 16) != 0;
EFLAGS.CF = overflow;
EFLAGS.OF = overflow;
EFLAGS.SF = 0;
EFLAGS.ZF = 0;
EFLAGS.AF = 0;
EFLAGS.PF = 0;
Tested on real machine.
Latency and Throughput
| CPU | µarch | Latency | Throughput (IPC) |
|---|---|---|---|
| 3C5000 | LA464 | 1.17 | 0.86(1/1.17) |
| 3C6000 | LA664 | 1 | 1 |