ac: update and document fast math flags used by radeonsi
authorMarek Olšák <marek.olsak@amd.com>
Thu, 23 Apr 2020 02:38:14 +0000 (22:38 -0400)
committerMarge Bot <eric+marge@anholt.net>
Mon, 27 Apr 2020 11:20:16 +0000 (11:20 +0000)
This should have no effect, because we never use FP division, but
it's safer for the future.

Reviewed-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/4696>

src/amd/llvm/ac_llvm_helper.cpp
src/amd/llvm/ac_llvm_util.h
src/gallium/drivers/radeonsi/si_shader_llvm.c

index 6b4610597ed7a71e01304a9755f33ffb8122ad42..578521a6f2d6405bd2c471c26a2b8a343a2c8287 100644 (file)
@@ -84,8 +84,18 @@ LLVMBuilderRef ac_create_builder(LLVMContextRef ctx,
        case AC_FLOAT_MODE_DEFAULT:
        case AC_FLOAT_MODE_DENORM_FLUSH_TO_ZERO:
                break;
-       case AC_FLOAT_MODE_NO_SIGNED_ZEROS_FP_MATH:
-               flags.setNoSignedZeros();
+
+       case AC_FLOAT_MODE_DEFAULT_OPENGL:
+               /* Allow optimizations to treat the sign of a zero argument or
+                * result as insignificant.
+                */
+               flags.setNoSignedZeros(); /* nsz */
+
+               /* Allow optimizations to use the reciprocal of an argument
+                * rather than perform division.
+                */
+               flags.setAllowReciprocal(); /* arcp */
+
                llvm::unwrap(builder)->setFastMathFlags(flags);
                break;
        }
index 00372476d8efa8d04296696bd1de42eb4f4f4dc8..4cfb3b55388831ae06e8655b2c04702883b13572 100644 (file)
@@ -70,7 +70,7 @@ enum ac_target_machine_options {
 
 enum ac_float_mode {
        AC_FLOAT_MODE_DEFAULT,
-       AC_FLOAT_MODE_NO_SIGNED_ZEROS_FP_MATH,
+       AC_FLOAT_MODE_DEFAULT_OPENGL,
        AC_FLOAT_MODE_DENORM_FLUSH_TO_ZERO,
 };
 
index d8bcb4ad55ce55f752b46731d13b90db5512c8d8..63c9c033ab479727a427e8b5df64e4322aec95ca 100644 (file)
@@ -134,7 +134,7 @@ void si_llvm_context_init(struct si_shader_context *ctx, struct si_screen *sscre
    ctx->compiler = compiler;
 
    ac_llvm_context_init(&ctx->ac, compiler, sscreen->info.chip_class, sscreen->info.family,
-                        AC_FLOAT_MODE_NO_SIGNED_ZEROS_FP_MATH, wave_size, 64);
+                        AC_FLOAT_MODE_DEFAULT_OPENGL, wave_size, 64);
 }
 
 void si_llvm_create_func(struct si_shader_context *ctx, const char *name, LLVMTypeRef *return_types,