[llvm] [InstCombine] Fold binary op of reductions. (PR #121567)

Mikhail Gudim via llvm-commits llvm-commits at lists.llvm.org
Fri Jan 10 22:45:43 PST 2025


mgudim wrote:

> This will likely cause performance issues unless they are mitigated. There is a combine in the backend that does that same thing, but it gets guarded by shouldReassociateReduction and being in the backend allows the target to pattern recognize before it gets reassociated.

@davemgreen 

Before this combine worked for `Sub` in inst combine - was this an oversight?

I also find it surprising that this will cause a degradation on some targets. Can you please give an example.

I also think `reassociate` is not the right name. Reassociate means `(a + b) + c -> a + (b + c)`. Here I think a better term would be "factor out reduction" as in `a * b + a * c => a * (b + c)`

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


More information about the llvm-commits mailing list