[llvm] [InstCombine] Reassociate commutative binops over select/phi/minmax (PR #187493)
Mitch Briles via llvm-commits
llvm-commits at lists.llvm.org
Wed Apr 8 08:57:50 PDT 2026
MitchBriles wrote:
> ... but it still needs to create new instructions rather than being folded into an existing value.
My implementation doesn't create any new instructions, right?
```cpp
replaceOperand(*Op0, 0, Pair->first);
replaceOperand(*Op0, 1, Pair->second);
replaceOperand(I, 1, A);
I.swapOperands();
```
Unless we count dropping nsw/nuw as a new instruction? Same with the simple case:
```cpp
if (auto Pair = matchSymmetricPair(I.getOperand(0), I.getOperand(1))) {
replaceOperand(I, 0, Pair->first);
replaceOperand(I, 1, Pair->second);
Changed = true;
}
```
https://github.com/llvm/llvm-project/pull/187493
More information about the llvm-commits
mailing list