Re: Missed optimization with endian and alignment independent memory access on x64

2020-02-06 Thread Alexander Monakov
On Thu, 6 Feb 2020, Moritz Strübe wrote: > Why is this so hard optimize? As it's quite a common pattern I'd expect that > there would be at least some hand-coded special case optimizer. (This isn't > criticism - I'm honestly curious.) Or is there a reason gcc shouldn't optimize > this / Why it does

Missed optimization with endian and alignment independent memory access on x64

2020-02-06 Thread Moritz Strübe
Hey, a pattern I see quite often in embedded libraries is to access an array byte wise and shift the bits as needed (as this fixes endianness and alignment issues). If I read two consecutive bytes and left-shift the second by 8, I'd expect the compiler to optimize this to a word read on a x64