aboutsummaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg
diff options
context:
space:
mode:
authorJakub Jelinek <jakub@redhat.com>2018-05-08 14:16:19 +0200
committerJakub Jelinek <jakub@gcc.gnu.org>2018-05-08 14:16:19 +0200
commit4d4015db89b3e93dac9f8e08ce9127390d475f11 (patch)
tree58dcf1ac378e7ad6c3ef1d21a7f0fbb33c62e820 /gcc/testsuite/g++.dg
parentac6818591810af25dc9f91d28230f30494e22a71 (diff)
downloadgcc-4d4015db89b3e93dac9f8e08ce9127390d475f11.zip
gcc-4d4015db89b3e93dac9f8e08ce9127390d475f11.tar.gz
gcc-4d4015db89b3e93dac9f8e08ce9127390d475f11.tar.bz2
re PR target/85572 (faster code for absolute value of __v2di)
PR target/85572 * config/i386/i386.c (ix86_expand_sse2_abs): Handle E_V2DImode and E_V4DImode. * config/i386/sse.md (abs<mode>2): Use VI_AVX2 iterator instead of VI1248_AVX512VL_AVX512BW. Handle V2DImode and V4DImode if not TARGET_AVX512VL using ix86_expand_sse2_abs. Formatting fixes. * g++.dg/other/sse2-pr85572-1.C: New test. * g++.dg/other/sse2-pr85572-2.C: New test. * g++.dg/other/sse4-pr85572-1.C: New test. * g++.dg/other/avx2-pr85572-1.C: New test. From-SVN: r260041
Diffstat (limited to 'gcc/testsuite/g++.dg')
-rw-r--r--gcc/testsuite/g++.dg/other/avx2-pr85572-1.C21
-rw-r--r--gcc/testsuite/g++.dg/other/sse2-pr85572-1.C14
-rw-r--r--gcc/testsuite/g++.dg/other/sse2-pr85572-2.C45
-rw-r--r--gcc/testsuite/g++.dg/other/sse4-pr85572-1.C14
4 files changed, 94 insertions, 0 deletions
diff --git a/gcc/testsuite/g++.dg/other/avx2-pr85572-1.C b/gcc/testsuite/g++.dg/other/avx2-pr85572-1.C
new file mode 100644
index 0000000..adde2ea
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/avx2-pr85572-1.C
@@ -0,0 +1,21 @@
+// PR target/85572
+// { dg-do compile { target i?86-*-* x86_64-*-* } }
+// { dg-options "-O2 -mavx2 -mno-avx512f" }
+// { dg-final { scan-assembler-times {\mvpxor\M} 4 } }
+// { dg-final { scan-assembler-times {\mvpcmpgtq\M} 2 } }
+// { dg-final { scan-assembler-times {\mvpsubq\M} 2 } }
+
+typedef long long V __attribute__((vector_size (16)));
+typedef long long W __attribute__((vector_size (32)));
+
+V
+foo (V x)
+{
+ return x < 0 ? -x : x;
+}
+
+W
+bar (W x)
+{
+ return x < 0 ? -x : x;
+}
diff --git a/gcc/testsuite/g++.dg/other/sse2-pr85572-1.C b/gcc/testsuite/g++.dg/other/sse2-pr85572-1.C
new file mode 100644
index 0000000..e4c4423
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/sse2-pr85572-1.C
@@ -0,0 +1,14 @@
+// PR target/85572
+// { dg-do compile { target i?86-*-* x86_64-*-* } }
+// { dg-options "-O2 -msse2 -mno-sse3" }
+// { dg-final { scan-assembler-times {\mpxor\M} 2 } }
+// { dg-final { scan-assembler-times {\mpsubq\M} 2 } }
+// { dg-final { scan-assembler-times {\mpsrlq\M} 1 } }
+
+typedef long long V __attribute__((vector_size (16)));
+
+V
+foo (V x)
+{
+ return x < 0 ? -x : x;
+}
diff --git a/gcc/testsuite/g++.dg/other/sse2-pr85572-2.C b/gcc/testsuite/g++.dg/other/sse2-pr85572-2.C
new file mode 100644
index 0000000..8eb399b
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/sse2-pr85572-2.C
@@ -0,0 +1,45 @@
+// PR target/85572
+// { dg-do run { target i?86-*-* x86_64-*-* } }
+// { dg-options "-O2 -msse2" }
+// { dg-require-effective-target sse2_runtime }
+
+typedef long long V __attribute__((vector_size (16)));
+typedef long long W __attribute__((vector_size (32)));
+
+__attribute__((noipa)) V
+foo (V x)
+{
+ return x < 0 ? -x : x;
+}
+
+__attribute__((noipa)) void
+bar (W *x, W *y)
+{
+ *y = *x < 0 ? -*x : *x;
+}
+
+int
+main ()
+{
+ V a = { 11LL, -15LL };
+ V b = foo (a);
+ if (b[0] != 11LL || b[1] != 15LL)
+ __builtin_abort ();
+ V c = { -123456789123456LL, 654321654321654LL };
+ V d = foo (c);
+ if (d[0] != 123456789123456LL || d[1] != 654321654321654LL)
+ __builtin_abort ();
+ V e = { 0, 1 };
+ V f = foo (e);
+ if (f[0] != 0 || f[1] != 1)
+ __builtin_abort ();
+ W g = { 17LL, -32LL, -123456789123456LL, 654321654321654LL }, h;
+ bar (&g, &h);
+ if (h[0] != 17LL || h[1] != 32LL
+ || h[2] != 123456789123456LL || h[3] != 654321654321654LL)
+ __builtin_abort ();
+ W i = { 0, 1, -1, 0 }, j;
+ bar (&i, &j);
+ if (j[0] != 0 || j[1] != 1 || j[2] != 1 || j[3] != 0)
+ __builtin_abort ();
+}
diff --git a/gcc/testsuite/g++.dg/other/sse4-pr85572-1.C b/gcc/testsuite/g++.dg/other/sse4-pr85572-1.C
new file mode 100644
index 0000000..fe0adae
--- /dev/null
+++ b/gcc/testsuite/g++.dg/other/sse4-pr85572-1.C
@@ -0,0 +1,14 @@
+// PR target/85572
+// { dg-do compile { target i?86-*-* x86_64-*-* } }
+// { dg-options "-O2 -msse4 -mno-avx" }
+// { dg-final { scan-assembler-times {\mpxor\M} 2 } }
+// { dg-final { scan-assembler-times {\mpcmpgtq\M} 1 } }
+// { dg-final { scan-assembler-times {\mpsubq\M} 1 } }
+
+typedef long long V __attribute__((vector_size (16)));
+
+V
+foo (V x)
+{
+ return x < 0 ? -x : x;
+}