diff --git a/src/compiler/nir/nir_opcodes.py b/src/compiler/nir/nir_opcodes.py index dded4a6a635..b49efdbcc19 100644 --- a/src/compiler/nir/nir_opcodes.py +++ b/src/compiler/nir/nir_opcodes.py @@ -500,16 +500,12 @@ for (int bit = bit_size - 1; bit >= 0; bit--) { unop_convert("ifind_msb_rev", tint32, tint, """ dst = -1; -if (src0 != 0 && src0 != -1) { - for (int bit = 0; bit < 31; bit++) { - /* If src0 < 0, we're looking for the first 0 bit. - * if src0 >= 0, we're looking for the first 1 bit. - */ - if ((((src0 << bit) & 0x40000000) && (src0 >= 0)) || - ((!((src0 << bit) & 0x40000000)) && (src0 < 0))) { - dst = bit; - break; - } +/* We are looking for the highest bit that's not the same as the sign bit. */ +uint32_t sign = src0 & 0x80000000u; +for (int bit = 0; bit < 32; bit++) { + if (((src0 << bit) & 0x80000000u) != sign) { + dst = bit; + break; } } """)