This an alternate to D87479 that uses LoopInfo when available
to more precisely target the problematic transform. If we
know the fmul lives in a loop then we will only sink the fdiv
if it's not loop invariant. Otherwise, if we don't have any
loop information, or the fmul is not in a loop we only combine
the fmul and fdiv if they are in the same block. Allowing the
transform early in the optimization pipeline (because there
may not be any LoopInfo yet) doesn't seem like a bad thing.
As discussed in D143631, there's a larger issue between
reassociation/combining/LICM because this doesn't solve a more
general problem that we can show in an example with no fdivs:
https://godbolt.org/z/xrs9xfGrf
...but this does manage to avoid the problem in the motivating
test for D143631.
Co-authored-by: Sanjay Patel <spatel@rotateright.com>
nit: there is little value in creating a lambda and using it only once?