radeonsi: use ordered compares for SSG and face selection
authorMarek Olšák <marek.olsak@amd.com>
Sun, 4 Jan 2015 19:45:35 +0000 (20:45 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Wed, 7 Jan 2015 11:06:43 +0000 (12:06 +0100)
Ordered compares are what you have in C. Unordered compares are the result
of negating ordered compares (they return true if either argument is NaN).

That special NaN behavior is completely useless here, and unordered
compares produce horrible code with all stable LLVM versions.
(I think that has been fixed in LLVM git)

Reviewed-by: Michel Dänzer <michel.daenzer@amd.com>
src/gallium/drivers/radeon/radeon_setup_tgsi_llvm.c
src/gallium/drivers/radeonsi/si_shader.c

index c30a9d05e3a89ee21cf89d27287a5822369c4107..dce5b55a4ed48bd8ad75442740207fb1bcafd3a5 100644 (file)
@@ -1107,9 +1107,9 @@ static void emit_ssg(
                cmp = LLVMBuildICmp(builder, LLVMIntSGE, val, bld_base->int_bld.zero, "");
                val = LLVMBuildSelect(builder, cmp, val, LLVMConstInt(bld_base->int_bld.elem_type, -1, true), "");
        } else { // float SSG
-               cmp = LLVMBuildFCmp(builder, LLVMRealUGT, emit_data->args[0], bld_base->base.zero, "");
+               cmp = LLVMBuildFCmp(builder, LLVMRealOGT, emit_data->args[0], bld_base->base.zero, "");
                val = LLVMBuildSelect(builder, cmp, bld_base->base.one, emit_data->args[0], "");
-               cmp = LLVMBuildFCmp(builder, LLVMRealUGE, val, bld_base->base.zero, "");
+               cmp = LLVMBuildFCmp(builder, LLVMRealOGE, val, bld_base->base.zero, "");
                val = LLVMBuildSelect(builder, cmp, val, LLVMConstReal(bld_base->base.elem_type, -1), "");
        }
 
index ba42dab78bbf051f3cb1d622bb63c7dff7a815bd..09d7849a373e28cf003f9b789f89196d320605b2 100644 (file)
@@ -484,7 +484,7 @@ static void declare_input_fs(
                face = LLVMGetParam(main_fn, SI_PARAM_FRONT_FACE);
 
                is_face_positive = LLVMBuildFCmp(gallivm->builder,
-                                                LLVMRealUGT, face,
+                                                LLVMRealOGT, face,
                                                 lp_build_const_float(gallivm, 0.0f),
                                                 "");