Bug 24879

Summary: [4.1]: SSE3 monitor intrinsic doesn't work in 64bit
Product: gcc Reporter: H.J. Lu <hjl.tools>
Component: targetAssignee: Not yet assigned to anyone <unassigned>
Status: RESOLVED FIXED    
Severity: minor CC: gcc-bugs, ian
Priority: P3 Keywords: ice-on-valid-code, patch, ssemmx
Version: 4.1.1   
Target Milestone: 4.2.0   
Host: Target: x86_64-*-linux-gnu
Build: Known to work:
Known to fail: 3.4.6 4.0.3 4.1.1 Last reconfirmed: 2005-11-15 19:17:47

Description H.J. Lu 2005-11-15 19:12:11 UTC
It seems that SSE3 _mm_monitor instrinsic doesn't work too well with
64bit.

[hjl@gnu-13 function]$ cat x.c
#include <stdio.h>
#include <pmmintrin.h>

static void
foo (char *p)
{
   _mm_monitor(p, 0, 0);
}

main()
{
    char *p = (char *)&foo;
    int fail = 1;
    int i;

    for (i = 0; i < 20; i++) {
        if (p[i] == 0x0f) {
            fail = 0;
            break;
        }
    }

    printf ("failed: %d\n", fail);
    return 0;
}

[hjl@gnu-13 function]$ make
/usr/gcc-4.1/bin/gcc -O2 -msse3    x.c   -o x
x.c: In function \uffff\uffff\ufffffoo\uffff\uffff\uffff:
x.c:8: error: unrecognizable insn:
(insn 11 10 12 1 (unspec_volatile [
            (reg/v/f:DI 58 [ p ])
            (reg:SI 59)
            (reg:SI 60)
        ] 8) -1 (nil)
    (nil))
x.c:8: internal compiler error: in extract_insn, at recog.c:2084
Please submit a full bug report,
with preprocessed source if appropriate.
See <URL:http://gcc.gnu.org/bugs.html> for instructions.
make: *** [x] Error 1
[hjl@gnu-13 function]$ /usr/gcc-4.1/bin/gcc -O2 -msse3    x.c   -o x -m32
[hjl@gnu-13 function]$ ./x
failed: 0
Comment 1 Andrew Pinski 2005-11-15 19:17:47 UTC
Confirmed and not a regression.
Comment 2 Andrew Pinski 2005-11-15 19:24:52 UTC
(define_insn "sse3_mwait"
  [(unspec_volatile [(match_operand:SI 0 "register_operand" "a")
                     (match_operand:SI 1 "register_operand" "c")]
                    UNSPECV_MWAIT)]
  "TARGET_SSE3"
  "mwait\t%0, %1"
  [(set_attr "length" "3")])

(define_insn "sse3_monitor"
  [(unspec_volatile [(match_operand:SI 0 "register_operand" "a")
                     (match_operand:SI 1 "register_operand" "c")
                     (match_operand:SI 2 "register_operand" "d")]
                    UNSPECV_MONITOR)]
  "TARGET_SSE3"
  "monitor\t%0, %1, %2"
  [(set_attr "length" "3")])


These targets don't have any of the 64bit stuff.  This has been an issue since the patterns were added... So you caused the bug.
Comment 3 H.J. Lu 2005-11-16 17:35:47 UTC
A patch is posted at

http://gcc.gnu.org/ml/gcc-patches/2005-11/msg01195.html
Comment 4 hjl@gcc.gnu.org 2006-05-08 03:43:15 UTC
Subject: Bug 24879

Author: hjl
Date: Mon May  8 03:43:07 2006
New Revision: 113617

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=113617
Log:
gcc/

2006-05-07  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/24879
	* config/i386/pmmintrin.h (_mm_monitor): Remove macro. Use
	inline function.
	(_mm_mwait): Likewise.

	* config/i386/sse.md (sse3_mwait): Replace "mwait\t%0, %1" with
	"mwait".
	(sse3_monitor): Make it 32bit only.
	(sse3_monitor64): New. 64bit monitor.

gcc/testsuite/

2006-05-07  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/24879
	* gcc.target/i386/monitor.c: New file.

Added:
    trunk/gcc/testsuite/gcc.target/i386/monitor.c
Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/pmmintrin.h
    trunk/gcc/config/i386/sse.md
    trunk/gcc/testsuite/ChangeLog

Comment 5 Andrew Pinski 2006-05-08 06:47:08 UTC
Fixed.
Comment 6 H.J. Lu 2006-05-08 14:00:25 UTC
It isn't fixed in 4.1.
Comment 7 Andrew Pinski 2006-05-08 15:12:33 UTC
So what this is not a regression.