[llvm] [InstCombine] Reassociate commutative binops over select/phi/minmax (PR #187493)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 8 08:23:59 PDT 2026
================
@@ -526,6 +526,20 @@ bool InstCombinerImpl::SimplifyAssociativeOrCommutative(BinaryOperator &I) {
Value *B = Op0->getOperand(1);
Value *C = I.getOperand(1);
+ // Form "A op V" when "B op C" is a symmetric pair
+ if (I.isCommutative() && Op0->hasOneUse()) {
+ if (auto Pair = matchSymmetricPair(B, C)) {
+ replaceOperand(*Op0, 0, Pair->first);
----------------
dtcxzyw wrote:
Drop nsw/nuw on Op0: https://alive2.llvm.org/ce/z/SV-deG
https://github.com/llvm/llvm-project/pull/187493
More information about the llvm-commits
mailing list