This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Fix PR target/22585


Hello!

  This patch fixes another problem with 80387 XFmode compares. This problem is
triggered for XFmode comparisons with integer arguments placed in memory.
ix86_prepare_fp_compare_args() tried to outsmart itself by putting all operands
in registers. This is true for FP operands, but 

(float:XF (mem/i:SI (plus:SI (reg/f:SI 6 bp)
            (const_int 20 [0x14])) [0 i+0 S4 A32]))

operands should be left untouched.

The testcase from the PR:

int foo(long double d, int i)
{
  if (d == (long double)i)
    return 1;
}

when compiled with 'gcc -O2 -ffast-math -march=i386 -fomit-frame-pointer' produces:

foo:
        fldt    4(%esp)
        ficompl 16(%esp)
        fnstsw  %ax
        testb   $64, %ah
        jne     .L7
        ret 

Note the ficompl insn that is generated only for TARGET_USE_HIMODE_FIOP and
TARGET_USE_SIMODE_FIOP targets (i386 and i486).

Patch is bootstrapeed on i686-pc-linux-gnu, regtested for c,c++.
(I have no CVS access, so someone should commit this patch, if OK).

BTW: Thanks to Volker for his work on providing excellent testcases!

2005-07-22  Uros Bizjak  <uros@kss-loka.si>

	PR target/22585
	* config/i386/i386.c (ix86_prepare_fp_compare_args): Do not
	force integer op1 into register for XFmode compares.

Uros.

Attachment: pr22585.diff
Description: Binary data


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]