[InstCombine] fold add+negate through select into sub
This transform came up as a potential DAGCombine in D133282, so I wanted to see how it escaped in IR too. We do general folds in InstCombiner::SimplifySelectsFeedingBinaryOp() by checking if either arm of a select simplifies when the trailing binop is threaded into the select. So as long as one side simplifies, it's a good fold to combine a negate and add into 1 subtract. This is an example with a zero arm in the select: https://alive2.llvm.org/ce/z/Hgu_Tj And this models the tests with a cancelling 'not' op: https://alive2.llvm.org/ce/z/BuzVV_ Differential Revision: https://reviews.llvm.org/D133369
parent
e6c5d13a
Please register or sign in to comment