summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2015-02-11 14:44:10 +0000
committerjakub <jakub@138bc75d-0d04-0410-961f-82ee72b054a4>2015-02-11 14:44:10 +0000
commit32c64c49214e44d0ac5132e8db2ab0fd1a716746 (patch)
tree860c37bea2b616ca2e03b5772a687e15b39b4ea3
parent82d9a902f91233f6e42aa8224e2ba0e7256d9282 (diff)
downloadgcc-32c64c49214e44d0ac5132e8db2ab0fd1a716746.tar.gz
Backported from mainline
2015-02-04 Jakub Jelinek <jakub@redhat.com> PR c/64824 PR c/64868 * c-omp.c (c_finish_omp_atomic): Use TRUNC_DIV_EXPR instead of RDIV_EXPR. Use build_binary_op instead of build2_loc. * c-parser.c (c_parser_omp_atomic): Handle RDIV_EXPR. * parser.c (cp_parser_omp_atomic): Handle RDIV_EXPR. * testsuite/libgomp.c/pr64824.c: New test. * testsuite/libgomp.c/pr64868.c: New test. * testsuite/libgomp.c++/pr64824.C: New test. * testsuite/libgomp.c++/pr64868.C: New test. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/branches/gcc-4_9-branch@220622 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--gcc/c-family/ChangeLog11
-rw-r--r--gcc/c-family/c-omp.c5
-rw-r--r--gcc/c/ChangeLog9
-rw-r--r--gcc/c/c-parser.c1
-rw-r--r--gcc/cp/ChangeLog9
-rw-r--r--gcc/cp/parser.c1
-rw-r--r--libgomp/ChangeLog12
-rw-r--r--libgomp/testsuite/libgomp.c++/pr64824.C5
-rw-r--r--libgomp/testsuite/libgomp.c++/pr64868.C5
-rw-r--r--libgomp/testsuite/libgomp.c/pr64824.c16
-rw-r--r--libgomp/testsuite/libgomp.c/pr64868.c87
11 files changed, 160 insertions, 1 deletions
diff --git a/gcc/c-family/ChangeLog b/gcc/c-family/ChangeLog
index b1dc3406913..76cf06a2ab2 100644
--- a/gcc/c-family/ChangeLog
+++ b/gcc/c-family/ChangeLog
@@ -1,3 +1,14 @@
+2015-02-11 Jakub Jelinek <jakub@redhat.com>
+
+ Backported from mainline
+ 2015-02-04 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/64824
+ PR c/64868
+ * c-omp.c (c_finish_omp_atomic): Use TRUNC_DIV_EXPR
+ instead of RDIV_EXPR. Use build_binary_op instead of
+ build2_loc.
+
2015-02-11 Richard Biener <rguenther@suse.de>
Backport from mainline
diff --git a/gcc/c-family/c-omp.c b/gcc/c-family/c-omp.c
index 6a0e41988a7..bdcedb22e81 100644
--- a/gcc/c-family/c-omp.c
+++ b/gcc/c-family/c-omp.c
@@ -156,6 +156,9 @@ c_finish_omp_atomic (location_t loc, enum tree_code code,
return error_mark_node;
}
+ if (opcode == RDIV_EXPR)
+ opcode = TRUNC_DIV_EXPR;
+
/* ??? Validate that rhs does not overlap lhs. */
/* Take and save the address of the lhs. From then on we'll reference it
@@ -190,7 +193,7 @@ c_finish_omp_atomic (location_t loc, enum tree_code code,
to do this, and then take it apart again. */
if (swapped)
{
- rhs = build2_loc (loc, opcode, TREE_TYPE (lhs), rhs, lhs);
+ rhs = build_binary_op (loc, opcode, rhs, lhs, 1);
opcode = NOP_EXPR;
}
bool save = in_late_binary_op;
diff --git a/gcc/c/ChangeLog b/gcc/c/ChangeLog
index 57be674171d..972ea357279 100644
--- a/gcc/c/ChangeLog
+++ b/gcc/c/ChangeLog
@@ -1,3 +1,12 @@
+2015-02-11 Jakub Jelinek <jakub@redhat.com>
+
+ Backported from mainline
+ 2015-02-04 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/64824
+ PR c/64868
+ * c-parser.c (c_parser_omp_atomic): Handle RDIV_EXPR.
+
2015-02-01 Jakub Jelinek <jakub@redhat.com>
Backported from mainline
diff --git a/gcc/c/c-parser.c b/gcc/c/c-parser.c
index 264c17026eb..66a9a16c7a8 100644
--- a/gcc/c/c-parser.c
+++ b/gcc/c/c-parser.c
@@ -11423,6 +11423,7 @@ restart:
{
case MULT_EXPR:
case TRUNC_DIV_EXPR:
+ case RDIV_EXPR:
case PLUS_EXPR:
case MINUS_EXPR:
case LSHIFT_EXPR:
diff --git a/gcc/cp/ChangeLog b/gcc/cp/ChangeLog
index 83bf91d54bc..61640dd8e8a 100644
--- a/gcc/cp/ChangeLog
+++ b/gcc/cp/ChangeLog
@@ -1,3 +1,12 @@
+2015-02-11 Jakub Jelinek <jakub@redhat.com>
+
+ Backported from mainline
+ 2015-02-04 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/64824
+ PR c/64868
+ * parser.c (cp_parser_omp_atomic): Handle RDIV_EXPR.
+
2015-02-04 Ville Voutilainen <ville.voutilainen@gmail.com>
PR c++/64901
diff --git a/gcc/cp/parser.c b/gcc/cp/parser.c
index 93f94d260c1..18c706846ba 100644
--- a/gcc/cp/parser.c
+++ b/gcc/cp/parser.c
@@ -28748,6 +28748,7 @@ restart:
{
case MULT_EXPR:
case TRUNC_DIV_EXPR:
+ case RDIV_EXPR:
case PLUS_EXPR:
case MINUS_EXPR:
case LSHIFT_EXPR:
diff --git a/libgomp/ChangeLog b/libgomp/ChangeLog
index 81c62da380b..39f693d8d55 100644
--- a/libgomp/ChangeLog
+++ b/libgomp/ChangeLog
@@ -1,3 +1,15 @@
+2015-02-11 Jakub Jelinek <jakub@redhat.com>
+
+ Backported from mainline
+ 2015-02-04 Jakub Jelinek <jakub@redhat.com>
+
+ PR c/64824
+ PR c/64868
+ * testsuite/libgomp.c/pr64824.c: New test.
+ * testsuite/libgomp.c/pr64868.c: New test.
+ * testsuite/libgomp.c++/pr64824.C: New test.
+ * testsuite/libgomp.c++/pr64868.C: New test.
+
2015-01-23 Jakub Jelinek <jakub@redhat.com>
PR middle-end/64734
diff --git a/libgomp/testsuite/libgomp.c++/pr64824.C b/libgomp/testsuite/libgomp.c++/pr64824.C
new file mode 100644
index 00000000000..348f6d6e0c2
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c++/pr64824.C
@@ -0,0 +1,5 @@
+// PR c/64824
+// { dg-do run }
+// { dg-options "-O2 -fopenmp" }
+
+#include "../libgomp.c/pr64824.c"
diff --git a/libgomp/testsuite/libgomp.c++/pr64868.C b/libgomp/testsuite/libgomp.c++/pr64868.C
new file mode 100644
index 00000000000..2d730ac4924
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c++/pr64868.C
@@ -0,0 +1,5 @@
+// PR c/64868
+// { dg-do run }
+// { dg-options "-O2 -fopenmp" }
+
+#include "../libgomp.c/pr64868.c"
diff --git a/libgomp/testsuite/libgomp.c/pr64824.c b/libgomp/testsuite/libgomp.c/pr64824.c
new file mode 100644
index 00000000000..544d0b0fc1f
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c/pr64824.c
@@ -0,0 +1,16 @@
+/* PR c/64824 */
+/* { dg-do run } */
+/* { dg-options "-O2 -fopenmp" } */
+
+int
+main ()
+{
+ long long a;
+ long long b = 1LL;
+ int c = 3;
+#pragma omp atomic capture
+ a = b = c << b;
+ if (b != 6LL || a != 6LL)
+ __builtin_abort ();
+ return 0;
+}
diff --git a/libgomp/testsuite/libgomp.c/pr64868.c b/libgomp/testsuite/libgomp.c/pr64868.c
new file mode 100644
index 00000000000..acdf9984108
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c/pr64868.c
@@ -0,0 +1,87 @@
+/* PR c/64868 */
+/* { dg-do run } */
+/* { dg-options "-O2 -fopenmp" } */
+
+float f = 2.0f;
+double d = 4.0;
+long double ld = 8.0L;
+
+void
+foo ()
+{
+#pragma omp atomic
+ f = 1.0f / f;
+#pragma omp atomic
+ f = 1 / f;
+#pragma omp atomic
+ f = f / 2.0f;
+#pragma omp atomic
+ f = f / 2;
+#pragma omp atomic
+ f /= 2.0f;
+#pragma omp atomic
+ f /= 2;
+#pragma omp atomic
+ d = 1.0 / d;
+#pragma omp atomic
+ d = 1 / d;
+#pragma omp atomic
+ d = d / 2.0;
+#pragma omp atomic
+ d = d / 2;
+#pragma omp atomic
+ d /= 2.0;
+#pragma omp atomic
+ d /= 2;
+#pragma omp atomic
+ ld = 1.0L / ld;
+#pragma omp atomic
+ ld = 1 / ld;
+#pragma omp atomic
+ ld = ld / 2.0L;
+#pragma omp atomic
+ ld = ld / 2;
+#pragma omp atomic
+ ld /= 2.0L;
+#pragma omp atomic
+ ld /= 2;
+ if (f != 0.125f || d != 0.25 || ld != 0.5L)
+ __builtin_abort ();
+}
+
+#ifdef __cplusplus
+template <typename T, int N1, int N2>
+void
+bar ()
+{
+ T v = ::d;
+#pragma omp atomic
+ v *= 16;
+#pragma omp atomic
+ v = 1.0 / v;
+#pragma omp atomic
+ v = N1 / v;
+#pragma omp atomic
+ v = v / 2.0;
+#pragma omp atomic
+ v = v / N2;
+#pragma omp atomic
+ v /= 2.0;
+#pragma omp atomic
+ v /= N2;
+ if (v != 0.25)
+ __builtin_abort ();
+}
+#endif
+
+int
+main ()
+{
+ foo ();
+#ifdef __cplusplus
+ bar<float, 1, 2> ();
+ bar<double, 1, 2> ();
+ bar<long double, 1, 2> ();
+#endif
+ return 0;
+}