[llvm-commits] r55638 - /llvm/trunk/include/llvm/Function.h

Duncan Sands baldrick at free.fr
Fri Sep 26 02:37:43 PDT 2008


> 	define void @S() notes ("x86.sse3") { ... }
> 
> Here, the intent is simple - function S will run on a processor which  
> has sse3 support.
> 
> 	define void @NS() notes ("x86.no-sse") { ... }
> 
> Again, the intent is clear and simple - function NS is intended to run  
> on a processor that does not have SSE support. Do not use SSE  
> instructions.
> 
> 
> Now,
> 
> - if S calls NS then what to do about these notes ?
> 
> 	Simple. S absorbs code from NS. After inlining you don't see any  
> trace of NS inside S. And function S will run on a processor that has  
> sse3 instructions so code generator is free to use sse3 instructions  
> for the code copied from function NS.

This is ok as long as no-sse was not needed for correctness.  Not
sure how it could be required for correctness, maybe someone with
more imagination can come up with a scenario...

> - what if NS calls S ?
> 
> 	Simple. After inlining, NS will run on a processor that has no sse  
> support. So, inline S into NS only if code generator will not be  
> forced to use SSE instructions for the code copied from S.

So the inliner needs to know all about how codegen works?
I don't think Chris is going to like that!  This doesn't
seem simple to me.

> If XYZ calls S and NS then once again, XYZ's notes win.

And could result in a huge performance loss.  And it is a loss:
it was ok to run S using sse instructions (that's why the
function was marked "sse"!), but now sse isn't being used due
to inlining...

How about this instead: have sse be a tri-state
"sse", "no-sse" or don't care.  Have the inliner
refuse to inline function B into function A if
they have conflicting notes ("sse" conflicts with
"no-sse", but "don't care" doesn't conflict with
anything).  If function A had the "don't-care"
note then replace it with function B's note.

Thus:
  A is "don't care", B is "sse" -> B inlined into A and A becomes "sse"
  A is "sse", B is don't care -> B inlined into A and A stays "sse"
etc

Ciao,

Duncan.



More information about the llvm-commits mailing list