From: Nicolai Hähnle <nicolai.haeh...@amd.com>

Avoid building all those store 0 / store undef instrucction pairs that
end up getting removed anyway.
---
 src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c 
b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
index 6a010d5..b419add 100644
--- a/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
+++ b/src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
@@ -483,43 +483,34 @@ static LLVMValueRef fetch_system_value(struct 
lp_build_tgsi_context *bld_base,
        struct gallivm_state *gallivm = bld_base->base.gallivm;
 
        LLVMValueRef cval = ctx->system_values[reg->Register.Index];
        if (LLVMGetTypeKind(LLVMTypeOf(cval)) == LLVMVectorTypeKind) {
                cval = LLVMBuildExtractElement(gallivm->builder, cval,
                                               lp_build_const_int32(gallivm, 
swizzle), "");
        }
        return bitcast(bld_base, type, cval);
 }
 
-static LLVMValueRef si_build_alloca_undef(struct gallivm_state *gallivm,
-                                         LLVMTypeRef type,
-                                         const char *name)
-{
-       LLVMValueRef ptr = lp_build_alloca(gallivm, type, name);
-       LLVMBuildStore(gallivm->builder, LLVMGetUndef(type), ptr);
-       return ptr;
-}
-
 static void emit_declaration(struct lp_build_tgsi_context *bld_base,
                             const struct tgsi_full_declaration *decl)
 {
        struct radeon_llvm_context *ctx = radeon_llvm_context(bld_base);
        LLVMBuilderRef builder = bld_base->base.gallivm->builder;
        unsigned first, last, i;
        switch(decl->Declaration.File) {
        case TGSI_FILE_ADDRESS:
        {
                 unsigned idx;
                for (idx = decl->Range.First; idx <= decl->Range.Last; idx++) {
                        unsigned chan;
                        for (chan = 0; chan < TGSI_NUM_CHANNELS; chan++) {
-                                ctx->soa.addr[idx][chan] = 
si_build_alloca_undef(
+                                ctx->soa.addr[idx][chan] = 
lp_build_alloca_undef(
                                        &ctx->gallivm,
                                        ctx->soa.bld_base.uint_bld.elem_type, 
"");
                        }
                }
                break;
        }
 
        case TGSI_FILE_TEMPORARY:
        {
                char name[16] = "";
@@ -574,21 +565,21 @@ static void emit_declaration(struct lp_build_tgsi_context 
*bld_base,
                        ctx->temps_count = 
bld_base->info->file_max[TGSI_FILE_TEMPORARY] + 1;
                        ctx->temps = MALLOC(TGSI_NUM_CHANNELS * 
ctx->temps_count * sizeof(LLVMValueRef));
                }
                if (!array_alloca) {
                        for (i = 0; i < decl_size; ++i) {
 #ifdef DEBUG
                                snprintf(name, sizeof(name), "TEMP%d.%c",
                                         first + i / 4, "xyzw"[i % 4]);
 #endif
                                ctx->temps[first * TGSI_NUM_CHANNELS + i] =
-                                       
si_build_alloca_undef(bld_base->base.gallivm,
+                                       
lp_build_alloca_undef(bld_base->base.gallivm,
                                                              
bld_base->base.vec_type,
                                                              name);
                        }
                } else {
                        LLVMValueRef idxs[2] = {
                                bld_base->uint_bld.zero,
                                NULL
                        };
                        LLVMValueRef undef = NULL;
                        unsigned j = 0;
@@ -633,21 +624,21 @@ static void emit_declaration(struct lp_build_tgsi_context 
*bld_base,
        }
        break;
 
        case TGSI_FILE_OUTPUT:
        {
                unsigned idx;
                for (idx = decl->Range.First; idx <= decl->Range.Last; idx++) {
                        unsigned chan;
                        assert(idx < RADEON_LLVM_MAX_OUTPUTS);
                        for (chan = 0; chan < TGSI_NUM_CHANNELS; chan++) {
-                               ctx->soa.outputs[idx][chan] = 
si_build_alloca_undef(
+                               ctx->soa.outputs[idx][chan] = 
lp_build_alloca_undef(
                                        &ctx->gallivm,
                                        ctx->soa.bld_base.base.elem_type, "");
                        }
                }
                break;
        }
 
        case TGSI_FILE_MEMORY:
                ctx->declare_memory_region(ctx, decl);
                break;
-- 
2.7.4

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to