https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95740
--- Comment #5 from Hongtao.liu <crazylht at gmail dot com> --- (In reply to Hongtao.liu from comment #4) > It can be fixed by > > 2 files changed, 4 insertions(+), 2 deletions(-) > gcc/config/i386/i386.c | 2 +- > gcc/config/i386/i386.h | 4 +++- > > modified gcc/config/i386/i386.c > @@ -19194,7 +19194,7 @@ ix86_preferred_reload_class (rtx x, reg_class_t > regclass) > > /* Prefer SSE regs only, if we can use them for math. */ > if (SSE_FLOAT_MODE_P (mode) && TARGET_SSE_MATH) > - return SSE_CLASS_P (regclass) ? regclass : NO_REGS; > + return INT_SSE_CLASS_P (regclass) ? regclass : NO_REGS; > > /* Generally when we see PLUS here, it's the function invariant > (plus soft-fp const_int). Which can only be computed into general > modified gcc/config/i386/i386.h > @@ -1283,7 +1283,9 @@ enum reg_class > reg_class_subset_p ((CLASS), FLOAT_REGS) > #define SSE_CLASS_P(CLASS) \ > reg_class_subset_p ((CLASS), ALL_SSE_REGS) > -#define MMX_CLASS_P(CLASS) \ > +#define INT_SSE_CLASS_P(CLASS) \ > + reg_class_subset_p ((CLASS), INT_SSE_REGS) > +#define MMX_CLASS_P(CLASS) \ > ((CLASS) == MMX_REGS) > #define MASK_CLASS_P(CLASS) \ > reg_class_subset_p ((CLASS), ALL_MASK_REGS) > > I'm testing performance impact. orginally, ix86_preferred_reload_class (SFmode, GENERAL_REGS) return NO_REG, and it increase reject by LRA_MAX_REJECT(600) which make it impossible to reload to general_regs. ---------------------cut from lra-constraints.c------------------------ /* Check strong discouragement of reload of non-constant into class THIS_ALTERNATIVE. */ if (! CONSTANT_P (op) && ! no_regs_p && (targetm.preferred_reload_class (op, this_alternative) == NO_REGS || (curr_static_id->operand[nop].type == OP_OUT && (targetm.preferred_output_reload_class (op, this_alternative) == NO_REGS)))) { if (offmemok && REG_P (op)) { if (lra_dump_file != NULL) fprintf (lra_dump_file, " %d Spill pseudo into memory: reject+=3\n", nop); reject += 3; } else { if (lra_dump_file != NULL) fprintf (lra_dump_file, " %d Non-prefered reload: reject+=%d\n", nop, LRA_MAX_REJECT); reject += LRA_MAX_REJECT; } } ------------------------------------------------------- with gcc -O2 test.c -mfpmath=387, trunk gcc can also generate foo(float): movd %xmm0, %eax addl $1, %eax ret