[PATCH] Fix PR target/22585

Uros Bizjak uros.bizjak@kss-loka.si
Fri Jul 22 12:19:00 GMT 2005


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.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: pr22585.diff
Type: application/octet-stream
Size: 883 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20050722/8729ff7d/attachment.obj>


More information about the Gcc-patches mailing list