Richard Biener <richard.guent...@gmail.com> writes: >>> E.g. for the attached microbenchmark I get: >>> >>> Time taken, normalised to VERSION==1 >>> >>> VERSION==1: 1.000 >>> VERSION==2: 1.377 >>> VERSION==3: 3.202 (1.638 with -minline-all-stringops) >>> VERSION==4: 4.242 (2.921 with -minline-all-stringops) >>> VERSION==5: 4.526 >>> VERSION==6: 4.543 >>> VERSION==7: 10.884 >>> >>> where the results for 5 vs. 6 are in the noise. >>> >>> The 5->4 gain is by doing the buffering ourselves. The 4->3 gain is >>for >>> keeping track of the string length rather than recomputing it each >>time. >>> >>> This suggests that if we're serious about trying to speed up the asm >>output, >>> it would be worth adding an equivalent of LLVM's StringRef that pairs >>a >>> const char * string with its length. >> >>I've thought a tiny bit about working on that, so its nice to have >>data. > > Tree identifiers have an embedded length. > So its all about avoidibg this target hook mangling the labels.
Yeah, and register names start out as C strings where the length is known at compile time. Strings that result from sprintf have a length given by the sprintf return value. I think in practice most strings in GCC have (or had) a known length, and the nice thing about StringRef-like classes is that they abstract away the source of the length. Even if we do have to use strlen, the class makes sure we only calculate it once per object rather than once per use. Thanks, Richard