[llvm] [InstCombine] Reassociate commutative binops over select/phi/minmax (PR #187493)

Mitch Briles via llvm-commits llvm-commits at lists.llvm.org
Thu Apr 9 17:31:18 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);
----------------
MitchBriles wrote:

Thanks. Should be fixed now.

https://github.com/llvm/llvm-project/pull/187493


More information about the llvm-commits mailing list