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

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


On 2010-05-03 19:00, José Fonseca wrote:
> Török,
> 
> Thanks.
> 
> I didn't see as much improvement (most of the stuff I've been playing
> with has actually simple shaders), but I saw no regression so I've
> commited it. We have more benchmarks running continuously from git so
> once the commit goes through them we should have more data.

Thanks.

> 
> Also, do you know any good piece of documentation describing the good
> ordering of passes, or is it just trial/error?

Look in include/llvm/Support/StandardPasses.h for the default ordering
of -O1, -O2, -O3

Mem2reg is good to be run first because it reduces number of
(alloca+load+store), and creates a new LLVM (SSA) value for them.
It also enables further transforms to be smarter (most can't see accross
a load/store).

Now those orderings are for normal C programs, most of those
optimizations may be of little benefit to shaders.
Finding out which optimizers help shaders is a trial/error I think.

Unfortunately LLVM doesn't have any -ffast-math-like optimizers, I think
no CSE/reassoc is done on FP operations by default because that can lead
to wrong results (due to rounding).

Do the shaders need strict IEEE 754 math? Or can c+b+a be rewritten as
a+b+c for example?

Best regards,
--Edwin


More information about the mesa-dev mailing list