radeonsi: add a debug flag for unsafe math LLVM optimizations
[mesa.git] / src / gallium / drivers / radeonsi / si_shader.c
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)