On Sun, Jun 06, 2021 at 07:59:55AM -0500, Segher Boessenkool wrote:
On Sat, Jun 05, 2021 at 08:41:00PM -0700, Linus Torvalds wrote:
quoted
On Sat, Jun 5, 2021 at 6:29 PM Alan Stern [off-list ref] wrote:
quoted
Interesting. And changing one of the branches from barrier() to __asm__
__volatile__("nop": : :"memory") also causes a branch to be emitted. So
even though the compiler doesn't "look inside" assembly code, it does
compare two pieces at least textually and apparently assumes if they are
identical then they do the same thing.
That's actually a feature in some cases, ie the ability to do CSE on
asm statements (ie the "always has the same output" optimization that
the docs talk about).
So gcc has always looked at the asm string for that reason, afaik.
GCC does not pretend it can understand the asm. But it can see when
two asm statements are identical.
How similar do two asm strings have to be before they are considered
identical? For instance, do changes to the amount of leading or
trailing whitespace matter?
Or what about including an empty assembly statement in one but not the
other?
Alan