[PATCH] D16836: [CodeGenPrepare] Don't transform select instructions into branches when both of operands are cheap
Hal Finkel via llvm-commits
llvm-commits at lists.llvm.org
Fri Feb 5 10:17:35 PST 2016
hfinkel added a comment.
In http://reviews.llvm.org/D16836#345074, @spatel wrote:
> In http://reviews.llvm.org/D16836#344790, @flyingforyou wrote:
> > Addressed Hal's comment.
> I don't think the patch implements what Hal suggested. You're checking if the direct operands of a "free" instruction are not Arg/Phi/Const. The suggestion was to recurse/loop until we are sure that no operands in the chain are not free.
True, although it occurs to me that we actually can't be more-sophisticated here than the sinking logic. The sinking logic should also sink the whole chain of free instructions (bitcasts, truncs, etc.) to get to the expensive one (should one exist). But it doesn't.
Also, now I feel like I'm missing something. isFormingBranchFromSelectProfitable should only return true if at least one of the operands is expensive or a load. Here you're checking that both operands are free. In that state, isFormingBranchFromSelectProfitable should always have returned false (unless, perhaps, one of them was a "free" load).
More information about the llvm-commits