3 ms·
You haven't been able to assume trivial translation of C code to assembly for decades. Then perhaps everyone should continue to do that, and continue to very s
by userbinator 7y ago
You haven't been able to assume trivial translation of C code to assembly for decades.
Then perhaps everyone should continue to do that, and continue to very strongly complain to the compiler-authors who seem to have become absolutely engrossed in blindly following the standard to the letter and completely ignoring the fact that people are wanting C precisely because it's supposed to be close to Asm. But I guess it satiates their egos more to point and laugh... "we're following the standard, fuck you for thinking we care about anything else."
- nly 7y agoIf the standard didn't allow this optimization then GCC would have to emit unaligned access instructions everywhere. If it did that then people who want C to be 'close to the machine' would be complaining about lackluster performance and calling for everything to be written in ASM. The reality is that the abstract machine modeled by C is a long, long way from what modern CPUs actually do, and the C language standards committee seems to have little interest in extending their language
- userbinator 7y agoIf you were compiling for an architecture that doesn't allow unaligned access, then you'd expect unaligned accesses to fault. If you were compiling for an architecture which does, then you'd wouldn't. That's what sane undefined behaviour should be expected to do.
- asveikau 7y ago> The reality is that the abstract machine modeled by C is a long, long way from what modern CPUs actually do, But some modern CPUs fault on unaligned access or make such access slower. (I think Intel is actually sometimes in the latter camp.) I don't get why people label "modern" as a synonym for their pre-existing favorite idea and then demand stuff reflect that "modernity" or else it is totally illegitimate. Seems like some kind of hangup. As some have mentioned in similar discussions, even the x86 machine code does not reflect how the CPU really works, there are things like caching and branch prediction and speculative execution and microcode and ... There is a long list and probably no one person is aware of all the abstractions.
- qppo 7y agoRegardless of what C is or isn't "supposed" to be, it's not close to assembler. It's an abstract machine, and one that is fundamentally different than actual machines today. It would do well for people to remember that before complaining to compiler authors. You're not at the bottom of the stack, you're just a few lowering passes closer than in other languages.