[Mesa-dev] [PATCH 07/18] gallium/radeon: re-enable unsafe math for graphics shaders

Tom Stellard tom at stellard.net
Tue Jul 28 08:42:12 PDT 2015


On Tue, Jul 28, 2015 at 12:05:42PM +0200, Marek Olšák wrote:
> From: Marek Olšák <marek.olsak at amd.com>
> 
> This reverts commit 4db985a5fa9ea985616a726b1770727309502d81.
> 
> The grass no longer disappears, which was the reason the commit was reverted.
> This might affect tessellation. We'll see.
> 

Hi Marek,

This patch is: Reviewed-by: Tom Stellard <thomas.stellard at amd.com>

Setting this fast-math flags on individual floating-point instructions
may have an even bigger impact, because this function attribute is only
used in a few places.

Here is documentation for the fast-math flags:
http://llvm.org/docs/LangRef.html#fast-math-flags

Currently the only way to set the fast-math flags on instructions is
with the C++ API.  Something like this should work:

LLVMValueRef Inst;
llvm::Instruction *I = llvm:unwrap<llvm::Instruction>(Inst);

// Construct fast-math flags;
llvm::FastMathFlags Flags;
Flags.setUnsafeAlgebra();
// Apply other flags as needed

I->setFastMathFlags(Flags)

I'm not sure which fast-math flags the spec allows, so we would need to
figure that out.

-Tom

> Totals from affected shaders:
> SGPRS: 151672 -> 150232 (-0.95 %)
> VGPRS: 90620 -> 89776 (-0.93 %)
> Code Size: 3980472 -> 3920836 (-1.50 %) bytes
> LDS: 67 -> 67 (0.00 %) blocks
> Scratch: 1357824 -> 1202176 (-11.46 %) bytes per wave
> ---
>  src/gallium/drivers/radeon/radeon_llvm_emit.c | 4 ++++
>  1 file changed, 4 insertions(+)
> 
> diff --git a/src/gallium/drivers/radeon/radeon_llvm_emit.c b/src/gallium/drivers/radeon/radeon_llvm_emit.c
> index 973d6ed..c442c65 100644
> --- a/src/gallium/drivers/radeon/radeon_llvm_emit.c
> +++ b/src/gallium/drivers/radeon/radeon_llvm_emit.c
> @@ -82,6 +82,10 @@ void radeon_llvm_shader_type(LLVMValueRef F, unsigned type)
>  	sprintf(Str, "%1d", llvm_type);
>  
>  	LLVMAddTargetDependentFunctionAttr(F, "ShaderType", Str);
> +
> +	if (type != TGSI_PROCESSOR_COMPUTE) {
> +		LLVMAddTargetDependentFunctionAttr(F, "unsafe-fp-math", "true");
> +	}
>  }
>  
>  static void init_r600_target()
> -- 
> 2.1.4
> 
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list