aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite
diff options
context:
space:
mode:
authorMartin Jambor <mjambor@suse.cz>2016-05-23 13:45:13 +0200
committerMartin Jambor <jamborm@gcc.gnu.org>2016-05-23 13:45:13 +0200
commita50575432b41b3bc3b0a14cb2e6e53881941a99f (patch)
treef960a48373fb98e3c858fff7a8c978dc5d1c6c7e /libgomp/testsuite
parente569db5fb5fece9f9a3ee09e3dc7c58f0db36e40 (diff)
downloadgcc-a50575432b41b3bc3b0a14cb2e6e53881941a99f.zip
gcc-a50575432b41b3bc3b0a14cb2e6e53881941a99f.tar.gz
gcc-a50575432b41b3bc3b0a14cb2e6e53881941a99f.tar.bz2
[hsa] Avoid segfault in hsa switch expansion
2016-05-23 Martin Jambor <mjambor@suse.cz> * hsa-gen.c (gen_hsa_insns_for_switch_stmt): Create an empty default block if a PHI node in the original one would be resized. libgomp/ * testsuite/libgomp.hsa.c/switch-sbr-2.c: New test. From-SVN: r236585
Diffstat (limited to 'libgomp/testsuite')
-rw-r--r--libgomp/testsuite/libgomp.hsa.c/switch-sbr-2.c59
1 files changed, 59 insertions, 0 deletions
diff --git a/libgomp/testsuite/libgomp.hsa.c/switch-sbr-2.c b/libgomp/testsuite/libgomp.hsa.c/switch-sbr-2.c
new file mode 100644
index 0000000..06990d1
--- /dev/null
+++ b/libgomp/testsuite/libgomp.hsa.c/switch-sbr-2.c
@@ -0,0 +1,59 @@
+/* { dg-additional-options "-fno-tree-switch-conversion" } */
+
+#pragma omp declare target
+int
+foo (unsigned a)
+{
+ switch (a)
+ {
+ case 1 ... 5:
+ return 1;
+ case 9 ... 11:
+ return a + 3;
+ case 12 ... 13:
+ return a + 3;
+ default:
+ return 44;
+ }
+}
+#pragma omp end declare target
+
+#define s 100
+
+void __attribute__((noinline, noclone))
+verify(int *a)
+{
+ if (a[0] != 44)
+ __builtin_abort ();
+
+ for (int i = 1; i <= 5; i++)
+ if (a[i] != 1)
+ __builtin_abort ();
+
+ for (int i = 6; i <= 8; i++)
+ if (a[i] != 44)
+ __builtin_abort ();
+
+ for (int i = 9; i <= 13; i++)
+ if (a[i] != i + 3)
+ __builtin_abort ();
+
+ for (int i = 14; i < s; i++)
+ if (a[i] != 44)
+ __builtin_abort ();
+}
+
+int main(int argc)
+{
+ int array[s];
+#pragma omp target
+ {
+ for (int i = 0; i < s; i++)
+ {
+ int v = foo (i);
+ array[i] = v;
+ }
+ }
+ verify (array);
+ return 0;
+}