[PATCH] D17288: [CodeGenPrepare] Do select to branch transform when cmp's operand is expensive.

Gerolf Hoflehner via llvm-commits llvm-commits at lists.llvm.org
Wed Mar 30 21:12:28 PDT 2016


Gerolf added a subscriber: Gerolf.
Gerolf added a comment.

In response to Sanjay's question: "so I think this is a reasonable way to solve the problem. I'm not sure if we want the default behavior to be opt-out though, but that's simple to change. 
I'd certainly like to hear from others if they think this is a good approach."

It seems the major motivation here is the benchmark gain, and no, it won’t be necessarily simple to change. This optimization could give a sizable gain on multiple architectures, and once in, people will not easily accept a loss when the default is attempted to be changed. If we decide to go for it we should be conscious about it.
I think the machine combiner (in this case it would split the conditional move instructions) would be a more natural place for this optimization. Eventually I see that pass capable of both latency and throughput estimates for possibly a small increase in compile-time. Perhaps a compromise is reasonable by enabling a version of the current patch (assuming no regressions) and starting the work towards a more general solution. I see related questions coming up in other places. For example for some DAGcombines the machine combiner could come up with faster code sequences.

-Gerolf


http://reviews.llvm.org/D17288





More information about the llvm-commits mailing list