radeonsi: add a debug flag for unsafe math LLVM optimizations
authorMarek Olšák <marek.olsak@amd.com>
Fri, 10 Jun 2016 20:43:29 +0000 (22:43 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 21 Jun 2016 11:52:05 +0000 (13:52 +0200)
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
src/gallium/drivers/radeon/r600_pipe_common.c
src/gallium/drivers/radeon/r600_pipe_common.h
src/gallium/drivers/radeonsi/si_shader.c

index fa9f70d33badb33397c921f1c7572839715020ea..5d4a67997290f9de05fa06571421a79742a5d924 100644 (file)
@@ -482,6 +482,7 @@ static const struct debug_named_value common_debug_options[] = {
        { "sisched", DBG_SI_SCHED, "Enable LLVM SI Machine Instruction Scheduler." },
        { "mono", DBG_MONOLITHIC_SHADERS, "Use old-style monolithic shaders compiled on demand" },
        { "noce", DBG_NO_CE, "Disable the constant engine"},
+       { "unsafemath", DBG_UNSAFE_MATH, "Enable unsafe math shader optimizations" },
 
        DEBUG_NAMED_VALUE_END /* must be last */
 };
index fb6d1a56d12cd8fe4f8671b782225eac305092a1..c0e4282c23f899b7776aca2681f6c8f644a5597f 100644 (file)
@@ -99,6 +99,7 @@
 #define DBG_SI_SCHED           (1llu << 46)
 #define DBG_MONOLITHIC_SHADERS (1llu << 47)
 #define DBG_NO_CE              (1llu << 48)
+#define DBG_UNSAFE_MATH                (1llu << 49)
 
 #define R600_MAP_BUFFER_ALIGNMENT 64
 #define R600_MAX_VIEWPORTS        16
index 6dc4985f94f0d9b149092a68518a41dde8d78496..bba6a55df95d1e15109d213e5d32bab280afd597 100644 (file)
@@ -5255,6 +5255,22 @@ static void si_create_function(struct si_shader_context *ctx,
                else
                        LLVMAddAttribute(P, LLVMInRegAttribute);
        }
+
+       if (ctx->screen->b.debug_flags & DBG_UNSAFE_MATH) {
+               /* These were copied from some LLVM test. */
+               LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
+                                                  "less-precise-fpmad",
+                                                  "true");
+               LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
+                                                  "no-infs-fp-math",
+                                                  "true");
+               LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
+                                                  "no-nans-fp-math",
+                                                  "true");
+               LLVMAddTargetDependentFunctionAttr(ctx->radeon_bld.main_fn,
+                                                  "unsafe-fp-math",
+                                                  "true");
+       }
 }
 
 static void create_meta_data(struct si_shader_context *ctx)