public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug c/21239] New: Illegal elimination of SSE2 load/store using xmm intrinsics
@ 2005-04-26 23:46 kurt at garloff dot de
  2005-04-26 23:49 ` [Bug c/21239] " matz at suse dot de
                   ` (6 more replies)
  0 siblings, 7 replies; 8+ messages in thread
From: kurt at garloff dot de @ 2005-04-26 23:46 UTC (permalink / raw)
  To: gcc-bugs

/** intrin.c   
 *   
 * gcc-4.0 misoptimizes the _mm_load_sd() away with   
 * -O1 (x86-64), with or without -m32 -msse2.   
 *   
 * (c) Kurt Garloff <garloff@suse.de>, Artistic v2   
 */   
   
#include <stdlib.h>                                                                              
#include <emmintrin.h>                                                                           
   
#ifdef WORKAROUND                                                                                
# define ACCESS(X) asm("": : "x"(X))                                                             
#else                                                                                            
# define ACCESS(X)                                                                               
#endif                                                                                           
   
void do_copy(const unsigned int ln, double* const dst,      
                const double* const src)   
{   
        int i = ln;   
        const register double *s = src;   
        register double *d = dst;   
        __m128d TMP;   
        while (i) {   
                TMP = _mm_load_sd(s);   
                ACCESS(TMP);   
                _mm_store_sd(d, TMP);   
                --i; ++s; ++d;   
        }                                                                                        
}                                                                                                
   
int main()   
{   
        unsigned int i;   
        double *a, *b ,*c;   
        a = (double*) malloc(19*sizeof(double));   
        b = (double*) malloc(19*sizeof(double));   
        for (i = 0; i < 19; ++i) {   
                a[i] = 1; b[i] = 2;   
        }                                                                                        
        do_copy(19, a, b);   
        return (a[18] != 2);   
}                                                                                                
   
The test program should return 0, which it does if gcc-3.3/3.4 is used or if   
compiled with -DWORKAROUND. gcc-4.0, 4_0-branch, HEAD, and   
tree-profiling-branch all fail: The _mm_load_sd() is optimized away.   
I guess the compiler does not consider the _mm_store_sd() as a consumer of   
the vector register. Adding the fake consumer asm(""::x(XMMREG)); helps thus.  
Compiling with -m32 -msse2 exposes the same problem, I have a strong suspicion  
the native compiler on x86 would have the same problem.  
  
   
Here's the wrong assembly produced by gcc-4.0 (on x86-64, using -O2):  
do_copy:  
.LFB495:  
        testl   %edi, %edi  
        jne     .L8  
        rep ; ret  
        .p2align 4,,7  
.L8:  
        xorl    %eax, %eax  
        .p2align 4,,7  
.L4:  
        incl    %eax  
        movq    $0, (%rsi)  
        addq    $8, %rsi  
        cmpl    %eax, %edi  
        jne     .L4  
        rep ; ret  
  
... and here the correct assembly with -DWORKAROUND added:  
do_copy:  
.LFB495:  
        testl   %edi, %edi  
        jne     .L8  
        rep ; ret  
        .p2align 4,,7  
.L8:  
        xorl    %eax, %eax  
        .p2align 4,,7  
.L4:  
        movsd   (%rdx), %xmm0  
        incl    %eax  
        movlpd  %xmm0, (%rsi)  
        addq    $8, %rdx  
        addq    $8, %rsi  
        cmpl    %eax, %edi  
        jne     .L4  
        rep ; ret

-- 
           Summary: Illegal elimination of SSE2 load/store using xmm
                    intrinsics
           Product: gcc
           Version: 4.0.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: c
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: kurt at garloff dot de
                CC: gcc-bugs at gcc dot gnu dot org
 GCC build triplet: x86_64-suse-linux
  GCC host triplet: x86_64-suse-linux
GCC target triplet: x86_64-suse-linux


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21239


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug c/21239] Illegal elimination of SSE2 load/store using xmm intrinsics
  2005-04-26 23:46 [Bug c/21239] New: Illegal elimination of SSE2 load/store using xmm intrinsics kurt at garloff dot de
@ 2005-04-26 23:49 ` matz at suse dot de
  2005-04-27  0:00 ` [Bug rtl-optimization/21239] [4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: matz at suse dot de @ 2005-04-26 23:49 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |matz at suse dot de


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21239


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug rtl-optimization/21239] [4.0/4.1 Regression] Illegal elimination of SSE2 load/store using xmm intrinsics
  2005-04-26 23:46 [Bug c/21239] New: Illegal elimination of SSE2 load/store using xmm intrinsics kurt at garloff dot de
  2005-04-26 23:49 ` [Bug c/21239] " matz at suse dot de
@ 2005-04-27  0:00 ` pinskia at gcc dot gnu dot org
  2005-05-03 14:42 ` jakub at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2005-04-27  0:00 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2005-04-27 00:00 -------
Confirmed.
Combine is combing the following RTL:
(insn 30 27 31 2 (set (reg:DF 70)
        (mem:DF (reg/v/f:SI 64 [ s ]) [0 S8 A64])) -1 (nil)
    (nil))

(insn 31 30 32 2 (set (reg:V2DF 69)
        (vec_concat:V2DF (reg:DF 70)
            (const_double:DF 0 [0x0] 0.0 [0x0.0p+0]))) -1 (insn_list:REG_DEP_TRUE 30 (nil))
    (expr_list:REG_DEAD (reg:DF 70)
        (nil)))

(insn 32 31 34 2 (set (reg:DF 71)
        (vec_select:DF (reg:V2DF 69)
            (parallel [
                    (const_int 0 [0x0])
                ]))) -1 (insn_list:REG_DEP_TRUE 31 (nil))
    (expr_list:REG_DEAD (reg:V2DF 69)
        (nil)))

(insn 34 32 36 2 (set (mem:DF (reg/v/f:SI 63 [ d ]) [0 S8 A64])
        (reg:DF 71)) -1 (insn_list:REG_DEP_TRUE 32 (nil))
    (expr_list:REG_DEAD (reg:DF 71)
        (nil)))
into:
(insn 34 32 36 2 (set (mem:DF (reg/v/f:SI 63 [ d ]) [0 S8 A64])
        (const_double:DF 0 [0x0] 0.0 [0x0.0p+0])) 65 {*movdf_nointeger} (nil)
    (nil))

Which is just wrong.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
          Component|c                           |rtl-optimization
     Ever Confirmed|                            |1
           Keywords|                            |ssemmx, wrong-code
   Last reconfirmed|0000-00-00 00:00:00         |2005-04-27 00:00:41
               date|                            |
            Summary|Illegal elimination of SSE2 |[4.0/4.1 Regression] Illegal
                   |load/store using xmm        |elimination of SSE2
                   |intrinsics                  |load/store using xmm
                   |                            |intrinsics
   Target Milestone|---                         |4.0.1


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21239


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug rtl-optimization/21239] [4.0/4.1 Regression] Illegal elimination of SSE2 load/store using xmm intrinsics
  2005-04-26 23:46 [Bug c/21239] New: Illegal elimination of SSE2 load/store using xmm intrinsics kurt at garloff dot de
  2005-04-26 23:49 ` [Bug c/21239] " matz at suse dot de
  2005-04-27  0:00 ` [Bug rtl-optimization/21239] [4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
@ 2005-05-03 14:42 ` jakub at gcc dot gnu dot org
  2005-05-03 22:16 ` cvs-commit at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: jakub at gcc dot gnu dot org @ 2005-05-03 14:42 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From jakub at gcc dot gnu dot org  2005-05-03 14:42 -------
Yeah, a bug in combine_simplify_rtx.  I have a patch that fixes this, but
while working on a testcase I encountered other bug as well, so am looking
into that too.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |jakub at gcc dot gnu dot org
                   |dot org                     |
             Status|NEW                         |ASSIGNED
   Last reconfirmed|2005-04-27 00:00:41         |2005-05-03 14:42:12
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21239


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug rtl-optimization/21239] [4.0/4.1 Regression] Illegal elimination of SSE2 load/store using xmm intrinsics
  2005-04-26 23:46 [Bug c/21239] New: Illegal elimination of SSE2 load/store using xmm intrinsics kurt at garloff dot de
                   ` (2 preceding siblings ...)
  2005-05-03 14:42 ` jakub at gcc dot gnu dot org
@ 2005-05-03 22:16 ` cvs-commit at gcc dot gnu dot org
  2005-05-04  7:30 ` [Bug rtl-optimization/21239] [4.0 " cvs-commit at gcc dot gnu dot org
                   ` (2 subsequent siblings)
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-05-03 22:16 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-05-03 22:16 -------
Subject: Bug 21239

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	jakub@gcc.gnu.org	2005-05-03 22:16:02

Modified files:
	gcc            : ChangeLog combine.c 
	gcc/testsuite  : ChangeLog 
	gcc/config/i386: i386.c 
Added files:
	gcc/testsuite/gcc.dg: i386-sse-11.c 

Log message:
	* config/i386/i386.c (ix86_expand_vector_set): Fix setting 3rd and 4th
	item in V4SF mode.
	
	PR rtl-optimization/21239
	* combine.c (combine_simplify_rtx) <case VEC_SELECT>: Fix a typo.
	
	* gcc.dg/i386-sse-11.c: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.8587&r2=2.8588
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/combine.c.diff?cvsroot=gcc&r1=1.488&r2=1.489
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&r1=1.5436&r2=1.5437
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/i386.c.diff?cvsroot=gcc&r1=1.817&r2=1.818
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/i386-sse-11.c.diff?cvsroot=gcc&r1=NONE&r2=1.1



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21239


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug rtl-optimization/21239] [4.0 Regression] Illegal elimination of SSE2 load/store using xmm intrinsics
  2005-04-26 23:46 [Bug c/21239] New: Illegal elimination of SSE2 load/store using xmm intrinsics kurt at garloff dot de
                   ` (3 preceding siblings ...)
  2005-05-03 22:16 ` cvs-commit at gcc dot gnu dot org
@ 2005-05-04  7:30 ` cvs-commit at gcc dot gnu dot org
  2005-05-04  8:15 ` giovannibajo at libero dot it
  2005-05-26 17:55 ` cvs-commit at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-05-04  7:30 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-05-04 07:30 -------
Subject: Bug 21239

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-4_0-branch
Changes by:	jakub@gcc.gnu.org	2005-05-04 07:29:29

Modified files:
	gcc            : ChangeLog combine.c 
	gcc/testsuite  : ChangeLog 
	gcc/config/i386: i386.c 
Added files:
	gcc/testsuite/gcc.dg: i386-sse-11.c 

Log message:
	* config/i386/i386.c (ix86_expand_vector_set): Fix setting 3rd and 4th
	item in V4SF mode.
	
	PR rtl-optimization/21239
	* combine.c (combine_simplify_rtx) <case VEC_SELECT>: Fix a typo.
	
	* gcc.dg/i386-sse-11.c: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=2.7592.2.215&r2=2.7592.2.216
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/combine.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.475.4.4&r2=1.475.4.5
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.5084.2.158&r2=1.5084.2.159
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/i386.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=1.795.6.7&r2=1.795.6.8
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/i386-sse-11.c.diff?cvsroot=gcc&only_with_tag=gcc-4_0-branch&r1=NONE&r2=1.1.2.1



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21239


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug rtl-optimization/21239] [4.0 Regression] Illegal elimination of SSE2 load/store using xmm intrinsics
  2005-04-26 23:46 [Bug c/21239] New: Illegal elimination of SSE2 load/store using xmm intrinsics kurt at garloff dot de
                   ` (4 preceding siblings ...)
  2005-05-04  7:30 ` [Bug rtl-optimization/21239] [4.0 " cvs-commit at gcc dot gnu dot org
@ 2005-05-04  8:15 ` giovannibajo at libero dot it
  2005-05-26 17:55 ` cvs-commit at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: giovannibajo at libero dot it @ 2005-05-04  8:15 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From giovannibajo at libero dot it  2005-05-04 08:15 -------
Fixed, thanks Kurt for the report and Jakub for fixing it!

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21239


^ permalink raw reply	[flat|nested] 8+ messages in thread

* [Bug rtl-optimization/21239] [4.0 Regression] Illegal elimination of SSE2 load/store using xmm intrinsics
  2005-04-26 23:46 [Bug c/21239] New: Illegal elimination of SSE2 load/store using xmm intrinsics kurt at garloff dot de
                   ` (5 preceding siblings ...)
  2005-05-04  8:15 ` giovannibajo at libero dot it
@ 2005-05-26 17:55 ` cvs-commit at gcc dot gnu dot org
  6 siblings, 0 replies; 8+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2005-05-26 17:55 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2005-05-26 17:53 -------
Subject: Bug 21239

CVSROOT:	/cvs/gcc
Module name:	gcc
Branch: 	gcc-3_4-rhl-branch
Changes by:	jakub@gcc.gnu.org	2005-05-26 17:53:53

Modified files:
	gcc            : ChangeLog combine.c 
	gcc/testsuite  : ChangeLog 
Added files:
	gcc/testsuite/gcc.dg: i386-sse-11.c 

Log message:
	PR rtl-optimization/21239
	* combine.c (combine_simplify_rtx) <case VEC_SELECT>: Fix a typo.
	
	* gcc.dg/i386-sse-11.c: New test.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-rhl-branch&r1=2.2326.2.399.2.79&r2=2.2326.2.399.2.80
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/combine.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-rhl-branch&r1=1.400.4.6.2.5&r2=1.400.4.6.2.6
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/ChangeLog.diff?cvsroot=gcc&only_with_tag=gcc-3_4-rhl-branch&r1=1.3389.2.170.2.50&r2=1.3389.2.170.2.51
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/testsuite/gcc.dg/i386-sse-11.c.diff?cvsroot=gcc&only_with_tag=gcc-3_4-rhl-branch&r1=NONE&r2=1.1.8.1



-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=21239


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2005-05-26 17:54 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-04-26 23:46 [Bug c/21239] New: Illegal elimination of SSE2 load/store using xmm intrinsics kurt at garloff dot de
2005-04-26 23:49 ` [Bug c/21239] " matz at suse dot de
2005-04-27  0:00 ` [Bug rtl-optimization/21239] [4.0/4.1 Regression] " pinskia at gcc dot gnu dot org
2005-05-03 14:42 ` jakub at gcc dot gnu dot org
2005-05-03 22:16 ` cvs-commit at gcc dot gnu dot org
2005-05-04  7:30 ` [Bug rtl-optimization/21239] [4.0 " cvs-commit at gcc dot gnu dot org
2005-05-04  8:15 ` giovannibajo at libero dot it
2005-05-26 17:55 ` cvs-commit at gcc dot gnu dot org

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).