From: Nicolai Hähnle <nicolai.haeh...@amd.com>

---
 src/amd/common/ac_llvm_build.c           | 7 +++++++
 src/amd/common/ac_llvm_build.h           | 1 +
 src/gallium/drivers/radeonsi/si_shader.c | 2 +-
 3 files changed, 9 insertions(+), 1 deletion(-)

diff --git a/src/amd/common/ac_llvm_build.c b/src/amd/common/ac_llvm_build.c
index 0a3cc8a..1f74497 100644
--- a/src/amd/common/ac_llvm_build.c
+++ b/src/amd/common/ac_llvm_build.c
@@ -902,20 +902,27 @@ ac_build_umsb(struct ac_llvm_context *ctx,
        msb = LLVMBuildSub(ctx->builder, LLVMConstInt(ctx->i32, 31, false),
                           msb, "");
 
        /* check for zero */
        return LLVMBuildSelect(ctx->builder,
                               LLVMBuildICmp(ctx->builder, LLVMIntEQ, arg,
                                             LLVMConstInt(ctx->i32, 0, 0), ""),
                               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) {
                LLVMValueRef max[2] = {
                        value,
                        LLVMConstReal(ctx->f32, 0),
                };
                LLVMValueRef min[2] = {
                        LLVMConstReal(ctx->f32, 1),
                };
diff --git a/src/amd/common/ac_llvm_build.h b/src/amd/common/ac_llvm_build.h
index 9ad13cc..264337f 100644
--- a/src/amd/common/ac_llvm_build.h
+++ b/src/amd/common/ac_llvm_build.h
@@ -191,20 +191,21 @@ void ac_build_sendmsg(struct ac_llvm_context *ctx,
                      LLVMValueRef wave_id);
 
 LLVMValueRef ac_build_imsb(struct ac_llvm_context *ctx,
                           LLVMValueRef arg,
                           LLVMTypeRef dst_type);
 
 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 {
        LLVMValueRef out[4];
         unsigned target;
         unsigned enabled_channels;
         bool compr;
         bool done;
         bool valid_mask;
 };
diff --git a/src/gallium/drivers/radeonsi/si_shader.c 
b/src/gallium/drivers/radeonsi/si_shader.c
index 9ddadc1..0e8a601 100644
--- a/src/gallium/drivers/radeonsi/si_shader.c
+++ b/src/gallium/drivers/radeonsi/si_shader.c
@@ -2449,21 +2449,21 @@ handle_semantic:
 
                if (shader->selector->info.writes_psize)
                        pos_args[1].out[0] = psize_value;
 
                if (shader->selector->info.writes_edgeflag) {
                        /* The output is a float, but the hw expects an integer
                         * with the first bit containing the edge flag. */
                        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);
 
                        /* The LLVM intrinsic expects a float. */
                        pos_args[1].out[1] = 
LLVMBuildBitCast(ctx->gallivm.builder,
                                                          edgeflag_value,
                                                          ctx->f32, "");
                }
 
                if (ctx->screen->b.chip_class >= GFX9) {
-- 
2.9.3

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to