[LLVMdev] Loop-specific optimizations

Ralf Karrenberg Chareos at gmx.de
Sat Apr 6 00:26:41 PDT 2013


Hi Tim,

On 05.04.2013 11:48, Tim Besard wrote:
>> we at Saarland University are working on something similar to what you
>> are describing. In principle, we enhance Clang by an attribute that
>> allows to specify what transformation phases should be run on the
>> annotated construct (currently functions, compound statements, or loops)
>> and in what order.
> That definitely sounds interesting. Do you add these attributes to the
> bytecode, or how does opt decide which transformations to apply? This
> because our approach, attaching metadata to loop latches, is quite
> fragile; loop latches can easily get destroyed or transformed during
> optimization.

We do this in the front end already:

void test_noise(int x, int* in, int* out)
{
     __attribute__((noise("inline(fn) licm wfv-vectorize(4) unroll(4)")))
     for (int i=0; i<16; ++i)
     {
       out[i] = in[i] + fn(x);
     }
}

This results in IR similar to this code:

void test_noise_result(int x, int* in, int* out)
{
   // Code of "fn" (assuming it was loop invariant).
   int F = ...

   out[0-3]   = <in[0],in[1],in[2],in[3]> + <F,F,F,F>;
   out[4-7]   = <in[4],in[5],in[6],in[7]> + <F,F,F,F>;
   out[8-11]  = <in[8],in[9],in[10],in[11]> + <F,F,F,F>;
   out[12-15] = <in[12],in[13],in[14],in[15]> + <F,F,F,F>;
}

>> Will you be at the LLVM Euro Conference? We will have a lightning talk
>> and poster on the topic there.
> Sadly no, I missed the call for participation. Are the talks going to be
> videotaped, or will proceedings be published? Or could you, if possible,
> send over a working paper or something similar?

I don't think that the lightning talks will be videotaped since they are 
only 5 minutes long - but I may be wrong. There are also no proceedings, 
and we don't have anything ready except some examples.
However, if you are interested, we could talk about giving you access to 
an alpha version - it will be open source eventually, anyway.

Cheers,
Ralf



More information about the llvm-dev mailing list