On 12/16/2010 3:57 PM, Steven Bosscher wrote:
It looks to me like a case of value profiling, see tree-profile.c, for the various "stringops" optimizations. Unless I misunderstand David's idea here or missing something else, it seems that this kind of optimization should fit in the existing infrastructure without too much effort.
That's good; I hadn't realized that this stuff had all gotten wired up.
It does look like there's code in value-prof.c to do some stuff with string operations. If I'm reading the code correctly, gimple_stringops_transform will take a call to (say) memset with an argument that has a given value 80% of the time and inline the call.
So, yes, you could put more smarts in there to deal with other things. (Right now, it only does mem* routines, and only deals with the constant argument case.) I'd still like to see this handled a lot more generally, but I'm not saying that we should gate incremental progress on a grand plan. We could do both. :-)