[llvm] [InstCombine] Reassociate commutative binops over select/phi/minmax (PR #187493)
Yingwei Zheng via llvm-commits
llvm-commits at lists.llvm.org
Sun May 24 08:38:30 PDT 2026
================
@@ -522,6 +522,17 @@ class LLVM_LIBRARY_VISIBILITY InstCombinerImpl final
/// or commutative.
bool SimplifyAssociativeOrCommutative(BinaryOperator &I);
+ /// If InnerVal1 and OuterVal form a symmetric pair, and "op" is commutative:
+ /// "(InnerVal0 op InnerVal1) op OuterVal" ==> "(X op' Y) op InnerVal0".
+ /// "OuterVal op (InnerVal0 op InnerVal1)" ==> "InnerVal0 op (X op' Y)".
+ /// X and Y are the inputs to the symmetric pair. "op'" indicates that
+ /// InnerOp will have its poison-generating flags dropped. Warning:
+ /// associativity not checked.
----------------
dtcxzyw wrote:
I guess only `InnerOp.isAssociative() && InnerOp.hasOneUse()` should be checked by the callee.
https://github.com/llvm/llvm-project/pull/187493
More information about the llvm-commits
mailing list