User account creation filtered due to spam.

Bug 48612 - [4.7 Regression] vminps instruction is generated with -ftree-vectorize even without -mavx, causing SIGILL
Summary: [4.7 Regression] vminps instruction is generated with -ftree-vectorize even w...
Status: RESOLVED FIXED
Alias: None
Product: gcc
Classification: Unclassified
Component: target (show other bugs)
Version: 4.7.0
: P3 normal
Target Milestone: 4.7.0
Assignee: Not yet assigned to anyone
URL:
Keywords: ssemmx, wrong-code
Depends on:
Blocks:
 
Reported: 2011-04-14 20:40 UTC by Zdenek Sojka
Modified: 2011-04-15 12:51 UTC (History)
2 users (show)

See Also:
Host: x86_64-pc-linux-gnu
Target: x86_64-pc-linux-gnu
Build:
Known to work: 4.6.1
Known to fail: 4.7.0
Last reconfirmed:


Attachments
reduced testcase (from gcc.target/i386/sse-minps-1.c) (227 bytes, text/plain)
2011-04-14 20:40 UTC, Zdenek Sojka
Details

Note You need to log in before you can comment on or make changes to this bug.
Description Zdenek Sojka 2011-04-14 20:40:20 UTC
Created attachment 23990 [details]
reduced testcase (from gcc.target/i386/sse-minps-1.c)

Output:
$ gcc -O -ftree-vectorize testcase.c
$ ./a.out
Program received signal SIGILL, Illegal instruction.
0x00000000004004eb in do_test (e=0x7fffffffde70) at testcase.c:16
16          e[i] = s1.a[i] < s2.a[i] ? s1.a[i] : s2.a[i];
(gdb) disassemble
Dump of assembler code for function do_test:
   0x00000000004004e4 <+0>:     movaps 0x135(%rip),%xmm0        # 0x400620
=> 0x00000000004004eb <+7>:     vminps 0x13d(%rip),%xmm0,%xmm0        # 0x400630
   0x00000000004004f3 <+15>:    movlps %xmm0,(%rdi)
   0x00000000004004f6 <+18>:    movhps %xmm0,0x8(%rdi)
   0x00000000004004fa <+22>:    retq   
End of assembler dump.
Comment 1 H.J. Lu 2011-04-15 02:51:43 UTC
This should work:

diff --git a/gcc/config/i386/sse.md b/gcc/config/i386/sse.md
index df5e216..fabd35b 100644
--- a/gcc/config/i386/sse.md
+++ b/gcc/config/i386/sse.md
@@ -962,8 +962,8 @@
 	 UNSPEC_IEEE_MIN))]
   ""
   "@
-   vmin<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
-   min<ssemodesuffix>\t{%2, %0|%0, %2}"
+   min<ssemodesuffix>\t{%2, %0|%0, %2}
+   vmin<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
   [(set_attr "isa" "noavx,avx")
    (set_attr "type" "sseadd")
    (set_attr "prefix" "orig,vex")
@@ -977,8 +977,8 @@
 	 UNSPEC_IEEE_MAX))]
   ""
   "@
-   vmax<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}
-   max<ssemodesuffix>\t{%2, %0|%0, %2}"
+   max<ssemodesuffix>\t{%2, %0|%0, %2}
+   vmax<ssemodesuffix>\t{%2, %1, %0|%0, %1, %2}"
   [(set_attr "isa" "noavx,avx")
    (set_attr "type" "sseadd")
    (set_attr "prefix" "orig,vex")
Comment 2 Uroš Bizjak 2011-04-15 09:09:14 UTC
(In reply to comment #1)
> This should work:

Yes, these mnemonics should be switched. Please go ahead and commit this change.

Thanks,
Uros.
Comment 3 hjl@gcc.gnu.org 2011-04-15 12:48:40 UTC
Author: hjl
Date: Fri Apr 15 12:48:36 2011
New Revision: 172492

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=172492
Log:
Switch SSE and AVX mnemonics.

2011-04-15  H.J. Lu  <hongjiu.lu@intel.com>

	PR target/48612
	* config/i386/sse.md (*ieee_smin<mode>3): Switch mnemonics.
	(*ieee_smax<mode>3): Likewise.

Modified:
    trunk/gcc/ChangeLog
    trunk/gcc/config/i386/sse.md
Comment 4 H.J. Lu 2011-04-15 12:51:45 UTC
Fixed.