[Bug rtl-optimization/83952] [missed optimization] difference calculation for floats vs ints in a loop

rguenth at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Mon Jan 22 08:56:00 GMT 2018


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83952

--- Comment #10 from Richard Biener <rguenth at gcc dot gnu.org> ---
But at least we could perform strength reduction in IVOPTs, replacing

   for (i = 0; i < 100; i++) {
        val = 2 * i;
        a[i] = val;
    }

with

   for (i = 0, j = 0; i < 100; i++, j+=2) {
        val = j;
        a[i] = val;
    }

I guess we might even consider this but reject it based on costs.  Iff we
then could see that j is only used in a int to float conversion we might
evaluate precision/round-off issues and elide the IV to float ...


More information about the Gcc-bugs mailing list