[InstCombine] allow more folds more multi-use selects
The 'and' case showed up in a recent bug report and prevented more follow-on transforms from happening. We could handle more patterns (for example, the select arms simplified, but not to constant values), but this seems like a safe, conservative enhancement. The backend can convert select-of-constants to math/logic in many cases if it is profitable. There is a lot of overlapping logic for these kinds of patterns (see SimplifySelectsFeedingBinaryOp() and FoldOpIntoSelect()), so there may be some opportunity to improve efficiency. There are also optimization gaps/inconsistency because we do not call this code for all bin-opcodes (see TODO for ashr test).
Loading
Please sign in to comment