================
@@ -1523,6 +1523,34 @@ static Instruction *foldBoxMultiply(BinaryOperator &I) {
   return nullptr;
 }
 
+/// Canonicalize a nested add/sub with a constant on the inner RHS by
+/// sinking the constant to the outer RHS.
+/// (X +/- C) +/- Y  ->  (X +/- Y) +/- C
----------------
MaxGraey wrote:

Yeah, but as far as I know, Reassociate pass only works when the inner and 
outer associative operations are the same. To avoid this conflict, we can stop 
this reassociating in this case. It’s actually strange why this is done, since 
simple binary canonization in LLVM (and not only here) is designed so that a 
constant is always on the right-hand side; therefore, to simplify the constant 
folding and reduce the number of isomorphic forms for matching, it makes sense 
to push constants from the nested expression nodes in the same direction if 
this possible.

https://github.com/llvm/llvm-project/pull/191022
_______________________________________________
cfe-commits mailing list
[email protected]
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to