public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug tree-optimization/18503] New: _mm_move_ss SSE intrinsic causes erroneous
@ 2004-11-15 15:39 torgeihe at stud dot ntnu dot no
  2004-11-15 15:41 ` [Bug tree-optimization/18503] " pinskia at gcc dot gnu dot org
                   ` (10 more replies)
  0 siblings, 11 replies; 12+ messages in thread
From: torgeihe at stud dot ntnu dot no @ 2004-11-15 15:39 UTC (permalink / raw)
  To: gcc-bugs

Compiling the following function on x86 with options -O -fomit-frame-pointer
-msse -S seems to result in erroneous code.

#include <xmmintrin.h>

__m128 bug(__m128 a, __m128 b) {
	__m128 c = _mm_sub_ps(a, b);
	return _mm_move_ss(c, a);
}

This is what the function in the resulting .s file looke like:

	.file	"gccbug.c"
	.text
	.align 2
.globl __Z3bugU8__vectorfS_
	.def	__Z3bugU8__vectorfS_;	.scl	2;	.type	32;	.endef
__Z3bugU8__vectorfS_:
	subss	%xmm1, %xmm0
	ret

According to
http://www.intel.com/software/products/compilers/clin/docs/ug_cpp/comm1030.htm
_mm_move_ss passes the upper three values through, but the code generated
doesn't even calculate those values. I had expected the code to look more like this:

	movaps	%xmm0, %xmm2
	subps	%xmm1, %xmm0
	movss	%xmm2, %xmm0

Hope that turned out right, I'm not experienced with AT&T syntax. Is this a bug,
or have I misunderstood something? I get similar results with 3.3.4.

Torgeir

-- 
           Summary: _mm_move_ss SSE intrinsic causes erroneous
           Product: gcc
           Version: 3.4.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P2
         Component: tree-optimization
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: torgeihe at stud dot ntnu dot no
                CC: gcc-bugs at gcc dot gnu dot org


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


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

* [Bug tree-optimization/18503] _mm_move_ss SSE intrinsic causes erroneous
  2004-11-15 15:39 [Bug tree-optimization/18503] New: _mm_move_ss SSE intrinsic causes erroneous torgeihe at stud dot ntnu dot no
@ 2004-11-15 15:41 ` pinskia at gcc dot gnu dot org
  2004-11-15 15:47 ` pinskia at gcc dot gnu dot org
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-11-15 15:41 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-11-15 15:41 -------
*** Bug 18504 has been marked as a duplicate of this bug. ***

-- 


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


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

* [Bug tree-optimization/18503] _mm_move_ss SSE intrinsic causes erroneous
  2004-11-15 15:39 [Bug tree-optimization/18503] New: _mm_move_ss SSE intrinsic causes erroneous torgeihe at stud dot ntnu dot no
  2004-11-15 15:41 ` [Bug tree-optimization/18503] " pinskia at gcc dot gnu dot org
@ 2004-11-15 15:47 ` pinskia at gcc dot gnu dot org
  2004-11-15 16:26 ` torgeihe at stud dot ntnu dot no
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-11-15 15:47 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From pinskia at gcc dot gnu dot org  2004-11-15 15:47 -------
No you are reading the asm backwards, the corresponding intel asm is:
bug:        subss   %xmm0, %xmm1
ret

Which you can  get with -masm=intel.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|                            |INVALID


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


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

* [Bug tree-optimization/18503] _mm_move_ss SSE intrinsic causes erroneous
  2004-11-15 15:39 [Bug tree-optimization/18503] New: _mm_move_ss SSE intrinsic causes erroneous torgeihe at stud dot ntnu dot no
  2004-11-15 15:41 ` [Bug tree-optimization/18503] " pinskia at gcc dot gnu dot org
  2004-11-15 15:47 ` pinskia at gcc dot gnu dot org
@ 2004-11-15 16:26 ` torgeihe at stud dot ntnu dot no
  2004-11-16 13:23 ` torgeihe at stud dot ntnu dot no
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: torgeihe at stud dot ntnu dot no @ 2004-11-15 16:26 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From torgeihe at stud dot ntnu dot no  2004-11-15 16:26 -------
Subject: Re:  _mm_move_ss SSE intrinsic causes
 erroneous

pinskia at gcc dot gnu dot org wrote:
> ------- Additional Comments From pinskia at gcc dot gnu dot org  2004-11-15 15:47 -------
> No you are reading the asm backwards, the corresponding intel asm is:
> bug:        subss   %xmm0, %xmm1
> ret
> 
> Which you can  get with -masm=intel.
> 

Yes, I know AT&T syntax is backwards compared to Intel, have I 
misinterpreted the intrinsics or resulting code somehow? To be more 
clear, I expected the C function to return the following vector:

   v0 = a0
   v1 = a1 - b1
   v2 = a2 - b2
   v3 = a3 - b3

Instead it seems to return:

   v0 = a0 - b0
   v1 = a1
   v2 = a2
   v3 = a3

_mm_move_ss should the three upper values from its first argument, and 
the lower from its second, no?

Torgeir



-- 


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


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

* [Bug tree-optimization/18503] _mm_move_ss SSE intrinsic causes erroneous
  2004-11-15 15:39 [Bug tree-optimization/18503] New: _mm_move_ss SSE intrinsic causes erroneous torgeihe at stud dot ntnu dot no
                   ` (2 preceding siblings ...)
  2004-11-15 16:26 ` torgeihe at stud dot ntnu dot no
@ 2004-11-16 13:23 ` torgeihe at stud dot ntnu dot no
  2004-11-16 13:53 ` [Bug target/18503] " pinskia at gcc dot gnu dot org
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: torgeihe at stud dot ntnu dot no @ 2004-11-16 13:23 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From torgeihe at stud dot ntnu dot no  2004-11-16 13:23 -------
Why was this bug closed without being resolved? I have attached an improved
testcase that uncovers another bug that occurs when optimization is disabled, so
hopefully it's okay that I reopen this report.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |


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


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

* [Bug target/18503] _mm_move_ss SSE intrinsic causes erroneous
  2004-11-15 15:39 [Bug tree-optimization/18503] New: _mm_move_ss SSE intrinsic causes erroneous torgeihe at stud dot ntnu dot no
                   ` (3 preceding siblings ...)
  2004-11-16 13:23 ` torgeihe at stud dot ntnu dot no
@ 2004-11-16 13:53 ` pinskia at gcc dot gnu dot org
  2004-11-17  9:17 ` uros at kss-loka dot si
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2004-11-16 13:53 UTC (permalink / raw)
  To: gcc-bugs



-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
          Component|tree-optimization           |target
           Keywords|                            |wrong-code


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


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

* [Bug target/18503] _mm_move_ss SSE intrinsic causes erroneous
  2004-11-15 15:39 [Bug tree-optimization/18503] New: _mm_move_ss SSE intrinsic causes erroneous torgeihe at stud dot ntnu dot no
                   ` (4 preceding siblings ...)
  2004-11-16 13:53 ` [Bug target/18503] " pinskia at gcc dot gnu dot org
@ 2004-11-17  9:17 ` uros at kss-loka dot si
  2004-11-17  9:19 ` uros at gcc dot gnu dot org
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: uros at kss-loka dot si @ 2004-11-17  9:17 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From uros at kss-loka dot si  2004-11-17 09:17 -------
The problem was that "sse_movss" pattern has wrong vec_merge constant, so it was
wrongly combined to "vmsubv4sf3" pattern. Instead of 0x1, "sse_movss" pattern
should have 0x14:

(define_insn "sse_movss"
  [(set (match_operand:V4SF 0 "register_operand" "=x")
	(vec_merge:V4SF
	 (match_operand:V4SF 1 "register_operand" "0")
	 (match_operand:V4SF 2 "register_operand" "x")
	 (const_int 14)))]                               <- here!
  "TARGET_SSE"
  "movss\t{%2, %0|%0, %2}"
  [(set_attr "type" "ssemov")
   (set_attr "mode" "SF")])

With this change, the result from your testcase is OK. ASM code looks like:

bug:
        movaps %xmm0, %xmm2
        subps %xmm1, %xmm2
        pushl %ebp
        movl %esp, %ebp
        movaps %xmm2, %xmm1
        movss %xmm0, %xmm1
        popl %ebp
        movaps %xmm1, %xmm0
        ret

BTW: "sse2_movsd" pattern has the same problem... And "sse_loadss_1",
"sse_storess" and their sse2 equivalents.

Bug is confirmed, a patch will follow soon...

Thanks,
Uros.

-- 


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


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

* [Bug target/18503] _mm_move_ss SSE intrinsic causes erroneous
  2004-11-15 15:39 [Bug tree-optimization/18503] New: _mm_move_ss SSE intrinsic causes erroneous torgeihe at stud dot ntnu dot no
                   ` (5 preceding siblings ...)
  2004-11-17  9:17 ` uros at kss-loka dot si
@ 2004-11-17  9:19 ` uros at gcc dot gnu dot org
  2004-11-17 10:10 ` uros at gcc dot gnu dot org
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: uros at gcc dot gnu dot org @ 2004-11-17  9:19 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From uros at gcc dot gnu dot org  2004-11-17 09:19 -------
.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |NEW
     Ever Confirmed|                            |1
      Known to fail|                            |4.0.0
   Last reconfirmed|0000-00-00 00:00:00         |2004-11-17 09:19:16
               date|                            |


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


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

* [Bug target/18503] _mm_move_ss SSE intrinsic causes erroneous
  2004-11-15 15:39 [Bug tree-optimization/18503] New: _mm_move_ss SSE intrinsic causes erroneous torgeihe at stud dot ntnu dot no
                   ` (6 preceding siblings ...)
  2004-11-17  9:19 ` uros at gcc dot gnu dot org
@ 2004-11-17 10:10 ` uros at gcc dot gnu dot org
  2004-11-22  6:36 ` uros at kss-loka dot si
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 12+ messages in thread
From: uros at gcc dot gnu dot org @ 2004-11-17 10:10 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From uros at gcc dot gnu dot org  2004-11-17 10:10 -------
Patch here: http://gcc.gnu.org/ml/gcc-patches/2004-11/msg01377.html

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


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


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

* [Bug target/18503] _mm_move_ss SSE intrinsic causes erroneous
  2004-11-15 15:39 [Bug tree-optimization/18503] New: _mm_move_ss SSE intrinsic causes erroneous torgeihe at stud dot ntnu dot no
                   ` (7 preceding siblings ...)
  2004-11-17 10:10 ` uros at gcc dot gnu dot org
@ 2004-11-22  6:36 ` uros at kss-loka dot si
  2004-12-13  6:38 ` cvs-commit at gcc dot gnu dot org
  2004-12-13  7:09 ` uros at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: uros at kss-loka dot si @ 2004-11-22  6:36 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From uros at kss-loka dot si  2004-11-22 06:36 -------
Patch, rev. 2, waiting review:
http://gcc.gnu.org/ml/gcc-patches/2004-11/msg01469.html

-- 


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


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

* [Bug target/18503] _mm_move_ss SSE intrinsic causes erroneous
  2004-11-15 15:39 [Bug tree-optimization/18503] New: _mm_move_ss SSE intrinsic causes erroneous torgeihe at stud dot ntnu dot no
                   ` (8 preceding siblings ...)
  2004-11-22  6:36 ` uros at kss-loka dot si
@ 2004-12-13  6:38 ` cvs-commit at gcc dot gnu dot org
  2004-12-13  7:09 ` uros at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: cvs-commit at gcc dot gnu dot org @ 2004-12-13  6:38 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From cvs-commit at gcc dot gnu dot org  2004-12-13 06:38 -------
Subject: Bug 18503

CVSROOT:	/cvs/gcc
Module name:	gcc
Changes by:	uros@gcc.gnu.org	2004-12-13 06:38:47

Modified files:
	gcc            : ChangeLog 
	gcc/config/i386: i386.md 

Log message:
	PR target/14941
	PR target/18503
	* config/i386/i386.md (sse_movss, sse2_movsd, sse2_movhpd):
	Fix wrong vec_merge selector bitmask.

Patches:
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/ChangeLog.diff?cvsroot=gcc&r1=2.6798&r2=2.6799
http://gcc.gnu.org/cgi-bin/cvsweb.cgi/gcc/gcc/config/i386/i386.md.diff?cvsroot=gcc&r1=1.571&r2=1.572



-- 


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


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

* [Bug target/18503] _mm_move_ss SSE intrinsic causes erroneous
  2004-11-15 15:39 [Bug tree-optimization/18503] New: _mm_move_ss SSE intrinsic causes erroneous torgeihe at stud dot ntnu dot no
                   ` (9 preceding siblings ...)
  2004-12-13  6:38 ` cvs-commit at gcc dot gnu dot org
@ 2004-12-13  7:09 ` uros at gcc dot gnu dot org
  10 siblings, 0 replies; 12+ messages in thread
From: uros at gcc dot gnu dot org @ 2004-12-13  7:09 UTC (permalink / raw)
  To: gcc-bugs


------- Additional Comments From uros at gcc dot gnu dot org  2004-12-13 07:09 -------
Fixed.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.0.0


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


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

end of thread, other threads:[~2004-12-13  7:09 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-15 15:39 [Bug tree-optimization/18503] New: _mm_move_ss SSE intrinsic causes erroneous torgeihe at stud dot ntnu dot no
2004-11-15 15:41 ` [Bug tree-optimization/18503] " pinskia at gcc dot gnu dot org
2004-11-15 15:47 ` pinskia at gcc dot gnu dot org
2004-11-15 16:26 ` torgeihe at stud dot ntnu dot no
2004-11-16 13:23 ` torgeihe at stud dot ntnu dot no
2004-11-16 13:53 ` [Bug target/18503] " pinskia at gcc dot gnu dot org
2004-11-17  9:17 ` uros at kss-loka dot si
2004-11-17  9:19 ` uros at gcc dot gnu dot org
2004-11-17 10:10 ` uros at gcc dot gnu dot org
2004-11-22  6:36 ` uros at kss-loka dot si
2004-12-13  6:38 ` cvs-commit at gcc dot gnu dot org
2004-12-13  7:09 ` uros 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).