This patch allows LICM to reassociate and hoist following expressions:
loop: %sum = add nsw %iv, %C1 %cmp = icmp <signed pred> %sum, C2
where C1 and C2 are loop invariants. The reassociated version looks like
preheader: %inv_sum = C2 - C1 ... loop: %cmp = icmp <signed pred> %iv, %inv_sum
In order to prove legality, we need both initial addition and the newly created subtraction
to happen without overflow.
Any comments?
Why LHS invariant is not interested to you? Covered in other place? Assert instead of if?
Is hasOneUse a cost model? We want to remove original add?