Re: [PATCH] Fix avx512f_sfixupimm* (PR target/88489)

2018-12-14 Thread Jeff Law
On 12/14/18 12:50 PM, Jakub Jelinek wrote:
> Hi!
> 
> The avx512f-vfixupimms{s,d}-2.c testcases were miscompiled with -mavx512vl.
> The problem is that there are separate instructions (e.g. vfixupimmsd vs.
> vfixupimmpd), each of those have different behavior, the first one is
> TARGET_AVX512F, the latter TARGET_AVX512VL, but the 128-bit version of the
> latter used identical RTL pattern to the vfixupimmsd instruction and was
> defined earlier.
> 
> Fixed by using different UNSPEC number for the scalar vs. vector ones.
> 
> Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?
> 
> 2018-12-14  Jakub Jelinek  
> 
>   PR target/88489
>   * config/i386/sse.md (UNSPEC_SFIXUPIMM): New unspec enumerator.
>   (avx512f_sfixupimm): Use it
>   instead of UNSPEC_FIXUPIMM.
> 
>   * gcc.target/i386/avx512vl-vfixupimmsd-2.c: New test.
>   * gcc.target/i386/avx512vl-vfixupimmss-2.c: New test.
OK
jeff


[PATCH] Fix avx512f_sfixupimm* (PR target/88489)

2018-12-14 Thread Jakub Jelinek
Hi!

The avx512f-vfixupimms{s,d}-2.c testcases were miscompiled with -mavx512vl.
The problem is that there are separate instructions (e.g. vfixupimmsd vs.
vfixupimmpd), each of those have different behavior, the first one is
TARGET_AVX512F, the latter TARGET_AVX512VL, but the 128-bit version of the
latter used identical RTL pattern to the vfixupimmsd instruction and was
defined earlier.

Fixed by using different UNSPEC number for the scalar vs. vector ones.

Bootstrapped/regtested on x86_64-linux and i686-linux, ok for trunk?

2018-12-14  Jakub Jelinek  

PR target/88489
* config/i386/sse.md (UNSPEC_SFIXUPIMM): New unspec enumerator.
(avx512f_sfixupimm): Use it
instead of UNSPEC_FIXUPIMM.

* gcc.target/i386/avx512vl-vfixupimmsd-2.c: New test.
* gcc.target/i386/avx512vl-vfixupimmss-2.c: New test.

--- gcc/config/i386/sse.md.jj   2018-12-13 08:59:03.0 +0100
+++ gcc/config/i386/sse.md  2018-12-14 18:43:04.924881740 +0100
@@ -95,6 +95,7 @@ (define_c_enum "unspec" [
   UNSPEC_RCP14
   UNSPEC_RSQRT14
   UNSPEC_FIXUPIMM
+  UNSPEC_SFIXUPIMM
   UNSPEC_SCALEF
   UNSPEC_VTERNLOG
   UNSPEC_GETEXP
@@ -8872,7 +8873,7 @@ (define_insn "avx512f_sfixupimm 2 "" 
"")
 (match_operand:SI 3 "const_0_to_255_operand")]
-   UNSPEC_FIXUPIMM))]
+   UNSPEC_SFIXUPIMM))]
"TARGET_AVX512F"
   "vfixupimm\t{%3, %2, %1, 
%0|%0, %1, %2, %3}";
   [(set_attr "prefix" "evex")
--- gcc/testsuite/gcc.target/i386/avx512vl-vfixupimmsd-2.c.jj   2018-12-14 
18:46:05.334946460 +0100
+++ gcc/testsuite/gcc.target/i386/avx512vl-vfixupimmsd-2.c  2018-12-14 
18:50:11.986933429 +0100
@@ -0,0 +1,20 @@
+/* { dg-do run } */
+/* { dg-options "-mavx512vl -O2 -std=gnu99" } */
+/* { dg-require-effective-target avx512vl } */
+/* { dg-require-effective-target c99_runtime } */
+
+#define AVX512VL
+#define AVX512F_LEN 512
+#define AVX512F_LEN_HALF 256
+#include "avx512f-vfixupimmsd-2.c"
+
+static void
+test_256 (void)
+{
+  test_512 ();
+}
+
+static void
+test_128 (void)
+{
+}
--- gcc/testsuite/gcc.target/i386/avx512vl-vfixupimmss-2.c.jj   2018-12-14 
18:50:52.808269261 +0100
+++ gcc/testsuite/gcc.target/i386/avx512vl-vfixupimmss-2.c  2018-12-14 
18:51:06.084053265 +0100
@@ -0,0 +1,20 @@
+/* { dg-do run } */
+/* { dg-options "-mavx512vl -O2 -std=gnu99" } */
+/* { dg-require-effective-target avx512vl } */
+/* { dg-require-effective-target c99_runtime } */
+
+#define AVX512VL
+#define AVX512F_LEN 512
+#define AVX512F_LEN_HALF 256
+#include "avx512f-vfixupimmss-2.c"
+
+static void
+test_256 (void)
+{
+  test_512 ();
+}
+
+static void
+test_128 (void)
+{
+}

Jakub