nir: Fix ifind_msb_rev constant folding.
For example if src0 is 0x80000000 we should return 1, not 0. Signed-off-by: Georg Lehmann <dadschoorse@gmail.com> Reviewed-by: Ian Romanick <ian.d.romanick@intel.com> Reviewed-by: Rhys Perry <pendingchaos02@gmail.com> Fixes:a5747f8ab3
("nir: add opcodes for *find_msb_rev and lowering") Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18951> (cherry picked from commit741dbadae0
)
This commit is contained in:

committed by
Dylan Baker

parent
8771aff787
commit
b2e3963fd9
@@ -2344,7 +2344,7 @@
|
||||
"description": "nir: Fix ifind_msb_rev constant folding.",
|
||||
"nominated": true,
|
||||
"nomination_type": 1,
|
||||
"resolution": 0,
|
||||
"resolution": 1,
|
||||
"main_sha": null,
|
||||
"because_sha": "a5747f8ab357ff00c630b937b221e5fb59d90289"
|
||||
},
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
""")
|
||||
|
Reference in New Issue
Block a user