[PATCH, i386]: Committed: Fix PR target/22152

Uros Bizjak ubizjak@gmail.com
Sat Mar 8 12:44:00 GMT 2008


Richard Guenther wrote:

> I realize this may be hard, but with all the many tweaking patches for SSE, MMX,
> etc. how do we make sure to not regress in cases we fixed earlier?  So, may I
> suggest you try to enter at least "something" into the testsuite?  For example
> scan-assembler-not ".L6.*ebp.*.L6" (no stack operations between the .L6 loop
> entry and the backedge)?  Maybe a little bit fragile, but at least
> some confidence
> would be there (and some testcases to eventually manually inspect) that
> we won't regress again?
>   

Heh, I _did_ say that "... The testcase will be committed in a separate 
commit, as I have to clean it a bit."

Attached to this message, please find a couple of testcases, derived 
from PR 22152:

- pr22152.c is a compile time test that checks if (long long) value 
stays inside MMX register. Due to the cast to (long long) in the 
mmintrin.h, the value was dragged to and from the memory (-O2 -m32 -msse2):

.L3:
        movl    (%ebx,%eax,8), %esi
        movl    4(%ebx,%eax,8), %edi
        movl    %esi, -24(%ebp)
        movl    %edi, -20(%ebp)
        movq    -24(%ebp), %mm0
        paddq   (%ecx,%eax,8), %mm0
        addl    $1, %eax
        cmpl    %eax, %edx
        movq    %mm0, -24(%ebp)
        movq    -24(%ebp), %mm0
        ja      .L3

 The situation is now much better:

.L3:
        movq    (%ebx,%eax,8), %mm0
        paddq   (%ecx,%eax,8), %mm0
        addl    $1, %eax
        cmpl    %eax, %edx
        ja      .L3

- sse2-mmx.c
This is a runtime test, based on the large testcase from the PR. The 
test should add two huge numbers together using MMX stuff, but 
unfortunately, it doesn't work correctly (carry propagation logic is 
fatally flawed). Attached test fixes this logic, so it can be used to 
increase the runtime coverage of SSE2 based MMX operations.

FWIW, the loop from the testcase is now:

.L3:
        movq    (%esi,%eax,8), %mm2     #* a, _a.37
        movq    (%ebx,%eax,8), %mm3     #* b, _b
        movq    %mm2, %mm0      # D.2452, tmp94
        paddq   %mm3, %mm0      # D.2451, tmp94
        movq    %mm2, %mm1      # _a.37, D.2452
        movq    %mm3, %mm4      # _b, D.2451
        paddq   %mm5, %mm0      # carry, tmp94
        psrlq   $1, %mm1        #, D.2452
        movq    %mm0, (%ecx,%eax,8)     # tmp94,* result
        movq    %mm2, %mm0      # _a.37, tmp96
        pxor    %mm3, %mm0      # _b, tmp96
        pand    %mm5, %mm0      # carry, tmp96
        pand    %mm3, %mm2      # _b, _a.37
        por     %mm0, %mm2      # tmp96, _a.37
        psrlq   $1, %mm4        #, D.2451
        pand    %mm6, %mm2      # one.38, _a.37
        paddq   %mm4, %mm1      # D.2451, D.2452
        paddq   %mm2, %mm1      # _a.37, D.2452
        addl    $1, %eax        #, i
        psrlq   $63, %mm1       #, D.2452
        cmpl    %eax, %edx      # i, count
        movq    %mm1, %mm5      # D.2452, carry
        ja      .L3     #,
.L2:

Other than that, previous changes to MMX patterns are covered by 
pr22076.c, pr34256.c. In addition, all vecinit-N.c tests check that no 
MMX register is used in vector initialization code (we had some problems 
with this in the past).

2008-03-08  Uros Bizjak  <ubizjak@gmail.com>

        PR target/22152
        * gcc.target/i386/pr22152.c: New test.
        * gcc.target/i386/sse2-mmx.c: Ditto.


These new tests were checked on x86_64-linux-gnu {,-m32} and are 
committed to mainline.

Uros.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: p.diff.txt
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20080308/9997b56d/attachment.txt>


More information about the Gcc-patches mailing list