PR 19653 fix and SSE float->double conversions

Uros Bizjak ubizjak@gmail.com
Tue Apr 4 14:25:00 GMT 2006


Hello!

I have compiled the testcase below that produces some unnecessary
moves in SSE float->double conversions
(http://gcc.gnu.org/ml/gcc-patches/2005-11/msg00243.html), that was
claimed to be fixed by PR19653 fix.

--cut here--
void test_fp (float *a, double *b)
{
  int i;

  for (i = 0; i < 4; i++)
    b[i] = (double) a[i];
}
--cut here--

However, current SVN gcc (that includes PR19653 fix) still produces
(gcc -O2 -msse2 -mfpmath=sse):

--cut here--test_fp:
        pushl   %ebp
        movl    $2, %eax
        movl    %esp, %ebp
        movl    8(%ebp), %ecx
        movl    12(%ebp), %edx
        movss   (%ecx), %xmm0               << this is not needed
        cvtss2sd        %xmm0, %xmm0
        movsd   %xmm0, (%edx)
.L2:
        movss   -4(%ecx,%eax,4), %xmm0  << this is not needed
        cvtss2sd        %xmm0, %xmm0
        movsd   %xmm0, -8(%edx,%eax,8)
        addl    $1, %eax
        cmpl    $5, %eax
        jne     .L2
        popl    %ebp
        ret
--cut here--

Attached patch, re-diffed to current SVN fixes this problem, and
following code is produced:

--cut here--
test_fp:
        pushl   %ebp
        movl    $2, %eax
        movl    %esp, %ebp
        movl    8(%ebp), %ecx
        movl    12(%ebp), %edx
        cvtss2sd        (%ecx), %xmm0
        movsd   %xmm0, (%edx)
.L2:
        cvtss2sd        -4(%ecx,%eax,4), %xmm0
        movsd   %xmm0, -8(%edx,%eax,8)
        addl    $1, %eax
        cmpl    $5, %eax
        jne     .L2
        popl    %ebp
        ret
-- cut here--

An analysis of this problem could be found at
http://gcc.gnu.org/ml/gcc-patches/2005-11/msg00243.html.

2006-04-04  Uros Bizjak  <uros@kss-loka.si>

        * config/i386/i386.md (extendsfdf2, extendsfxf2, extenddfxf2): Do not
        force operand1 to register if both operands are memory operands.
        (*extendsfdf2_mixed, *extendsfdf2_sse, *extendsfdf2_i387)
        (*extendsfxf2_i387, *extenddfxf2_i387): Do not disable pattern
        if both operands are memory operands.
        (truncdfsf2): Do not force operand1 to register if both operands
        are memory operands.

 The patch was regtested on i686-pc-linux-gnu for c and c++ with no
new failures.

Uros.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cvt.diff
Type: application/octet-stream
Size: 2995 bytes
Desc: not available
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20060404/77d69ec2/attachment.obj>


More information about the Gcc-patches mailing list