radeonsi: use new function ac_build_umin for edgeflag clamping
authorNicolai Hähnle <nicolai.haehnle@amd.com>
Sun, 25 Jun 2017 15:56:37 +0000 (17:56 +0200)
committerNicolai Hähnle <nicolai.haehnle@amd.com>
Mon, 31 Jul 2017 12:55:42 +0000 (14:55 +0200)
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
src/amd/common/ac_llvm_build.c
src/amd/common/ac_llvm_build.h
src/gallium/drivers/radeonsi/si_shader.c

index 2dddf44ff854e3336984734fe6033ef08740a8fa..9b939c148e5bafa3d99171c88e45aee4bb2985ef 100644 (file)
@@ -908,6 +908,13 @@ ac_build_umsb(struct ac_llvm_context *ctx,
                               LLVMConstInt(ctx->i32, -1, true), msb, "");
 }
 
+LLVMValueRef ac_build_umin(struct ac_llvm_context *ctx, LLVMValueRef a,
+                          LLVMValueRef b)
+{
+       LLVMValueRef cmp = LLVMBuildICmp(ctx->builder, LLVMIntULE, a, b, "");
+       return LLVMBuildSelect(ctx->builder, cmp, a, b, "");
+}
+
 LLVMValueRef ac_build_clamp(struct ac_llvm_context *ctx, LLVMValueRef value)
 {
        if (HAVE_LLVM >= 0x0500) {
index f25af8b76a89af770d2ad24ae3af557d5939de84..09fd585706adf2887efc851d5adc913861f522eb 100644 (file)
@@ -197,6 +197,7 @@ LLVMValueRef ac_build_umsb(struct ac_llvm_context *ctx,
                          LLVMValueRef arg,
                          LLVMTypeRef dst_type);
 
+LLVMValueRef ac_build_umin(struct ac_llvm_context *ctx, LLVMValueRef a, LLVMValueRef b);
 LLVMValueRef ac_build_clamp(struct ac_llvm_context *ctx, LLVMValueRef value);
 
 struct ac_export_args {
index 2827b9d06a24399198c873d880fcee6291d3707f..473dd95a149bf4c3e85ac3ab0926153ae805ee6f 100644 (file)
@@ -2502,7 +2502,7 @@ static void si_llvm_export_vs(struct lp_build_tgsi_context *bld_base,
                        edgeflag_value = LLVMBuildFPToUI(ctx->gallivm.builder,
                                                         edgeflag_value,
                                                         ctx->i32, "");
-                       edgeflag_value = lp_build_min(&bld_base->int_bld,
+                       edgeflag_value = ac_build_umin(&ctx->ac,
                                                      edgeflag_value,
                                                      ctx->i32_1);