# Pastebin 2k1n5Xzc diff --git a/src/amd/llvm/ac_nir_to_llvm.c b/src/amd/llvm/ac_nir_to_llvm.c index a4914db94302..9c0458d13525 100644 --- a/src/amd/llvm/ac_nir_to_llvm.c +++ b/src/amd/llvm/ac_nir_to_llvm.c @@ -329,10 +329,24 @@ static LLVMValueRef emit_f2f16(struct ac_llvm_context *ctx, LLVMValueRef src0) return result; } +static LLVMValueRef block_range_analysis(struct ac_llvm_context *ctx, LLVMValueRef val) +{ + assert(LLVMTypeOf(val) == ctx->i32); + LLVMTypeRef ftype = LLVMFunctionType(ctx->i32, &ctx->i32, 1, false); + LLVMValueRef inlineasm = LLVMConstInlineAsm(ftype, "", "=v,0", false, false); + return LLVMBuildCall2(ctx->builder, ftype, inlineasm, &val, 1, ""); +} + static LLVMValueRef emit_umul_high(struct ac_llvm_context *ctx, LLVMValueRef src0, LLVMValueRef src1) { LLVMValueRef dst64, result; + + if (LLVMIsConstant(src0)) + src1 = block_range_analysis(ctx, src1); + else + src0 = block_range_analysis(ctx, src0); + src0 = LLVMBuildZExt(ctx->builder, src0, ctx->i64, ""); src1 = LLVMBuildZExt(ctx->builder, src1, ctx->i64, ""); @@ -346,6 +360,12 @@ static LLVMValueRef emit_imul_high(struct ac_llvm_context *ctx, LLVMValueRef src LLVMValueRef src1) { LLVMValueRef dst64, result; + + if (LLVMIsConstant(src0)) + src1 = block_range_analysis(ctx, src1); + else + src0 = block_range_analysis(ctx, src0); + src0 = LLVMBuildSExt(ctx->builder, src0, ctx->i64, ""); src1 = LLVMBuildSExt(ctx->builder, src1, ctx->i64, "");