On 2/13/25 11:14, Uros Bizjak wrote: > According to [1], the usage of asm pseudo directives in the asm template > can confuse the compiler to wrongly estimate the size of the generated > code. ALTERNATIVE macro expands to several asm pseudo directives, so > its usage in {,try_}cmpxchg{64,128} causes instruction length estimate > to fail by an order of magnitude (the compiler estimates the length of > an asm to be more than 20 instructions). Just curious, but how did you come up with the "20 instructions" number? > This wrong estimate further causes unoptimal inlining decisions for > functions that use these locking primitives. > > Use asm_inline instead of just asm. For inlining purposes, the size of > the asm is then taken as the minimum size, ignoring how many instructions > compiler thinks it is. So, the compiler is trying to decide whether to inline a function or not. The bigger it is, the less likely, it is to be inlined. Since it is over-estimating the size of {,try_}cmpxchg{64,128}, it will avoid inlining it when it _should_ be inlining it. Is that it? Is any of this measurable? Is there any objective data to support that this change is a good one? It's quite possible that someone did the "asm" on purpose because over-estimating the size was a good thing.