diff --git a/src/amd/llvm/ac_llvm_build.c b/src/amd/llvm/ac_llvm_build.c index 5d8da90b6f1..66d26406c97 100644 --- a/src/amd/llvm/ac_llvm_build.c +++ b/src/amd/llvm/ac_llvm_build.c @@ -412,54 +412,26 @@ void ac_build_optimization_barrier(struct ac_llvm_context *ctx, LLVMValueRef *pg LLVMTypeRef ftype = LLVMFunctionType(ctx->voidt, NULL, 0, false); LLVMValueRef inlineasm = LLVMConstInlineAsm(ftype, code, "", true, false); LLVMBuildCall2(builder, ftype, inlineasm, NULL, 0, ""); - } else if (LLVMTypeOf(*pgpr) == ctx->i32) { - /* Simple version for i32 that allows the caller to set LLVM metadata on the call - * instruction. */ - LLVMTypeRef ftype = LLVMFunctionType(ctx->i32, &ctx->i32, 1, false); - LLVMValueRef inlineasm = LLVMConstInlineAsm(ftype, code, constraint, true, false); + } else { + LLVMTypeRef old_type = LLVMTypeOf(*pgpr); - *pgpr = LLVMBuildCall2(builder, ftype, inlineasm, pgpr, 1, ""); - } else if (LLVMTypeOf(*pgpr) == ctx->i16) { - /* Simple version for i16 that allows the caller to set LLVM metadata on the call - * instruction. */ - LLVMTypeRef ftype = LLVMFunctionType(ctx->i16, &ctx->i16, 1, false); - LLVMValueRef inlineasm = LLVMConstInlineAsm(ftype, code, constraint, true, false); + if (old_type == ctx->i1) + *pgpr = LLVMBuildZExt(builder, *pgpr, ctx->i32, ""); + + if (old_type == LLVMVectorType(ctx->i16, 3)) + *pgpr = ac_build_expand_to_vec4(ctx, *pgpr, 4); - *pgpr = LLVMBuildCall2(builder, ftype, inlineasm, pgpr, 1, ""); - } else if (LLVMGetTypeKind(LLVMTypeOf(*pgpr)) == LLVMPointerTypeKind) { LLVMTypeRef type = LLVMTypeOf(*pgpr); LLVMTypeRef ftype = LLVMFunctionType(type, &type, 1, false); LLVMValueRef inlineasm = LLVMConstInlineAsm(ftype, code, constraint, true, false); *pgpr = LLVMBuildCall2(builder, ftype, inlineasm, pgpr, 1, ""); - } else { - LLVMTypeRef ftype = LLVMFunctionType(ctx->i32, &ctx->i32, 1, false); - LLVMValueRef inlineasm = LLVMConstInlineAsm(ftype, code, constraint, true, false); - LLVMTypeRef type = LLVMTypeOf(*pgpr); - unsigned bitsize = ac_get_elem_bits(ctx, type); - LLVMValueRef vgpr = *pgpr; - LLVMTypeRef vgpr_type; - unsigned vgpr_size; - LLVMValueRef vgpr0; - if (bitsize < 32) - vgpr = LLVMBuildZExt(ctx->builder, vgpr, ctx->i32, ""); + if (old_type == ctx->i1) + *pgpr = LLVMBuildTrunc(builder, *pgpr, old_type, ""); - vgpr_type = LLVMTypeOf(vgpr); - vgpr_size = ac_get_type_size(vgpr_type); - - assert(vgpr_size % 4 == 0); - - vgpr = LLVMBuildBitCast(builder, vgpr, LLVMVectorType(ctx->i32, vgpr_size / 4), ""); - vgpr0 = LLVMBuildExtractElement(builder, vgpr, ctx->i32_0, ""); - vgpr0 = LLVMBuildCall2(builder, ftype, inlineasm, &vgpr0, 1, ""); - vgpr = LLVMBuildInsertElement(builder, vgpr, vgpr0, ctx->i32_0, ""); - vgpr = LLVMBuildBitCast(builder, vgpr, vgpr_type, ""); - - if (bitsize < 32) - vgpr = LLVMBuildTrunc(builder, vgpr, type, ""); - - *pgpr = vgpr; + if (old_type == LLVMVectorType(ctx->i16, 3)) + *pgpr = ac_extract_components(ctx, *pgpr, 0, 3); } }