3 ms·
Until you profile and find out that the compiler didn't properly optimize and you replace it with a bit hack. You can't look at a particular piece of code in i
by mike_hock 4y ago
Until you profile and find out that the compiler didn't properly optimize and you replace it with a bit hack.
You can't look at a particular piece of code in isolation and judge whether it was optimized prematurely.
- tialaramex 4y agoIf the compiler mis-optimises this... foo.bar(baz); ... in a way which has unacceptable performance don't just replace it with inexplicable nonsense that you happen to know does the right thing in this particular compiler on this particular day for this particular architecture... let tmp = baz << 2; foo |= (tmp ^ 0x34F2A7); ... instead the correct thing is something like this: inline function compiler_hack(foo, bar) { let tmp = bar << 2; foo |= (tmp ^ 0x34F2A7); } // FooCompiler 11.65 mis-optimises foo.bar(baz); for the Axilon 480 compiler_hack(foo, bar);