There are many research projects out there exploring different ways to use neural networks for compiler optimisation though. My impression is that most of them are using it as a technique to replace heuristics to find candidate solutions for local optimisation problems.
[1] https://www.deepmind.com/blog/alphadev-discovers-faster-sort...
There was an interesting paper a while back before the LLM craze that basically did this for OpenMP programs. You'd feed it the source code to some loop body or whatever, and it would try to pick the right OMP block/loop scheduling parameters from there.
Naturally, if you're training it on open code, you will have to censor the AI so it doesn't use flags like -ffast-math too much. :)