What is the name of this code transformation that uses associativity of addition?
According to LLVM it is called &quot;Reassociate expressions&quot; and uses the flag &quot;-reassociate&quot;
According to here:

-reassociate: Reassociate expressions
This pass reassociates commutative expressions in an order that is designed to promote better constant propagation, GCSE, LICM, PRE, etc.
For example: 4 + (x + 5) ⇒ x + (4 + 5)
In the implementation of this algorithm, constants are assigned rank = 0, function arguments are rank = 1, and other values are assigned ranks corresponding to the reverse post order traversal of current function (starting at 2), which effectively gives values in deep loops higher rank than values not in loops.