[LLVMdev] Memset/memcpy: user control of loop-idiom recognizer

David Chisnall
Fri, 05 Dec 2014 17:09:47 -0000

On 5 Dec 2014, at 16:02, Robert Lougher <rob.lougher at gmail.com> wrote:

> The blunt fact is that game
> developers don't like their loops being replaced and they want user
> control.  The real conversation I wanted was what form should this
> user control take.

This doesn't really make sense.  They're writing code in a
high(ish)-level language and passing it to a compiler.  The processor
doesn't understand C, so the compiler *must* replace it with something.
Whether that's a call to a library routine, a scalar loop, a vector loop, or
a completely unrolled sequence depends on heuristics in the compiler.

If they want full control of the machine instructions that are generated, then
there is a mechanism for doing this: inline assembly.

The complaint can't be that it's not generating the same code, it is
that the compiler is generating something with performance characteristics that
are difficult to reason about from the input code.  That's always a danger
when you use an optimising compiler, but it looks like this case is a pretty
extreme example.

David