Module: Mesa
Branch: master
Commit: 10b1f266872bd03881b7bd0c7894f0ebf020db42
URL:    
http://cgit.freedesktop.org/mesa/mesa/commit/?id=10b1f266872bd03881b7bd0c7894f0ebf020db42

Author: Alyssa Rosenzweig <[email protected]>
Date:   Fri Jan 15 15:46:39 2021 -0500

pan/bi: Lower frsq to Newton-Raphson

Signed-off-by: Alyssa Rosenzweig <[email protected]>
Acked-by: Boris Brezillon <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/8894>

---

 src/panfrost/bifrost/bifrost_compile.c | 13 +++++++++++++
 1 file changed, 13 insertions(+)

diff --git a/src/panfrost/bifrost/bifrost_compile.c 
b/src/panfrost/bifrost/bifrost_compile.c
index f73c74b9467..7ea1b5f877e 100644
--- a/src/panfrost/bifrost/bifrost_compile.c
+++ b/src/panfrost/bifrost/bifrost_compile.c
@@ -989,6 +989,19 @@ bi_lower_frcp_32(bi_builder *b, bi_index dst, bi_index s0)
                         BI_ROUND_NONE, BI_SPECIAL_NONE);
 }
 
+static void
+bi_lower_frsq_32(bi_builder *b, bi_index dst, bi_index s0)
+{
+        bi_index x1 = bi_frsq_approx_f32(b, s0);
+        bi_index m  = bi_frexpm_f32(b, s0, false, true);
+        bi_index e  = bi_frexpe_f32(b, bi_neg(s0), false, true);
+        bi_index t1 = bi_fmul_f32(b, x1, x1);
+        bi_index t2 = bi_fma_rscale_f32(b, m, bi_neg(t1), bi_imm_f32(1.0),
+                        bi_imm_u32(-1), BI_ROUND_NONE, BI_SPECIAL_N);
+        bi_fma_rscale_f32_to(b, dst, t2, x1, x1, e,
+                        BI_ROUND_NONE, BI_SPECIAL_N);
+}
+
 static void
 bi_emit_alu(bi_builder *b, nir_alu_instr *instr)
 {

_______________________________________________
mesa-commit mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/mesa-commit

Reply via email to