4 ms·
It does make sense that ChatGPT can beat gcc (or any compiler really); the compiler is forced to optimise code so that it still appears to work as if it's the s
by dwattttt 3y ago
It does make sense that ChatGPT can beat gcc (or any compiler really); the compiler is forced to optimise code so that it still appears to work as if it's the source you wrote. Most importantly, if there are observable side-effects, compilers must preserve them, even though you know you don't actually care about them. An AI is not bound to preserve those, and can semantically change what you wrote, so long as the one semantic you wanted preserved is still there.
- esrauch 3y agoIt seems like compilers should have an interactive mode where it suggests code that is very similar but not technically perfectly the same that is more efficient and the can accept or decline the alternate version.
- oldmanhorton 3y agoThis sounds like an extension of performance lint rules which many languages/ecosystems already have.
- deleted 3y ago[deleted]
- insanitybit 3y agoA backend compiler is probably not in a good place to do that. Frontends could, however, and there are lots of tools already to make those suggestions for many languages. clippy in rust, for example, will tell you about removing needless allocations, etc, which a backend compiler might have a harder time doing.