--- Comment #10 from Marc Glisse <glisse at gcc dot gnu.org> ---
Flags like -ftrapping-math can prevent gcc from folding at compile-time when
the result is infinite (or maybe it always refuses to fold in that case). In
your example, gcc generates a runtime call to __muldc3 in main. The behavior
with -fno-trapping-math is a bit surprising. CCP folds the division but not the
multiplication (not even with -ffast-math)). CPLXLOWER turns it into __muldc3,
and DOM2 folds that to a (bad?) constant.
So in some sense, when gcc fails to fold to a constant, then we go to the
runtime behavior, and gcc can still fold that one to a constant (not as good as
what it could get in the first round).