mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-03 01:18:06 +02:00
ac: add ac_build_umax() and use it where possible
This changes the predicate from LessThan to Equal. Signed-off-by: Samuel Pitoiset <samuel.pitoiset@gmail.com> Reviewed-by: Marek Olšák <marek.olsak@amd.com>
This commit is contained in:
parent
cf88bfa75a
commit
4cb13e9462
3 changed files with 13 additions and 15 deletions
|
|
@ -2042,6 +2042,13 @@ LLVMValueRef ac_build_umin(struct ac_llvm_context *ctx, LLVMValueRef a,
|
|||
return LLVMBuildSelect(ctx->builder, cmp, a, b, "");
|
||||
}
|
||||
|
||||
LLVMValueRef ac_build_umax(struct ac_llvm_context *ctx, LLVMValueRef a,
|
||||
LLVMValueRef b)
|
||||
{
|
||||
LLVMValueRef cmp = LLVMBuildICmp(ctx->builder, LLVMIntUGE, a, b, "");
|
||||
return LLVMBuildSelect(ctx->builder, cmp, a, b, "");
|
||||
}
|
||||
|
||||
LLVMValueRef ac_build_clamp(struct ac_llvm_context *ctx, LLVMValueRef value)
|
||||
{
|
||||
LLVMTypeRef t = LLVMTypeOf(value);
|
||||
|
|
|
|||
|
|
@ -443,6 +443,7 @@ LLVMValueRef ac_build_imin(struct ac_llvm_context *ctx, LLVMValueRef a,
|
|||
LLVMValueRef ac_build_imax(struct ac_llvm_context *ctx, LLVMValueRef a,
|
||||
LLVMValueRef b);
|
||||
LLVMValueRef ac_build_umin(struct ac_llvm_context *ctx, LLVMValueRef a, LLVMValueRef b);
|
||||
LLVMValueRef ac_build_umax(struct ac_llvm_context *ctx, LLVMValueRef a, LLVMValueRef b);
|
||||
LLVMValueRef ac_build_clamp(struct ac_llvm_context *ctx, LLVMValueRef value);
|
||||
|
||||
struct ac_export_args {
|
||||
|
|
|
|||
|
|
@ -277,16 +277,6 @@ static LLVMValueRef emit_bcsel(struct ac_llvm_context *ctx,
|
|||
ac_to_integer_or_pointer(ctx, src2), "");
|
||||
}
|
||||
|
||||
static LLVMValueRef emit_minmax_int(struct ac_llvm_context *ctx,
|
||||
LLVMIntPredicate pred,
|
||||
LLVMValueRef src0, LLVMValueRef src1)
|
||||
{
|
||||
return LLVMBuildSelect(ctx->builder,
|
||||
LLVMBuildICmp(ctx->builder, pred, src0, src1, ""),
|
||||
src0,
|
||||
src1, "");
|
||||
|
||||
}
|
||||
static LLVMValueRef emit_iabs(struct ac_llvm_context *ctx,
|
||||
LLVMValueRef src0)
|
||||
{
|
||||
|
|
@ -754,7 +744,7 @@ static void visit_alu(struct ac_nir_context *ctx, const nir_alu_instr *instr)
|
|||
result = ac_build_imin(&ctx->ac, src[0], src[1]);
|
||||
break;
|
||||
case nir_op_umax:
|
||||
result = emit_minmax_int(&ctx->ac, LLVMIntUGT, src[0], src[1]);
|
||||
result = ac_build_umax(&ctx->ac, src[0], src[1]);
|
||||
break;
|
||||
case nir_op_umin:
|
||||
result = ac_build_umin(&ctx->ac, src[0], src[1]);
|
||||
|
|
@ -1119,8 +1109,8 @@ static void visit_alu(struct ac_nir_context *ctx, const nir_alu_instr *instr)
|
|||
ac_to_float_type(&ctx->ac, def_type), result, src[2]);
|
||||
break;
|
||||
case nir_op_umax3:
|
||||
result = emit_minmax_int(&ctx->ac, LLVMIntUGT, src[0], src[1]);
|
||||
result = emit_minmax_int(&ctx->ac, LLVMIntUGT, result, src[2]);
|
||||
result = ac_build_umax(&ctx->ac, src[0], src[1]);
|
||||
result = ac_build_umax(&ctx->ac, result, src[2]);
|
||||
break;
|
||||
case nir_op_imax3:
|
||||
result = ac_build_imax(&ctx->ac, src[0], src[1]);
|
||||
|
|
@ -1143,9 +1133,9 @@ static void visit_alu(struct ac_nir_context *ctx, const nir_alu_instr *instr)
|
|||
}
|
||||
case nir_op_umed3: {
|
||||
LLVMValueRef tmp1 = ac_build_umin(&ctx->ac, src[0], src[1]);
|
||||
LLVMValueRef tmp2 = emit_minmax_int(&ctx->ac, LLVMIntUGT, src[0], src[1]);
|
||||
LLVMValueRef tmp2 = ac_build_umax(&ctx->ac, src[0], src[1]);
|
||||
tmp2 = ac_build_umin(&ctx->ac, tmp2, src[2]);
|
||||
result = emit_minmax_int(&ctx->ac, LLVMIntUGT, tmp1, tmp2);
|
||||
result = ac_build_umax(&ctx->ac, tmp1, tmp2);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue