[llvm-commits] [llvm] r150060 - in /llvm/trunk: include/llvm/IntrinsicsX86.td lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86InstrSSE.td

David A. Greene dag at cray.com
Thu Feb 9 14:02:47 PST 2012


Chandler Carruth <chandlerc at google.com> writes:

> I think the primary problem here are the many definitions and
> understandings of what 'intrinsics' mean.

I agree.

> To be clear, I think most of the LLVM developers have been operating
> under the following assumption: intrinsics are a library-means of
> expressing operations very useful or common on a particular system
> which have no in-language formulation. As such, they are just a
> language extension with defined and specified semantics.

I agree here as well.  It just happened to be the only way in the past
to provide a "leave this alone" guarantee.  It's clear now that we need
something else.

> The compiler is then free to interpret them, lower them, optimize, and
> even delete them according to the as-if rules. I think that's
> fundamentally the *right* model, as there is no alternative. If you
> want to express operations on SSE vectors, but would like the compiler
> to have all of its usual freedom, what else can you use besides
> intrinsics?

I think it's perfectly reasonable to say the compiler should be able
to optimize certain kinds of these things.

There's another kind of "intrinsic" which is a source-level construct
provided by many compilers.  I think here the definition is much more
muddy.  Some users expect optimizations, others expect the compiler to
leave them alone.  We need some way of expression both desires in the IR
so that various implementations can translate them the proper way based
on requirements.

> However...
>
> On Thu, Feb 9, 2012 at 10:41 AM, David A. Greene <dag at cray.com> wrote:
>
>     We absolutely need some way to tell LLVM, "leave this alone."  It goes
>     beyond intrinsics even.
>
> This is a very reasonable requirement, and I actually think LLVM has
> exactly the means to deal with it: *volatile* inline asm. This says to
> the compiler, explicitly and without ambiguity, "leave this alone". It
> must not be changed, it must be preserved at all costs.

Ok, if "volatile" on inline asm provides this guarantee and if Duncan's
guesses as to the ease of using them hold up, this should be fine for
us.

If "volatile" doesn't currently provide this guarantee, then we'll have
to add that semantic to the IR.

                                 -Dave




More information about the llvm-commits mailing list