This better ensures that the src_bits == dst_bits case gets optimized away.
Reviewed-by: Neil Roberts <neil@linux.intel.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
{
if (src_bits < dst_bits) {
return EXTEND_NORMALIZED_INT(x, src_bits, dst_bits);
- } else {
+ } else if (src_bits > dst_bits) {
unsigned src_half = (1 << (src_bits - 1)) - 1;
if (src_bits + dst_bits > sizeof(x) * 8) {
} else {
return (x * MAX_UINT(dst_bits) + src_half) / MAX_UINT(src_bits);
}
+ } else {
+ return x;
}
}