Hacker News new | ask | show | jobs
by idiotsecant 15 days ago
There is evidence that LLMs are capable of making assembly that runs a great deal more efficiently than the compiler can manage on its own.
4 comments

This has got to be the craziest AI-shill sentence I have heard in a long time.

How can a generic LLM generate better assembly than a dedicated compiler, whose sole purpose is to generate assembly code. With people pedantically adding every optimization imaginable and unimaginable to produce the most efficient code possible. And you have the audacity to say LLMs, which write garbage non-trivial amount of time, are capable of producing better assembly.

This has got to be either a masterful ragebait, or a person with very low knowledge of modern compilers, because even an LLM would not write something so stupid as this.

One simple thing that LLM's doesn't have to do is use a calling convention. Compilers need to use them, at least to some extent because it's not known at compile time who will link against this function in the future. Humans kinda need them because it's a lot of mental load when everything is custom. But for a sufficiently smart llm, noticing a register doesn't need to be preserved because there is only two callers and neither of them care about it might be doable.
Agreed. "Evidence" in this case is a weasel word that could be anything. Misconfigured LLVM? Old/unsupported GCC target? Doesn't matter, look at the evidence of great success! This 10kb assembly loop has a 44,000% speedup versus compiling with automatic vectorization disabled!

LLMs generating "assembly that runs a great deal more efficiently" is a ludicrous claim that cannot be substantiated outside PEBCAK situations.

There are a ton of optimization opportunities that hinge on the intent of a piece of code which static compilers can never detect at scale. LLMs can actually navigate that and write surprisingly optimal assembly.

I've had all my side projects being written in x64 for the last 6 months and it is shockingly effective.

They can navigate that, if specifically targeted towards that, with proper adversarial reviews (including human reviews).

The question is, if one takes their time and has enough competence to do that.

The purpose of an optimizing compiler is not merely to produce efficient assembly. The goal of an optimizing compiler is to produce efficient assembly while confidently preserving a program's observable logical semantics. Asking an LLM to spit out raw unstructured assembly based on inferred context from a specification given in English is a contender for one of the worst ideas I have ever heard; I award you no points, and may God have mercy on your soul.
Now imagine doing this for some system which actually matters and can cost lives if implemented incorrectly. That would be scary.
Code is code my dude. If an LLM can turn English into Python, there's really no reason it can't do assembly. Assembly is not magic, it's just code that humans find difficult to grok. LLMs, it would seem, don't have the same kind of trouble understanding assembly that humans do.

Have you ever compiled something by hand? You should try sometime, it's an illuminating experience. Humans find it hard because you have to remember a lot of details while simultaneously paying attention to a different large set of information while also generating instructions. It's tough, but not impossible, it takes humans a lot of time and effort. How might a computer fare if it could remember everything and pay attention to multiple inputs and outputs at once? That's what an LLM does.

Do you have references ?