Compilers are afraid to optimize around possible UB, even though they can.
Re:Why physicists still use Fortran
by greglindahl on Monday December 19, 2016 @12:36AM
(#13209675)
Having worked with key people from the SGI compiler team, and then competed with Intel / PGI / Sun / gcc on x86, I totally disagree.
I guess I should've looked when I said "Compilers". I only skimmed two and one of them is LLVM.
I totally see UB as a blessing in disguise for optimizer.
Re:Why physicists still use Fortran
by greglindahl on Monday December 19, 2016 @02:15AM
(#13209977)
Usually, yeah. The art is making it debuggable, when the user accidentally strays into UB and needs help not doing that.
Historically, C compilers just couldn't do such a good job at optimising, because C is pretty complex and has loads of undefined behaviour. Also, Fortran compilers have always been optimised for numerical computation.
Recently * , a lot of effort has gone into making C compilers produce very optimised code. In general, this is a good idea because humans are bad at optimising and also remembering every damned Intel vectorisation instruction.
So historically, Fortran was much faster, recently * with compiler advances in e.g. reordering and AMD64, it's possible C compilers beat Fortran compilers.
* edit: adjust your definition of recently to encompass the entire timeframe of Fortran's existance