News for hackers. Stuff that matters.
Re:“What the Hardware Does” Is Not What Your Program Does: U... by lmm on Sunday July 14, 2019 @05:23PM (#20436144)
> Now we have, mostly academics from what I've noticed, that are taking the language farther and farther away from reality; focusing only on something uselessly abstract, completely ignoring the practical consequences of what they're doing. Compilers are becoming increasingly hostile to programmers.

I don't think it's the academics, it's the compiler implementers - driven by wanting to win at benchmarks. Our industry is absurdly focused on "performance" over all else (even correctness). But then again, those who care about other things moved on to non-C languages years or decades ago.

Re:“What the Hardware Does” Is Not What Your Program Does: U... by roca on Sunday July 14, 2019 @06:03PM (#20436445)
Indeed, it's compiler implementors, not academics.

However, the performance impact of optimizations that take advantage of UB is not known, and is potentially very large. It would be a very interesting experiment to modify a C/C++ compiler so that every C/C++ program has defined semantics in terms of a simple array-of-bytes abstract machine, and see how much slower the generated code is compared to the regular compiler.

Re:“What the Hardware Does” Is Not What Your Program Does: U... by userbinator on Sunday July 14, 2019 @06:46PM (#20436750)
It would be a very interesting experiment to modify a C/C++ compiler so that every C/C++ program has defined semantics in terms of a simple array-of-bytes abstract machine, and see how much slower the generated code is compared to the regular compiler.

Alternatively, look at compilers like Intel's ICC --- it has historically been one of the best at code generation, yet it's not known for having anywhere near the same level of UB-craziness as Clang (or GCC, to a lesser extent). The same has been my experience with MSVC, at least the earlier versions.

Re:“What the Hardware Does” Is Not What Your Program Does: U... by pcwalton on Sunday July 14, 2019 @09:14PM (#20437375)
On the contrary, ICC doesn't even implement IEEE 754 correctly by default [1], for performance. This is way more aggressive than GCC or Clang.

[1]: https://hal.archives-ouvertes.fr/hal-00128124v5/document

Re:“What the Hardware Does” Is Not What Your Program Does: U... by BeeOnRope on Sunday July 14, 2019 @11:39PM (#20437946)
Uh, ICC does some crazy things to get some of its performance, such as making transformations not allowed by the standard (inventing writes), in order to get better vectorization.

So in some respects ICC is very aggressive.

Re:“What the Hardware Does” Is Not What Your Program Does: U... by gameswithgo on Sunday July 14, 2019 @06:10PM (#20436515)
our industry mainly uses javascript, we aren’t focused on performance at all
Re:“What the Hardware Does” Is Not What Your Program Does: U... by wvenable on Monday July 15, 2019 @01:33AM (#20438396)
Yet the C/C++/ASM in JavaScript runtimes are heavily optimized for performance.
Re:“What the Hardware Does” Is Not What Your Program Does: U... by saagarjha on Monday July 15, 2019 @12:53AM (#20438239)
Compiler implementers are often academics, or at least a lot likely to be higher on the ivory tower than their users are.
Re:“What the Hardware Does” Is Not What Your Program Does: U... by ralfjung on Monday July 15, 2019 @06:58AM (#20439593)
Which major compiler is mostly implemented by academics? Neither GCC nor LLVM, for sure.

Us academics do have a lot of "fun" figuring out a way to put what the compiler developers do on solid footing [1]. But this is a game of whack-a-mole that will never end: each time we find a way to formally approach some new crazy optimization they came up with, and help them weed out all the bugs that were caused by not carefully thinking through all the implications [2], the next crazy optimization comes up [3].

[1]: https://people.mpi-sws.org/~jung/twinsem/twinsem.pdf

[2]: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=65752, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=82282, https://bugs.llvm.org/show_bug.cgi?id=35229, https://bugs.llvm.org/show_bug.cgi?id=34548

[3]: https://bugs.llvm.org/show_bug.cgi?id=21725, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=57359