return 0;
 }
 
+static bool
+glsl_is_array_image(const struct glsl_type *type)
+{
+       const enum glsl_sampler_dim dim = glsl_get_sampler_dim(type);
+
+       if (glsl_sampler_type_is_array(type))
+               return true;
+
+       return dim == GLSL_SAMPLER_DIM_CUBE ||
+              dim == GLSL_SAMPLER_DIM_3D ||
+              dim == GLSL_SAMPLER_DIM_SUBPASS ||
+              dim == GLSL_SAMPLER_DIM_SUBPASS_MS;
+}
 
 
 /* Adjust the sample index according to FMASK.
                res = trim_vector(&ctx->ac, res, instr->dest.ssa.num_components);
                res = ac_to_integer(&ctx->ac, res);
        } else {
-               bool is_da = glsl_sampler_type_is_array(type) ||
-                            dim == GLSL_SAMPLER_DIM_CUBE ||
-                            dim == GLSL_SAMPLER_DIM_3D ||
-                            dim == GLSL_SAMPLER_DIM_SUBPASS ||
-                            dim == GLSL_SAMPLER_DIM_SUBPASS_MS;
-               LLVMValueRef da = is_da ? ctx->ac.i1true : ctx->ac.i1false;
+               LLVMValueRef da = glsl_is_array_image(type) ? ctx->ac.i1true : ctx->ac.i1false;
                LLVMValueRef glc = ctx->ac.i1false;
                LLVMValueRef slc = ctx->ac.i1false;
 
                ac_build_intrinsic(&ctx->ac, "llvm.amdgcn.buffer.store.format.v4f32", ctx->ac.voidt,
                                   params, 6, 0);
        } else {
-               bool is_da = glsl_sampler_type_is_array(type) ||
-                            dim == GLSL_SAMPLER_DIM_CUBE ||
-                            dim == GLSL_SAMPLER_DIM_3D;
-               LLVMValueRef da = is_da ? ctx->ac.i1true : ctx->ac.i1false;
+               LLVMValueRef da = glsl_is_array_image(type) ? ctx->ac.i1true : ctx->ac.i1false;
                LLVMValueRef slc = ctx->ac.i1false;
 
                params[0] = ac_to_float(&ctx->ac, get_src(ctx, instr->src[2]));
        } else {
                char coords_type[8];
 
-               bool da = glsl_sampler_type_is_array(type) ||
-                         glsl_get_sampler_dim(type) == GLSL_SAMPLER_DIM_CUBE ||
-                         glsl_get_sampler_dim(type) == GLSL_SAMPLER_DIM_3D;
-
                LLVMValueRef coords = params[param_count++] = get_image_coords(ctx, instr);
                params[param_count++] = get_sampler_desc(ctx, instr->variables[0], AC_DESC_IMAGE,
                                                         NULL, true, true);
                params[param_count++] = ctx->ac.i1false; /* r128 */
-               params[param_count++] = da ? ctx->ac.i1true : ctx->ac.i1false;      /* da */
+               params[param_count++] = glsl_is_array_image(type) ? ctx->ac.i1true : ctx->ac.i1false;      /* da */
                params[param_count++] = ctx->ac.i1false;  /* slc */
 
                build_int_type_name(LLVMTypeOf(coords),
 {
        const nir_variable *var = instr->variables[0]->var;
        const struct glsl_type *type = glsl_without_array(var->type);
-       bool da = glsl_sampler_type_is_array(type) ||
-                 glsl_get_sampler_dim(type) == GLSL_SAMPLER_DIM_CUBE ||
-                 glsl_get_sampler_dim(type) == GLSL_SAMPLER_DIM_3D;
 
        struct ac_image_args args = { 0 };
-       args.da = da;
+       args.da = glsl_is_array_image(type);
        args.dmask = 0xf;
        args.resource = get_sampler_desc(ctx, instr->variables[0],
                                         AC_DESC_IMAGE, NULL, true, false);
        LLVMValueRef res;
        const nir_variable *var = instr->variables[0]->var;
        const struct glsl_type *type = glsl_without_array(var->type);
-       bool da = glsl_sampler_type_is_array(type) ||
-                 glsl_get_sampler_dim(type) == GLSL_SAMPLER_DIM_CUBE ||
-                 glsl_get_sampler_dim(type) == GLSL_SAMPLER_DIM_3D;
 
        if (glsl_get_sampler_dim(type) == GLSL_SAMPLER_DIM_BUF)
                return get_buffer_size(ctx,
 
        struct ac_image_args args = { 0 };
 
-       args.da = da;
+       args.da = glsl_is_array_image(type);
        args.dmask = 0xf;
        args.resource = get_sampler_desc(ctx, instr->variables[0], AC_DESC_IMAGE, NULL, true, false);
        args.opcode = ac_image_get_resinfo;