<div dir="ltr"><div>The driver should ignore the nir option on SI with LLVM <= 0x0500.<br><br></div>Marek<br></div><div class="gmail_extra"><br><div class="gmail_quote">On Tue, Mar 27, 2018 at 12:19 AM, Timothy Arceri <span dir="ltr"><<a href="mailto:tarceri@itsqueeze.com" target="_blank">tarceri@itsqueeze.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">This will be shared by the TGSI and NIR backends. For simplicity<br>
we leave the SI LLVM 5.0 and lower work around only in the TGSI<br>
backend.<br>
---<br>
 src/gallium/drivers/radeonsi/<wbr>si_shader.c | 88 ++++++++++++++++++------------<wbr>--<br>
 1 file changed, 49 insertions(+), 39 deletions(-)<br>
<br>
diff --git a/src/gallium/drivers/<wbr>radeonsi/si_shader.c b/src/gallium/drivers/<wbr>radeonsi/si_shader.c<br>
index d5607a99d32..62cb7ea7eb5 100644<br>
--- a/src/gallium/drivers/<wbr>radeonsi/si_shader.c<br>
+++ b/src/gallium/drivers/<wbr>radeonsi/si_shader.c<br>
@@ -2322,6 +2322,49 @@ void si_tgsi_declare_compute_<wbr>memory(struct si_shader_context *ctx,<br>
        si_declare_compute_memory(ctx)<wbr>;<br>
 }<br>
<br>
+static LLVMValueRef load_const_buffer_desc_fast_<wbr>path(struct si_shader_context *ctx)<br>
+{<br>
+       LLVMValueRef ptr =<br>
+               LLVMGetParam(ctx->main_fn, ctx->param_const_and_shader_<wbr>buffers);<br>
+       struct si_shader_selector *sel = ctx->shader->selector;<br>
+<br>
+       /* Do the bounds checking with a descriptor, because<br>
+        * doing computation and manual bounds checking of 64-bit<br>
+        * addresses generates horrible VALU code with very high<br>
+        * VGPR usage and very low SIMD occupancy.<br>
+        */<br>
+       ptr = LLVMBuildPtrToInt(ctx->ac.<wbr>builder, ptr, ctx->ac.intptr, "");<br>
+<br>
+       LLVMValueRef desc0, desc1;<br>
+       if (HAVE_32BIT_POINTERS) {<br>
+               desc0 = ptr;<br>
+               desc1 = LLVMConstInt(ctx->i32,<br>
+                                    S_008F04_BASE_ADDRESS_HI(ctx-><wbr>screen->info.address32_hi), 0);<br>
+       } else {<br>
+               ptr = LLVMBuildBitCast(ctx->ac.<wbr>builder, ptr, ctx->v2i32, "");<br>
+               desc0 = LLVMBuildExtractElement(ctx-><wbr>ac.builder, ptr, ctx->i32_0, "");<br>
+               desc1 = LLVMBuildExtractElement(ctx-><wbr>ac.builder, ptr, ctx->i32_1, "");<br>
+               /* Mask out all bits except BASE_ADDRESS_HI. */<br>
+               desc1 = LLVMBuildAnd(ctx->ac.builder, desc1,<br>
+                                    LLVMConstInt(ctx->i32, ~C_008F04_BASE_ADDRESS_HI, 0), "");<br>
+       }<br>
+<br>
+       LLVMValueRef desc_elems[] = {<br>
+               desc0,<br>
+               desc1,<br>
+               LLVMConstInt(ctx->i32, (sel->info.const_file_max[0] + 1) * 16, 0),<br>
+               LLVMConstInt(ctx->i32,<br>
+                       S_008F0C_DST_SEL_X(V_008F0C_<wbr>SQ_SEL_X) |<br>
+                       S_008F0C_DST_SEL_Y(V_008F0C_<wbr>SQ_SEL_Y) |<br>
+                       S_008F0C_DST_SEL_Z(V_008F0C_<wbr>SQ_SEL_Z) |<br>
+                       S_008F0C_DST_SEL_W(V_008F0C_<wbr>SQ_SEL_W) |<br>
+                       S_008F0C_NUM_FORMAT(V_008F0C_<wbr>BUF_NUM_FORMAT_FLOAT) |<br>
+                       S_008F0C_DATA_FORMAT(V_008F0C_<wbr>BUF_DATA_FORMAT_32), 0)<br>
+       };<br>
+<br>
+       return ac_build_gather_values(&ctx-><wbr>ac, desc_elems, 4);<br>
+}<br>
+<br>
 static LLVMValueRef load_const_buffer_desc(struct si_shader_context *ctx, int i)<br>
 {<br>
        LLVMValueRef list_ptr = LLVMGetParam(ctx->main_fn,<br>
@@ -2400,8 +2443,6 @@ static LLVMValueRef fetch_constant(<br>
        /* Fast path when user data SGPRs point to constant buffer 0 directly. */<br>
        if (sel->info.const_buffers_<wbr>declared == 1 &&<br>
            sel->info.shader_buffers_<wbr>declared == 0) {<br>
-               LLVMValueRef ptr =<br>
-                       LLVMGetParam(ctx->main_fn, ctx->param_const_and_shader_<wbr>buffers);<br>
<br>
                /* This enables use of s_load_dword and flat_load_dword for const buffer 0<br>
                 * loads, and up to x4 load opcode merging. However, it leads to horrible<br>
@@ -2416,48 +2457,17 @@ static LLVMValueRef fetch_constant(<br>
                 * s_buffer_load_dword (that we have to prevent) is when we use use<br>
                 * a literal offset where we don't need bounds checking.<br>
                 */<br>
-               if (ctx->screen->info.chip_class == SI &&<br>
-                    HAVE_LLVM < 0x0600 &&<br>
-                    !reg->Register.Indirect) {<br>
+               if (ctx->screen->info.chip_class == SI && HAVE_LLVM < 0x0600 &&<br>
+                   !reg->Register.Indirect) {<br>
+                       LLVMValueRef ptr =<br>
+                               LLVMGetParam(ctx->main_fn, ctx->param_const_and_shader_<wbr>buffers);<br>
+<br>
                        addr = LLVMBuildLShr(ctx->ac.builder, addr, LLVMConstInt(ctx->i32, 2, 0), "");<br>
                        LLVMValueRef result = ac_build_load_invariant(&ctx-><wbr>ac, ptr, addr);<br>
                        return bitcast(bld_base, type, result);<br>
                }<br>
<br>
-               /* Do the bounds checking with a descriptor, because<br>
-                * doing computation and manual bounds checking of 64-bit<br>
-                * addresses generates horrible VALU code with very high<br>
-                * VGPR usage and very low SIMD occupancy.<br>
-                */<br>
-               ptr = LLVMBuildPtrToInt(ctx->ac.<wbr>builder, ptr, ctx->ac.intptr, "");<br>
-<br>
-               LLVMValueRef desc0, desc1;<br>
-               if (HAVE_32BIT_POINTERS) {<br>
-                       desc0 = ptr;<br>
-                       desc1 = LLVMConstInt(ctx->i32,<br>
-                                            S_008F04_BASE_ADDRESS_HI(ctx-><wbr>screen->info.address32_hi), 0);<br>
-               } else {<br>
-                       ptr = LLVMBuildBitCast(ctx->ac.<wbr>builder, ptr, ctx->v2i32, "");<br>
-                       desc0 = LLVMBuildExtractElement(ctx-><wbr>ac.builder, ptr, ctx->i32_0, "");<br>
-                       desc1 = LLVMBuildExtractElement(ctx-><wbr>ac.builder, ptr, ctx->i32_1, "");<br>
-                       /* Mask out all bits except BASE_ADDRESS_HI. */<br>
-                       desc1 = LLVMBuildAnd(ctx->ac.builder, desc1,<br>
-                                            LLVMConstInt(ctx->i32, ~C_008F04_BASE_ADDRESS_HI, 0), "");<br>
-               }<br>
-<br>
-               LLVMValueRef desc_elems[] = {<br>
-                       desc0,<br>
-                       desc1,<br>
-                       LLVMConstInt(ctx->i32, (sel->info.const_file_max[0] + 1) * 16, 0),<br>
-                       LLVMConstInt(ctx->i32,<br>
-                               S_008F0C_DST_SEL_X(V_008F0C_<wbr>SQ_SEL_X) |<br>
-                               S_008F0C_DST_SEL_Y(V_008F0C_<wbr>SQ_SEL_Y) |<br>
-                               S_008F0C_DST_SEL_Z(V_008F0C_<wbr>SQ_SEL_Z) |<br>
-                               S_008F0C_DST_SEL_W(V_008F0C_<wbr>SQ_SEL_W) |<br>
-                               S_008F0C_NUM_FORMAT(V_008F0C_<wbr>BUF_NUM_FORMAT_FLOAT) |<br>
-                               S_008F0C_DATA_FORMAT(V_008F0C_<wbr>BUF_DATA_FORMAT_32), 0)<br>
-               };<br>
-               LLVMValueRef desc = ac_build_gather_values(&ctx-><wbr>ac, desc_elems, 4);<br>
+               LLVMValueRef desc = load_const_buffer_desc_fast_<wbr>path(ctx);<br>
                LLVMValueRef result = buffer_load_const(ctx, desc, addr);<br>
                return bitcast(bld_base, type, result);<br>
        }<br>
<span class="HOEnZb"><font color="#888888">--<br>
2.14.3<br>
<br>
______________________________<wbr>_________________<br>
mesa-dev mailing list<br>
<a href="mailto:mesa-dev@lists.freedesktop.org">mesa-dev@lists.freedesktop.org</a><br>
<a href="https://lists.freedesktop.org/mailman/listinfo/mesa-dev" rel="noreferrer" target="_blank">https://lists.freedesktop.org/<wbr>mailman/listinfo/mesa-dev</a><br>
</font></span></blockquote></div><br></div>