A discussion that started at D38037 raised the need for a new reassociation pass, in addition to the existing one.

The existing pass takes a tree of a reassociable operator, and transforms it into a "linear tree", e.g. for addition a_0 + (a_1 + (a_2 + ... (a_n-1 + a_n))...). The tree is built such that the latter operands have lower "ranks". The ranking is such that, for example, constants have rank of zero which means they will be at the end of the tree which will cause them to eventually fold.

The new pass implements another kind of reassociation, something of the form (a_0 + a_1) + (a_2 + a_3) -> (a_0 + a_2) + (a_1 + a_3), which is not supported by the existing pass.

The new pass also limited in numerous ways (hence "Weak"): it will only reassociate a tree compound of two kinds of leaves by putting all the leaves of one kind ("LeafClass") in one subtree and the leaves from the other kind at the second subtree. It will also never change the topography of the tree (unlike the existing reassociate pass which aggressively dictates a new topography). That means, amongst the rest, that this pass never creates new instructions.