[Mesa-dev] [PATCH] Reorder LLVM passes, running mem2reg earlier.

Török Edwin edwintorok at gmail.com
Mon May 3 09:48:18 PDT 2010


On 2010-05-03 19:37, José Fonseca wrote:
> On Mon, 2010-05-03 at 09:20 -0700, Török Edwin wrote:
>> Do the shaders need strict IEEE 754 math? 
> 
> I doubt. We already use -ffast-math in when compiling mesa.
> 
> -ffast-math tipically optimizes by leaving intermediate values in the
> x86 FP stack which is wider, so it is non conformant due to the extra
> precision. But we do almost everything with SIMD operations, so there is
> little to be gained I think. Also on 64bit the default is to use the
> partial SIMD instructions for scalars.

Well -ffast-math should also allow for other optimizations, using
associativity for example, which can't be done by default since the
strict IEEE FP operations are not associative :(

> 
>> Or can c+b+a be rewritten as
>> a+b+c for example?
> 
> I don't know about OpenCL/Cuda/D3D Compute, but I'm positive that cannot
> matter for GL/D3D. I know people are successfully doing GPGPU on graphic
> hardware, but the graphics APIs aren't that precise. And even when they
> do, drivers/hardware often cuts some corners.

I opened an enhancement bug in LLVM a while ago about FP optimization
opportunities missed with -ffast-math (which would probably become
another pass that you can add to the passmanager):
http://llvm.org/bugs/show_bug.cgi?id=4637

Maybe someone should look at the LLVM IR created by llvmpipe, and see
what could be optimized by LLVM and is not done, and add some comments
to that bug (or open another).

I am unlikely to work on this (I don't have much experience with FPU/SSE
FP code), but maybe someone else will.

Best regards,
--Edwin


More information about the mesa-dev mailing list