ac/llvm,radv: implement uadd_sat/iadd_sat

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Samuel Pitoiset <samuel.pitoiset@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12617>
This commit is contained in:
Rhys Perry 2021-08-30 14:02:38 +01:00 committed by Marge Bot
parent f7cdd49a09
commit d6619d0a01
2 changed files with 10 additions and 3 deletions

View file

@ -626,6 +626,15 @@ static void visit_alu(struct ac_nir_context *ctx, const nir_alu_instr *instr)
else
result = LLVMBuildAdd(ctx->ac.builder, src[0], src[1], "");
break;
case nir_op_uadd_sat:
case nir_op_iadd_sat: {
char name[64], type[64];
ac_build_type_name_for_intr(def_type, type, sizeof(type));
snprintf(name, sizeof(name), "llvm.%cadd.sat.%s",
instr->op == nir_op_uadd_sat ? 'u' : 's', type);
result = ac_build_intrinsic(&ctx->ac, name, def_type, src, 2, AC_FUNC_ATTR_READNONE);
break;
}
case nir_op_fadd:
src[0] = ac_to_float(&ctx->ac, src[0]);
src[1] = ac_to_float(&ctx->ac, src[1]);

View file

@ -3495,9 +3495,7 @@ radv_create_shaders(struct radv_pipeline *pipeline, struct radv_device *device,
/* lower ALU operations */
nir_lower_int64(nir[i]);
/* TODO: Implement nir_op_uadd_sat with LLVM. */
if (!radv_use_llvm_for_stage(device, i))
nir_opt_idiv_const(nir[i], 8);
nir_opt_idiv_const(nir[i], 8);
nir_lower_idiv(nir[i],
&(nir_lower_idiv_options){