r600/sb: Avoid causing an exception when getting the reciprocal of 0u.
authorEmma Anholt <emma@anholt.net>
Fri, 11 Feb 2022 21:06:47 +0000 (13:06 -0800)
committerMarge Bot <emma+marge@anholt.net>
Wed, 20 Apr 2022 21:46:09 +0000 (21:46 +0000)
I'm not sure what the hardware would return in this circumstance, so just
don't fold it.  Avoids regressions on transition to NIR.

Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/14319>

src/gallium/drivers/r600/sb/sb_expr.cpp

index 6d062b7..091037c 100644 (file)
@@ -459,8 +459,13 @@ bool expr_handler::fold_alu_op1(alu_node& n) {
        case ALU_OP1_RECIP_FF:
        case ALU_OP1_RECIP_IEEE: dv = 1.0f / cv.f; break;
 //     case ALU_OP1_RECIP_INT:
-       case ALU_OP1_RECIP_UINT: dv.u = (1ull << 32) / cv.u; break;
-//     case ALU_OP1_RNDNE: dv = floor(cv.f + 0.5f); break;
+       case ALU_OP1_RECIP_UINT: {
+               if (!cv.u)
+                       return false;
+               dv.u = (1ull << 32) / cv.u;
+               break;
+       }
+       //      case ALU_OP1_RNDNE: dv = floor(cv.f + 0.5f); break;
        case ALU_OP1_SIN: dv = sin(cv.f * 2.0f * M_PI); break;
        case ALU_OP1_SQRT_IEEE: dv = sqrtf(cv.f); break;
        case ALU_OP1_TRUNC: dv = truncf(cv.f); break;