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

Yingwei Zheng via llvm-commits llvm-commits at lists.llvm.org
Sat Apr 11 06:53:04 PDT 2026


https://github.com/dtcxzyw commented:

The commuted pattern should be covered:
```
define i32 @sadd_min_max_assoc(i32 %x, i32 %y, i32 %z) {
  %min = call i32 @llvm.smin.i32(i32 %x, i32 %y)
  %lhs = add i32 %z, %min
  %max = call i32 @llvm.smax.i32(i32 %x, i32 %y)
  %ret = add i32 %max, %lhs
  ret i32 %ret
}
```

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


More information about the llvm-commits mailing list