Backports to 7.5 (part 1)

Jakub Jelinek jakub@redhat.com
Fri Aug 30 14:27:00 GMT 2019


Hi!

I've backported 97 commits from trunk to 7.5, bootstrapped/regtested them on
x86_64-linux and i686-linux and committed.
Here is the first half of them, second half will follow in another mail.

	Jakub
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2018-10-19  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/85488
	PR middle-end/87649
	* omp-low.c (check_omp_nesting_restrictions): Diagnose ordered without
	depend closely nested inside of loop with ordered clause with
	a parameter.

	* c-c++-common/gomp/doacross-2.c: New test.
	* c-c++-common/gomp/sink-3.c: Expect another error during error
	recovery.

--- gcc/omp-low.c	(revision 265800)
+++ gcc/omp-low.c	(revision 265801)
@@ -2835,14 +2835,25 @@ check_omp_nesting_restrictions (gimple *
 	  case GIMPLE_OMP_FOR:
 	    if (gimple_omp_for_kind (ctx->stmt) == GF_OMP_FOR_KIND_TASKLOOP)
 	      goto ordered_in_taskloop;
-	    if (omp_find_clause (gimple_omp_for_clauses (ctx->stmt),
-				 OMP_CLAUSE_ORDERED) == NULL)
+	    tree o;
+	    o = omp_find_clause (gimple_omp_for_clauses (ctx->stmt),
+				 OMP_CLAUSE_ORDERED);
+	    if (o == NULL)
 	      {
 		error_at (gimple_location (stmt),
 			  "%<ordered%> region must be closely nested inside "
 			  "a loop region with an %<ordered%> clause");
 		return false;
 	      }
+	    if (OMP_CLAUSE_ORDERED_EXPR (o) != NULL_TREE
+		&& omp_find_clause (c, OMP_CLAUSE_DEPEND) == NULL_TREE)
+	      {
+		error_at (gimple_location (stmt),
+			  "%<ordered%> region without %<depend%> clause may "
+			  "not be closely nested inside a loop region with "
+			  "an %<ordered%> clause with a parameter");
+		return false;
+	      }
 	    return true;
 	  case GIMPLE_OMP_TARGET:
 	    if (gimple_omp_target_kind (ctx->stmt)
--- gcc/testsuite/c-c++-common/gomp/sink-3.c	(revision 265800)
+++ gcc/testsuite/c-c++-common/gomp/sink-3.c	(revision 265801)
@@ -14,7 +14,7 @@ foo ()
   for (i=0; i < 100; ++i)
     {
 #pragma omp ordered depend(sink:poo-1,paa+1) /* { dg-error "poo.*declared.*paa.*declared" } */
-    bar(&i);
+    bar(&i);				     /* { dg-error "may not be closely nested" "" { target *-*-* } .-1 } */
 #pragma omp ordered depend(source)
     }
 }
--- gcc/testsuite/c-c++-common/gomp/doacross-2.c	(nonexistent)
+++ gcc/testsuite/c-c++-common/gomp/doacross-2.c	(revision 265801)
@@ -0,0 +1,49 @@
+/* PR middle-end/87649 */
+
+void
+foo (void)
+{
+  int i;
+  #pragma omp for ordered(1)
+  for (i = 0; i < 64; i++)
+    {
+      #pragma omp ordered			/* { dg-error "'ordered' region without 'depend' clause may not be closely nested inside a loop region with an 'ordered' clause with a parameter" } */
+      ;
+    }
+  #pragma omp for ordered(1)
+  for (i = 0; i < 64; i++)
+    {
+      #pragma omp ordered threads		/* { dg-error "'ordered' region without 'depend' clause may not be closely nested inside a loop region with an 'ordered' clause with a parameter" } */
+      ;
+    }
+}
+
+void
+bar (void)
+{
+  int i;
+  #pragma omp for ordered
+  for (i = 0; i < 64; i++)
+    {
+      #pragma omp ordered depend(source)	/* { dg-error "'ordered' construct with 'depend' clause must be closely nested inside a loop with 'ordered' clause with a parameter" } */
+      #pragma omp ordered depend(sink: i - 1)	/* { dg-error "'ordered' construct with 'depend' clause must be closely nested inside a loop with 'ordered' clause with a parameter" } */
+    }
+  #pragma omp for
+  for (i = 0; i < 64; i++)
+    {
+      #pragma omp ordered depend(source)	/* { dg-error "'ordered' construct with 'depend' clause must be closely nested inside a loop with 'ordered' clause with a parameter" } */
+      #pragma omp ordered depend(sink: i - 1)	/* { dg-error "'ordered' construct with 'depend' clause must be closely nested inside a loop with 'ordered' clause with a parameter" } */
+    }
+  #pragma omp for
+  for (i = 0; i < 64; i++)
+    {
+      #pragma omp ordered			/* { dg-error "'ordered' region must be closely nested inside a loop region with an 'ordered' clause" } */
+      ;
+    }
+  #pragma omp for
+  for (i = 0; i < 64; i++)
+    {
+      #pragma omp ordered threads		/* { dg-error "'ordered' region must be closely nested inside a loop region with an 'ordered' clause" } */
+      ;
+    }
+}
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2018-10-20  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/87647
	* varasm.c (decode_addr_const): Handle COMPOUND_LITERAL_EXPR.

	* gcc.c-torture/compile/pr87647.c: New test.

--- gcc/varasm.c	(revision 265801)
+++ gcc/varasm.c	(revision 265802)
@@ -2954,6 +2954,11 @@ decode_addr_const (tree exp, struct addr
 		       gen_rtx_SYMBOL_REF (Pmode, "origin of addresses"));
       break;
 
+    case COMPOUND_LITERAL_EXPR:
+      gcc_assert (COMPOUND_LITERAL_EXPR_DECL (target));
+      x = DECL_RTL (COMPOUND_LITERAL_EXPR_DECL (target));
+      break;
+
     default:
       gcc_unreachable ();
     }
--- gcc/testsuite/gcc.c-torture/compile/pr87647.c	(nonexistent)
+++ gcc/testsuite/gcc.c-torture/compile/pr87647.c	(revision 265802)
@@ -0,0 +1,15 @@
+/* PR middle-end/87647 */
+
+struct A {};
+struct A *const b = &(struct A) {};
+struct B { char *s; struct A *t; };
+void bar (struct B *);
+
+void
+foo (void)
+{
+  struct B a[] = { "", b, "", b, "", b, "", b, "", b, "", b, "", b, "", b,
+		   "", b, "", b, "", b, "", b, "", b, "", b, "", b, "", b,
+		   "", b };
+  bar (a);
+}
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2018-10-25  Jakub Jelinek  <jakub@redhat.com>

	PR fortran/87725
	* openmp.c (gfc_match_omp_clauses): Parse simd, monotonic and
	nonmonotonic modifiers regardless of if they have been parsed
	already or if the opposite one has.  Fix up check whether
	comma after modifier should be parsed.
	(resolve_omp_clauses): Diagnose schedule modifier restrictions.

	* c-c++-common/gomp/schedule-modifiers-1.c (bar): Separate modifier
	from kind with a colon rather than comma.
	* gfortran.dg/gomp/schedule-modifiers-1.f90: New test.
	* gfortran.dg/gomp/schedule-modifiers-2.f90: New test.

--- gcc/fortran/openmp.c	(revision 265804)
+++ gcc/fortran/openmp.c	(revision 265805)
@@ -1705,22 +1705,17 @@ gfc_match_omp_clauses (gfc_omp_clauses *
 	      locus old_loc2 = gfc_current_locus;
 	      do
 		{
-		  if (!c->sched_simd
-		      && gfc_match ("simd") == MATCH_YES)
+		  if (gfc_match ("simd") == MATCH_YES)
 		    {
 		      c->sched_simd = true;
 		      nmodifiers++;
 		    }
-		  else if (!c->sched_monotonic
-			   && !c->sched_nonmonotonic
-			   && gfc_match ("monotonic") == MATCH_YES)
+		  else if (gfc_match ("monotonic") == MATCH_YES)
 		    {
 		      c->sched_monotonic = true;
 		      nmodifiers++;
 		    }
-		  else if (!c->sched_monotonic
-			   && !c->sched_nonmonotonic
-			   && gfc_match ("nonmonotonic") == MATCH_YES)
+		  else if (gfc_match ("nonmonotonic") == MATCH_YES)
 		    {
 		      c->sched_nonmonotonic = true;
 		      nmodifiers++;
@@ -1731,7 +1726,7 @@ gfc_match_omp_clauses (gfc_omp_clauses *
 			gfc_current_locus = old_loc2;
 		      break;
 		    }
-		  if (nmodifiers == 0
+		  if (nmodifiers == 1
 		      && gfc_match (" , ") == MATCH_YES)
 		    continue;
 		  else if (gfc_match (" : ") == MATCH_YES)
@@ -4068,6 +4063,30 @@ resolve_omp_clauses (gfc_code *code, gfc
 	gfc_warning (0, "INTEGER expression of SCHEDULE clause's chunk_size "
 		     "at %L must be positive", &expr->where);
     }
+  if (omp_clauses->sched_kind != OMP_SCHED_NONE
+      && omp_clauses->sched_nonmonotonic)
+    {
+      if (omp_clauses->sched_kind != OMP_SCHED_DYNAMIC
+	  && omp_clauses->sched_kind != OMP_SCHED_GUIDED)
+	{
+	  const char *p;
+	  switch (omp_clauses->sched_kind)
+	    {
+	    case OMP_SCHED_STATIC: p = "STATIC"; break;
+	    case OMP_SCHED_RUNTIME: p = "RUNTIME"; break;
+	    case OMP_SCHED_AUTO: p = "AUTO"; break;
+	    default: gcc_unreachable ();
+	    }
+	  gfc_error ("NONMONOTONIC modifier specified for %s schedule kind "
+		     "at %L", p, &code->loc);
+	}
+      else if (omp_clauses->sched_monotonic)
+	gfc_error ("Both MONOTONIC and NONMONOTONIC schedule modifiers "
+		   "specified at %L", &code->loc);
+      else if (omp_clauses->ordered)
+	gfc_error ("NONMONOTONIC schedule modifier specified with ORDERED "
+		   "clause at %L", &code->loc);
+    }
 
   /* Check that no symbol appears on multiple clauses, except that
      a symbol can appear on both firstprivate and lastprivate.  */
--- gcc/testsuite/c-c++-common/gomp/schedule-modifiers-1.c	(revision 265804)
+++ gcc/testsuite/c-c++-common/gomp/schedule-modifiers-1.c	(revision 265805)
@@ -80,21 +80,21 @@ bar (void)
   #pragma omp for schedule (nonmonotonic : auto)	/* { dg-error ".nonmonotonic. modifier specified for .auto. schedule kind" } */
   for (i = 0; i < 64; i++)
     ;
-  #pragma omp for schedule (nonmonotonic, dynamic) ordered	/* { dg-error ".nonmonotonic. schedule modifier specified together with .ordered. clause" } */
+  #pragma omp for schedule (nonmonotonic : dynamic) ordered	/* { dg-error ".nonmonotonic. schedule modifier specified together with .ordered. clause" } */
   for (i = 0; i < 64; i++)
     #pragma omp ordered
       ;
-  #pragma omp for ordered schedule(nonmonotonic, dynamic, 5)	/* { dg-error ".nonmonotonic. schedule modifier specified together with .ordered. clause" } */
+  #pragma omp for ordered schedule(nonmonotonic : dynamic, 5)	/* { dg-error ".nonmonotonic. schedule modifier specified together with .ordered. clause" } */
   for (i = 0; i < 64; i++)
     #pragma omp ordered
       ;
-  #pragma omp for schedule (nonmonotonic, guided) ordered(1)	/* { dg-error ".nonmonotonic. schedule modifier specified together with .ordered. clause" } */
+  #pragma omp for schedule (nonmonotonic : guided) ordered(1)	/* { dg-error ".nonmonotonic. schedule modifier specified together with .ordered. clause" } */
   for (i = 0; i < 64; i++)
     {
       #pragma omp ordered depend(sink: i - 1)
       #pragma omp ordered depend(source)
     }
-  #pragma omp for ordered(1) schedule(nonmonotonic, guided, 2)	/* { dg-error ".nonmonotonic. schedule modifier specified together with .ordered. clause" } */
+  #pragma omp for ordered(1) schedule(nonmonotonic : guided, 2)	/* { dg-error ".nonmonotonic. schedule modifier specified together with .ordered. clause" } */
   for (i = 0; i < 64; i++)
     {
       #pragma omp ordered depend(source)
--- gcc/testsuite/gfortran.dg/gomp/schedule-modifiers-1.f90	(nonexistent)
+++ gcc/testsuite/gfortran.dg/gomp/schedule-modifiers-1.f90	(revision 265805)
@@ -0,0 +1,63 @@
+! { dg-do compile }
+! { dg-options "-fopenmp" }
+
+subroutine foo
+  integer :: i
+  !$omp do simd schedule (simd, simd: static, 5)
+  do i = 0, 64
+  end do
+  !$omp do simd schedule (monotonic, simd: static)
+  do i = 0, 64
+  end do
+  !$omp do simd schedule (simd , monotonic : static, 6)
+  do i = 0, 64
+  end do
+  !$omp do schedule (monotonic, monotonic : static, 7)
+  do i = 0, 64
+  end do
+  !$omp do schedule (nonmonotonic, nonmonotonic : dynamic)
+  do i = 0, 64
+  end do
+  !$omp do simd schedule (nonmonotonic , simd : dynamic, 3)
+  do i = 0, 64
+  end do
+  !$omp do simd schedule (nonmonotonic,simd:guided,4)
+  do i = 0, 64
+  end do
+  !$omp do schedule (monotonic: static, 2)
+  do i = 0, 64
+  end do
+  !$omp do schedule (monotonic : static)
+  do i = 0, 64
+  end do
+  !$omp do schedule (monotonic : dynamic)
+  do i = 0, 64
+  end do
+  !$omp do schedule (monotonic : dynamic, 3)
+  do i = 0, 64
+  end do
+  !$omp do schedule (monotonic : guided)
+  do i = 0, 64
+  end do
+  !$omp do schedule (monotonic : guided, 7)
+  do i = 0, 64
+  end do
+  !$omp do schedule (monotonic : runtime)
+  do i = 0, 64
+  end do
+  !$omp do schedule (monotonic : auto)
+  do i = 0, 64
+  end do
+  !$omp do schedule (nonmonotonic : dynamic)
+  do i = 0, 64
+  end do
+  !$omp do schedule (nonmonotonic : dynamic, 3)
+  do i = 0, 64
+  end do
+  !$omp do schedule (nonmonotonic : guided)
+  do i = 0, 64
+  end do
+  !$omp do schedule (nonmonotonic : guided, 7)
+  do i = 0, 64
+  end do
+end subroutine foo
--- gcc/testsuite/gfortran.dg/gomp/schedule-modifiers-2.f90	(nonexistent)
+++ gcc/testsuite/gfortran.dg/gomp/schedule-modifiers-2.f90	(revision 265805)
@@ -0,0 +1,44 @@
+! { dg-do compile }
+! { dg-options "-fopenmp" }
+
+subroutine foo
+  integer :: i
+  !$omp do schedule (nonmonotonic: static, 2)	! { dg-error "NONMONOTONIC modifier specified for STATIC schedule kind" }
+  do i = 0, 64
+  end do
+  !$omp do schedule (nonmonotonic : static)	! { dg-error "NONMONOTONIC modifier specified for STATIC schedule kind" }
+  do i = 0, 64
+  end do
+  !$omp do schedule (nonmonotonic : runtime)	! { dg-error "NONMONOTONIC modifier specified for RUNTIME schedule kind" }
+  do i = 0, 64
+  end do
+  !$omp do schedule (nonmonotonic : auto)	! { dg-error "NONMONOTONIC modifier specified for AUTO schedule kind" }
+  do i = 0, 64
+  end do
+  !$omp do schedule (nonmonotonic : dynamic) ordered	! { dg-error "NONMONOTONIC schedule modifier specified with ORDERED clause" }
+  do i = 0, 64
+    !$omp ordered
+    !$omp end ordered
+  end do
+  !$omp do ordered schedule(nonmonotonic : dynamic, 5)	! { dg-error "NONMONOTONIC schedule modifier specified with ORDERED clause" }
+  do i = 0, 64
+    !$omp ordered
+    !$omp end ordered
+  end do
+  !$omp do schedule (nonmonotonic : guided) ordered(1)	! { dg-error "NONMONOTONIC schedule modifier specified with ORDERED clause" }
+  do i = 0, 64
+    !$omp ordered depend(sink: i - 1)
+    !$omp ordered depend(source)
+  end do
+  !$omp do ordered(1) schedule(nonmonotonic : guided, 2)	! { dg-error "NONMONOTONIC schedule modifier specified with ORDERED clause" }
+  do i = 0, 64
+    !$omp ordered depend(source)
+    !$ordered depend(sink: i - 1)
+  end do
+  !$omp do schedule (nonmonotonic , monotonic : dynamic)	! { dg-error "Both MONOTONIC and NONMONOTONIC schedule modifiers specified" }
+  do i = 0, 64
+  end do
+  !$omp do schedule (monotonic,nonmonotonic:dynamic)	! { dg-error "Both MONOTONIC and NONMONOTONIC schedule modifiers specified" }
+  do i = 0, 64
+  end do
+end subroutine foo
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>
 
	Backported from mainline
	2018-11-19  Jakub Jelinek  <jakub@redhat.com>

	PR c++/60994
	* g++.dg/lookup/pr60994.C: New test.
 
--- gcc/testsuite/g++.dg/lookup/pr60994.C	(nonexistent)
+++ gcc/testsuite/g++.dg/lookup/pr60994.C	(revision 267681)
@@ -0,0 +1,13 @@
+// PR c++/60994
+// { dg-do compile }
+
+struct s
+{
+  static int i;
+};
+
+template <typename T>
+int s()
+{
+  return s::i;	// { dg-bogus "is not a class" }
+}
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2018-11-20  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/87895
	* omp-simd-clone.c (ipa_simd_modify_function_body): When removing
	or replacing GIMPLE_RETURN, set EDGE_FALLTHRU on the edge to EXIT.
	(simd_clone_adjust): Don't set EDGE_FALLTHRU here. In a loop that
	redirects edges to EXIT to edges to incr_bb, iterate while EXIT
	has any preds and always use EDGE_PRED (, 0).

	* gcc.dg/gomp/pr87895-1.c: New test.
	* gcc.dg/gomp/pr87895-2.c: New test.
	* gcc.dg/gomp/pr87895-3.c: New test.

--- gcc/omp-simd-clone.c	(revision 267683)
+++ gcc/omp-simd-clone.c	(revision 267684)
@@ -996,6 +996,8 @@ ipa_simd_modify_function_body (struct cg
 	  if (greturn *return_stmt = dyn_cast <greturn *> (stmt))
 	    {
 	      tree retval = gimple_return_retval (return_stmt);
+	      edge e = find_edge (bb, EXIT_BLOCK_PTR_FOR_FN (cfun));
+	      e->flags |= EDGE_FALLTHRU;
 	      if (!retval)
 		{
 		  gsi_remove (&gsi, true);
@@ -1152,14 +1154,9 @@ simd_clone_adjust (struct cgraph_node *n
       incr_bb = create_empty_bb (orig_exit);
       incr_bb->count = profile_count::zero ();
       add_bb_to_loop (incr_bb, body_bb->loop_father);
-      /* The succ of orig_exit was EXIT_BLOCK_PTR_FOR_FN (cfun), with an empty
-	 flag.  Set it now to be a FALLTHRU_EDGE.  */
-      gcc_assert (EDGE_COUNT (orig_exit->succs) == 1);
-      EDGE_SUCC (orig_exit, 0)->flags |= EDGE_FALLTHRU;
-      for (unsigned i = 0;
-	   i < EDGE_COUNT (EXIT_BLOCK_PTR_FOR_FN (cfun)->preds); ++i)
+      while (EDGE_COUNT (EXIT_BLOCK_PTR_FOR_FN (cfun)->preds))
 	{
-	  edge e = EDGE_PRED (EXIT_BLOCK_PTR_FOR_FN (cfun), i);
+	  edge e = EDGE_PRED (EXIT_BLOCK_PTR_FOR_FN (cfun), 0);
 	  redirect_edge_succ (e, incr_bb);
 	  incr_bb->count += e->count ();
 	}
--- gcc/testsuite/gcc.dg/gomp/pr87895-1.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/gomp/pr87895-1.c	(revision 267684)
@@ -0,0 +1,19 @@
+/* PR tree-optimization/87895 */
+/* { dg-do compile } */
+/* { dg-additional-options "-O0" } */
+
+#pragma omp declare simd
+int
+foo (int x)
+{
+  if (x == 0)
+    return 0;
+}
+
+#pragma omp declare simd
+int
+bar (int *x, int y)
+{
+  if ((y == 0) ? (*x = 0) : *x)
+    return 0;
+}
--- gcc/testsuite/gcc.dg/gomp/pr87895-2.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/gomp/pr87895-2.c	(revision 267684)
@@ -0,0 +1,5 @@
+/* PR tree-optimization/87895 */
+/* { dg-do compile } */
+/* { dg-additional-options "-O1" } */
+
+#include "pr87895-1.c"
--- gcc/testsuite/gcc.dg/gomp/pr87895-3.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/gomp/pr87895-3.c	(revision 267684)
@@ -0,0 +1,18 @@
+/* PR tree-optimization/87895 */
+/* { dg-do compile } */
+/* { dg-additional-options "-O2" } */
+
+#pragma omp declare simd
+int foo (int x) __attribute__((noreturn));
+
+#pragma omp declare simd
+int
+bar (int x, int y)
+{
+  if (y == 1)
+    foo (x + 2);
+  if (y == 10)
+    foo (x + 6);
+  if (y != 25)
+    return 4;
+}
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2018-11-27  Jakub Jelinek  <jakub@redhat.com>

	PR c++/88181
	* class.c (fixup_attribute_variants): Also propagate TYPE_PACKED
	to variants.

	* g++.dg/debug/pr88181.C: New test.

--- gcc/cp/class.c	(revision 267688)
+++ gcc/cp/class.c	(revision 267689)
@@ -1957,6 +1957,7 @@ fixup_attribute_variants (tree t)
   unsigned align = TYPE_ALIGN (t);
   bool user_align = TYPE_USER_ALIGN (t);
   bool may_alias = lookup_attribute ("may_alias", attrs);
+  bool packed = TYPE_PACKED (t);
 
   if (may_alias)
     fixup_may_alias (t);
@@ -1974,6 +1975,7 @@ fixup_attribute_variants (tree t)
       else
 	TYPE_USER_ALIGN (variants) = user_align;
       SET_TYPE_ALIGN (variants, valign);
+      TYPE_PACKED (variants) = packed;
       if (may_alias)
 	fixup_may_alias (variants);
     }
--- gcc/testsuite/g++.dg/debug/pr88181.C	(nonexistent)
+++ gcc/testsuite/g++.dg/debug/pr88181.C	(revision 267689)
@@ -0,0 +1,29 @@
+// PR c++/88181
+// { dg-do compile }
+// { dg-options "-fpack-struct -g -std=c++11" }
+
+template <typename T> struct A { typedef T B; };
+template <typename...> class C;
+template <typename e> struct D { constexpr D (e) {} };
+template <int, typename...> struct E;
+template <int N, typename T, typename... U>
+struct E<N, T, U...> : E<1, U...>, D<T> {
+  constexpr E (T x, U... y) : E<1, U...>(y...), D<T>(x) {}
+};
+template <int N, typename T> struct E<N, T> : D<T> {
+  constexpr E (T x) : D<T>(x) {}
+};
+template <typename T, typename U> struct C<T, U> : E<0, T, U> {
+  constexpr C (T x, U y) : E<0, T, U>(x, y) {}
+  void operator= (typename A<const C>::B);
+};
+struct F {};
+struct G {};
+
+int
+main ()
+{
+  F f;
+  G g;
+  constexpr C<F, G> c(f, g);
+}
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2018-11-30  Jakub Jelinek  <jakub@redhat.com>

	PR debug/85550
	* g++.dg/debug/dwarf2/pr85550.C: New test.

--- gcc/testsuite/g++.dg/debug/dwarf2/pr85550.C	(nonexistent)
+++ gcc/testsuite/g++.dg/debug/dwarf2/pr85550.C	(revision 267693)
@@ -0,0 +1,17 @@
+// PR debug/85550
+// { dg-do link }
+// { dg-options "-O2 -g -fdebug-types-section" }
+
+struct A {
+  int bar () const { return 0; }
+};
+template <int (A::*foo)() const>
+struct B {
+};
+
+B<&A::bar> b;
+
+int
+main ()
+{
+}
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2018-12-03  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/71109
	* gcc.c-torture/compile/pr71109.c: New test.

--- gcc/testsuite/gcc.c-torture/compile/pr71109.c	(nonexistent)
+++ gcc/testsuite/gcc.c-torture/compile/pr71109.c	(revision 267694)
@@ -0,0 +1,31 @@
+/* PR tree-optimization/71109 */
+
+struct S { int g, h; signed char i; int j; signed char k; int l[4]; } a, c;
+struct T { signed char g; } e;
+int *b, d;
+static void foo ();
+
+void
+bar (void)
+{
+  while (d)
+    {
+      int k;
+      struct T f[3];
+      foo (bar, a);
+      for (k = 0;; k++)
+	f[k] = e;
+    }
+}
+
+static inline void
+foo (int x, struct S y, struct T z)
+{
+  for (z.g = 2; z.g; z.g--)
+    {
+      c = a = y;
+      *b |= 6;
+      if (y.g)
+	break;
+    }
+}
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>
 
	Backported from mainline
	2018-12-04  Jakub Jelinek  <jakub@redhat.com>

	PR c++/88103
	* typeck.c (build_class_member_access_expr): If unary_complex_lvalue
	turned xvalue_p into non-xvalue_p, call move on it.

	* g++.dg/cpp0x/rv-cond3.C: New test.

--- gcc/cp/typeck.c	(revision 267694)
+++ gcc/cp/typeck.c	(revision 267695)
@@ -2362,7 +2362,13 @@ build_class_member_access_expr (cp_expr
   {
     tree temp = unary_complex_lvalue (ADDR_EXPR, object);
     if (temp)
-      object = cp_build_indirect_ref (temp, RO_NULL, complain);
+      {
+	temp = cp_build_indirect_ref (temp, RO_NULL, complain);
+	if (xvalue_p (object) && !xvalue_p (temp))
+	  /* Preserve xvalue kind.  */
+	  temp = move (temp);
+	object = temp;
+      }
   }
 
   /* In [expr.ref], there is an explicit list of the valid choices for
--- gcc/testsuite/g++.dg/cpp0x/rv-cond3.C	(nonexistent)
+++ gcc/testsuite/g++.dg/cpp0x/rv-cond3.C	(revision 267695)
@@ -0,0 +1,22 @@
+// PR c++/88103
+// { dg-do compile { target c++11 } }
+
+struct A {
+  A (int);
+  A&& foo () &&;
+  int i;
+};
+void free (A&&);
+
+void test_xvalue (A a){
+  A&& ref = true ? static_cast<A&&> (a) : static_cast<A&&> (a); 
+  free (true ? static_cast<A&&> (a) : static_cast<A&&> (a));
+  (true ? static_cast<A&&> (a) : static_cast<A&&> (a)).foo ();
+  int&& k = (true ? static_cast<A&&> (a) : static_cast<A&&> (a)).i;
+}
+void test_prvalue (A a){
+  A&& ref = true ? static_cast<A&&> (a) : 1; 
+  free (true ? static_cast<A&&> (a) : 1);
+  (true ? static_cast<A&&> (a) : 1).foo ();
+  int&& k = (true ? static_cast<A&&> (a) : 1).i;
+}
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2018-12-07  Jakub Jelinek  <jakub@redhat.com>

	PR c++/87506
	* constexpr.c (adjust_temp_type): Handle EMPTY_CLASS_EXPR.

	* g++.dg/cpp0x/constexpr-87506.C: New test.

--- gcc/cp/constexpr.c	(revision 267698)
+++ gcc/cp/constexpr.c	(revision 267699)
@@ -1252,6 +1252,8 @@ adjust_temp_type (tree type, tree temp)
   /* Avoid wrapping an aggregate value in a NOP_EXPR.  */
   if (TREE_CODE (temp) == CONSTRUCTOR)
     return build_constructor (type, CONSTRUCTOR_ELTS (temp));
+  if (TREE_CODE (temp) == EMPTY_CLASS_EXPR)
+    return build0 (EMPTY_CLASS_EXPR, type);
   gcc_assert (scalarish_type_p (type));
   return cp_fold_convert (type, temp);
 }
--- gcc/testsuite/g++.dg/cpp0x/constexpr-87506.C	(nonexistent)
+++ gcc/testsuite/g++.dg/cpp0x/constexpr-87506.C	(revision 267699)
@@ -0,0 +1,12 @@
+// PR c++/87506
+// { dg-do compile { target c++11 } }
+
+struct A {};
+struct B { constexpr B (const A) {} };
+struct C : B { using B::B; };
+
+void
+foo ()
+{
+  C c (A{});
+}
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2018-12-07  Jakub Jelinek  <jakub@redhat.com>

	PR fortran/88377
	* trans-openmp.c (gfc_omp_clause_default_ctor,
	gfc_omp_clause_copy_ctor, gfc_omp_clause_assign_op,
	gfc_omp_clause_linear_ctor, gfc_omp_clause_dtor): Only consider
	GFC_DECL_GET_SCALAR_ALLOCATABLE vars as scalar allocatables if they
	have pointer type.

	* gfortran.dg/gomp/pr88377.f90: New test.

--- gcc/fortran/trans-openmp.c	(revision 267699)
+++ gcc/fortran/trans-openmp.c	(revision 267700)
@@ -460,7 +460,8 @@ gfc_omp_clause_default_ctor (tree clause
 
   if ((! GFC_DESCRIPTOR_TYPE_P (type)
        || GFC_TYPE_ARRAY_AKIND (type) != GFC_ARRAY_ALLOCATABLE)
-      && !GFC_DECL_GET_SCALAR_ALLOCATABLE (OMP_CLAUSE_DECL (clause)))
+      && (!GFC_DECL_GET_SCALAR_ALLOCATABLE (OMP_CLAUSE_DECL (clause))
+	  || !POINTER_TYPE_P (type)))
     {
       if (gfc_has_alloc_comps (type, OMP_CLAUSE_DECL (clause)))
 	{
@@ -567,7 +568,8 @@ gfc_omp_clause_copy_ctor (tree clause, t
 
   if ((! GFC_DESCRIPTOR_TYPE_P (type)
        || GFC_TYPE_ARRAY_AKIND (type) != GFC_ARRAY_ALLOCATABLE)
-      && !GFC_DECL_GET_SCALAR_ALLOCATABLE (OMP_CLAUSE_DECL (clause)))
+      && (!GFC_DECL_GET_SCALAR_ALLOCATABLE (OMP_CLAUSE_DECL (clause))
+	  || !POINTER_TYPE_P (type)))
     {
       if (gfc_has_alloc_comps (type, OMP_CLAUSE_DECL (clause)))
 	{
@@ -667,7 +669,8 @@ gfc_omp_clause_assign_op (tree clause, t
 
   if ((! GFC_DESCRIPTOR_TYPE_P (type)
        || GFC_TYPE_ARRAY_AKIND (type) != GFC_ARRAY_ALLOCATABLE)
-      && !GFC_DECL_GET_SCALAR_ALLOCATABLE (OMP_CLAUSE_DECL (clause)))
+      && (!GFC_DECL_GET_SCALAR_ALLOCATABLE (OMP_CLAUSE_DECL (clause))
+	  || !POINTER_TYPE_P (type)))
     {
       if (gfc_has_alloc_comps (type, OMP_CLAUSE_DECL (clause)))
 	{
@@ -905,7 +908,8 @@ gfc_omp_clause_linear_ctor (tree clause,
 
   if ((! GFC_DESCRIPTOR_TYPE_P (type)
        || GFC_TYPE_ARRAY_AKIND (type) != GFC_ARRAY_ALLOCATABLE)
-      && !GFC_DECL_GET_SCALAR_ALLOCATABLE (OMP_CLAUSE_DECL (clause)))
+      && (!GFC_DECL_GET_SCALAR_ALLOCATABLE (OMP_CLAUSE_DECL (clause))
+	  || !POINTER_TYPE_P (type)))
     {
       gcc_assert (TREE_CODE (type) == ARRAY_TYPE);
       if (!TYPE_DOMAIN (type)
@@ -989,7 +993,8 @@ gfc_omp_clause_dtor (tree clause, tree d
 
   if ((! GFC_DESCRIPTOR_TYPE_P (type)
        || GFC_TYPE_ARRAY_AKIND (type) != GFC_ARRAY_ALLOCATABLE)
-      && !GFC_DECL_GET_SCALAR_ALLOCATABLE (OMP_CLAUSE_DECL (clause)))
+      && (!GFC_DECL_GET_SCALAR_ALLOCATABLE (OMP_CLAUSE_DECL (clause))
+	  || !POINTER_TYPE_P (type)))
     {
       if (gfc_has_alloc_comps (type, OMP_CLAUSE_DECL (clause)))
 	return gfc_walk_alloc_comps (decl, NULL_TREE,
--- gcc/testsuite/gfortran.dg/gomp/pr88377.f90	(nonexistent)
+++ gcc/testsuite/gfortran.dg/gomp/pr88377.f90	(revision 267700)
@@ -0,0 +1,15 @@
+! PR fortran/88377
+! { dg-do compile }
+
+program pr88377
+  call s(3)
+contains
+  subroutine s(n)
+    integer :: n
+    character(n), allocatable :: x
+    x = 'abc'
+    !$omp task
+    print *, x, (x == 'abc')
+    !$omp end task
+  end
+end
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2018-12-07  Jakub Jelinek  <jakub@redhat.com>

	PR target/85593
	* final.c (rest_of_handle_final): Don't call collect_fn_hard_reg_usage
	for functions with naked attribute.

--- gcc/final.c	(revision 267700)
+++ gcc/final.c	(revision 267701)
@@ -4490,7 +4490,11 @@ rest_of_handle_final (void)
   assemble_start_function (current_function_decl, fnname);
   final_start_function (get_insns (), asm_out_file, optimize);
   final (get_insns (), asm_out_file, optimize);
-  if (flag_ipa_ra)
+  if (flag_ipa_ra
+      /* Functions with naked attributes are supported only with basic asm
+	 statements in the body, thus for supported use cases the information
+	 on clobbered registers is not available.  */
+      && !lookup_attribute ("naked", DECL_ATTRIBUTES (current_function_decl)))
     collect_fn_hard_reg_usage ();
   final_end_function ();
 
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2018-12-07  Jakub Jelinek  <jakub@redhat.com>

	PR c++/86669
	* call.c (make_temporary_var_for_ref_to_temp): Call pushdecl even for
	automatic vars.

	* g++.dg/cpp0x/initlist105.C: New test.
	* g++.dg/cpp0x/initlist106.C: New test.
	* g++.dg/other/pr86669.C: New test.

--- gcc/cp/call.c	(revision 267701)
+++ gcc/cp/call.c	(revision 267702)
@@ -10301,8 +10301,11 @@ make_temporary_var_for_ref_to_temp (tree
       var = pushdecl_top_level (var);
     }
   else
-    /* Create a new cleanup level if necessary.  */
-    maybe_push_cleanup_level (type);
+    {
+      /* Create a new cleanup level if necessary.  */
+      maybe_push_cleanup_level (type);
+      var = pushdecl (var);
+    }
 
   return var;
 }
--- gcc/testsuite/g++.dg/cpp0x/initlist105.C	(nonexistent)
+++ gcc/testsuite/g++.dg/cpp0x/initlist105.C	(revision 267702)
@@ -0,0 +1,28 @@
+// PR c++/86669
+// { dg-do run { target c++11 } }
+
+#include <initializer_list>
+
+struct S { S (); };
+struct T : public S {};
+int cnt;
+void foo (int) { cnt++; }
+
+S::S ()
+{
+  int e = 1, f = 2, g = 3, h = 4;
+
+  for (auto k : { e, f, g, h })
+    foo (k);
+}
+
+int
+main ()
+{
+  S s;
+  if (cnt != 4)
+    __builtin_abort ();
+  T t;
+  if (cnt != 8)
+    __builtin_abort ();
+}
--- gcc/testsuite/g++.dg/cpp0x/initlist106.C	(nonexistent)
+++ gcc/testsuite/g++.dg/cpp0x/initlist106.C	(revision 267702)
@@ -0,0 +1,29 @@
+// PR c++/86669
+// { dg-do run { target c++11 } }
+
+#include <initializer_list>
+
+struct A { };
+struct S : virtual public A { S (); };
+struct T : public S, virtual public A {};
+int cnt;
+void foo (int) { cnt++; }
+
+S::S ()
+{
+  int e = 1, f = 2, g = 3, h = 4;
+
+  for (auto k : { e, f, g, h })
+    foo (k);
+}
+
+int
+main ()
+{
+  S s;
+  if (cnt != 4)
+    __builtin_abort ();
+  T t;
+  if (cnt != 8)
+    __builtin_abort ();
+}
--- gcc/testsuite/g++.dg/other/pr86669.C	(nonexistent)
+++ gcc/testsuite/g++.dg/other/pr86669.C	(revision 267702)
@@ -0,0 +1,10 @@
+// PR c++/86669
+// { dg-do compile }
+
+struct S { S (); };
+struct T : public S {};
+
+S::S ()
+{
+  int *p = { (int *) &p };
+}
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2018-12-13  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/88416
	* valtrack.c (cleanup_auto_inc_dec): Handle pre/post-inc/dec/modify
	even if !AUTO_INC_DEC.

	* gcc.target/i386/pr88416.c: New test.

--- gcc/valtrack.c	(revision 267705)
+++ gcc/valtrack.c	(revision 267706)
@@ -56,8 +56,6 @@ static rtx
 cleanup_auto_inc_dec (rtx src, machine_mode mem_mode ATTRIBUTE_UNUSED)
 {
   rtx x = src;
-  if (!AUTO_INC_DEC)
-    return copy_rtx (x);
 
   const RTX_CODE code = GET_CODE (x);
   int i;
--- gcc/testsuite/gcc.target/i386/pr88416.c	(nonexistent)
+++ gcc/testsuite/gcc.target/i386/pr88416.c	(revision 267706)
@@ -0,0 +1,5 @@
+/* PR rtl-optimization/88416 */
+/* { dg-do compile } */
+/* { dg-options "-O1 -fvar-tracking-assignments -fno-forward-propagate --param max-cse-insns=1" } */
+
+#include "writeeflags-1.c"
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2018-12-13  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/88470
	* cfgcleanup.c (outgoing_edges_match): If the function is
	shrink-wrapped and bb1 ends with a JUMP_INSN with a single fake
	edge to EXIT, return false.

	* gcc.target/i386/pr88470.c: New test.

--- gcc/cfgcleanup.c	(revision 267706)
+++ gcc/cfgcleanup.c	(revision 267707)
@@ -1592,10 +1592,13 @@ outgoing_edges_match (int mode, basic_bl
   if (crtl->shrink_wrapped
       && single_succ_p (bb1)
       && single_succ (bb1) == EXIT_BLOCK_PTR_FOR_FN (cfun)
-      && !JUMP_P (BB_END (bb1))
+      && (!JUMP_P (BB_END (bb1))
+	  /* Punt if the only successor is a fake edge to exit, the jump
+	     must be some weird one.  */
+	  || (single_succ_edge (bb1)->flags & EDGE_FAKE) != 0)
       && !(CALL_P (BB_END (bb1)) && SIBLING_CALL_P (BB_END (bb1))))
     return false;
-  
+
   /* If BB1 has only one successor, we may be looking at either an
      unconditional jump, or a fake edge to exit.  */
   if (single_succ_p (bb1)
--- gcc/testsuite/gcc.target/i386/pr88470.c	(nonexistent)
+++ gcc/testsuite/gcc.target/i386/pr88470.c	(revision 267707)
@@ -0,0 +1,16 @@
+/* PR rtl-optimization/88470 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -maccumulate-outgoing-args -ftrapv -fno-ivopts -fno-reorder-blocks-and-partition" } */
+
+void
+foo (long x, long *y)
+{
+  long *a = y - 64, i;
+  for (i = 0; i < x; i++)
+    {
+      long v = y[i];
+      *a++ = v;
+    }
+  register void **c __asm__ ("di");
+  goto **c;
+}
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2018-12-21  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/88563
	* expr.c (expand_expr_real_2) <case WIDEN_MULT_EXPR>: Swap innermode
	and mode arguments to convert_modes.  Likewise swap mode and word_mode
	arguments.  Handle both arguments with VOIDmode before convert_modes
	of one of them.  Formatting fixes.

	* gcc.dg/pr88563.c: New test.

--- gcc/expr.c	(revision 267713)
+++ gcc/expr.c	(revision 267714)
@@ -8671,7 +8671,7 @@ expand_expr_real_2 (sepops ops, rtx targ
 	  machine_mode innermode = TYPE_MODE (TREE_TYPE (treeop0));
 	  this_optab = usmul_widen_optab;
 	  if (find_widening_optab_handler (this_optab, mode, innermode, 0)
-		!= CODE_FOR_nothing)
+	      != CODE_FOR_nothing)
 	    {
 	      if (TYPE_UNSIGNED (TREE_TYPE (treeop0)))
 		expand_operands (treeop0, treeop1, NULL_RTX, &op0, &op1,
@@ -8683,8 +8683,8 @@ expand_expr_real_2 (sepops ops, rtx targ
 		 != INTEGER_CST check.  Handle it.  */
 	      if (GET_MODE (op0) == VOIDmode && GET_MODE (op1) == VOIDmode)
 		{
-		  op0 = convert_modes (innermode, mode, op0, true);
-		  op1 = convert_modes (innermode, mode, op1, false);
+		  op0 = convert_modes (mode, innermode, op0, true);
+		  op1 = convert_modes (mode, innermode, op1, false);
 		  return REDUCE_BIT_FIELD (expand_mult (mode, op0, op1,
 							target, unsignedp));
 		}
@@ -8706,7 +8706,7 @@ expand_expr_real_2 (sepops ops, rtx targ
 	  if (TREE_CODE (treeop0) != INTEGER_CST)
 	    {
 	      if (find_widening_optab_handler (this_optab, mode, innermode, 0)
-		    != CODE_FOR_nothing)
+		  != CODE_FOR_nothing)
 		{
 		  expand_operands (treeop0, treeop1, NULL_RTX, &op0, &op1,
 				   EXPAND_NORMAL);
@@ -8715,9 +8715,9 @@ expand_expr_real_2 (sepops ops, rtx targ
 		  if (GET_MODE (op0) == VOIDmode && GET_MODE (op1) == VOIDmode)
 		    {
 		     widen_mult_const:
-		      op0 = convert_modes (innermode, mode, op0, zextend_p);
+		      op0 = convert_modes (mode, innermode, op0, zextend_p);
 		      op1
-			= convert_modes (innermode, mode, op1,
+			= convert_modes (mode, innermode, op1,
 					 TYPE_UNSIGNED (TREE_TYPE (treeop1)));
 		      return REDUCE_BIT_FIELD (expand_mult (mode, op0, op1,
 							    target,
@@ -8728,21 +8728,19 @@ expand_expr_real_2 (sepops ops, rtx targ
 		  return REDUCE_BIT_FIELD (temp);
 		}
 	      if (find_widening_optab_handler (other_optab, mode, innermode, 0)
-		    != CODE_FOR_nothing
+		  != CODE_FOR_nothing
 		  && innermode == word_mode)
 		{
 		  rtx htem, hipart;
 		  op0 = expand_normal (treeop0);
-		  if (TREE_CODE (treeop1) == INTEGER_CST)
-		    op1 = convert_modes (innermode, mode,
-					 expand_normal (treeop1),
-					 TYPE_UNSIGNED (TREE_TYPE (treeop1)));
-		  else
-		    op1 = expand_normal (treeop1);
-		  /* op0 and op1 might still be constant, despite the above
+		  op1 = expand_normal (treeop1);
+		  /* op0 and op1 might be constants, despite the above
 		     != INTEGER_CST check.  Handle it.  */
 		  if (GET_MODE (op0) == VOIDmode && GET_MODE (op1) == VOIDmode)
 		    goto widen_mult_const;
+		  if (TREE_CODE (treeop1) == INTEGER_CST)
+		    op1 = convert_modes (mode, word_mode, op1,
+					 TYPE_UNSIGNED (TREE_TYPE (treeop1)));
 		  temp = expand_binop (mode, other_optab, op0, op1, target,
 				       unsignedp, OPTAB_LIB_WIDEN);
 		  hipart = gen_highpart (innermode, temp);
--- gcc/testsuite/gcc.dg/pr88563.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/pr88563.c	(revision 267714)
@@ -0,0 +1,15 @@
+/* PR rtl-optimization/88563 */
+/* { dg-do run { target int128 } } */
+/* { dg-options "-O2 -fno-code-hoisting -fno-tree-ccp -fno-tree-dominator-opts -fno-tree-forwprop -fno-tree-fre -fno-tree-pre -fno-tree-vrp" } */
+
+int
+main ()
+{
+#if __SIZEOF_LONG_LONG__ == 8 && __SIZEOF_INT128__ == 16 && __CHAR_BIT__ == 8
+  unsigned __int128 a = 5;
+  __builtin_mul_overflow (0xffffffffffffffffULL, (unsigned long long) a, &a);
+  if (a != ((unsigned __int128)4 << 64 | 0xfffffffffffffffb))
+    __builtin_abort ();
+#endif
+  return 0;
+}
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2018-12-21  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/85594
	PR middle-end/88553
	* omp-expand.c (extract_omp_for_update_vars): Regimplify the condition
	if needed.
	(expand_omp_for_generic): Don't clobber t temporary for ordered loops.

	* gcc.dg/gomp/pr85594.c: New test.
	* gcc.dg/gomp/pr88553.c: New test.

--- gcc/omp-expand.c	(revision 267715)
+++ gcc/omp-expand.c	(revision 267716)
@@ -1957,6 +1957,11 @@ extract_omp_for_update_vars (struct omp_
 	  t = fold_build2 (fd->loops[i].cond_code, boolean_type_node, v, t);
 	  stmt = gimple_build_cond_empty (t);
 	  gsi_insert_after (&gsi, stmt, GSI_CONTINUE_LINKING);
+	  if (walk_tree (gimple_cond_lhs_ptr (as_a <gcond *> (stmt)),
+			 expand_omp_regimplify_p, NULL, NULL)
+	      || walk_tree (gimple_cond_rhs_ptr (as_a <gcond *> (stmt)),
+			    expand_omp_regimplify_p, NULL, NULL))
+	    gimple_regimplify_operands (stmt, &gsi);
 	  e = make_edge (bb, body_bb, EDGE_TRUE_VALUE);
 	  e->probability = profile_probability::guessed_always ().apply_scale (7, 8);
 	}
@@ -3039,20 +3044,21 @@ expand_omp_for_generic (struct omp_regio
 
 	  if (fd->ordered && counts[fd->collapse - 1] == NULL_TREE)
 	    {
+	      tree tem;
 	      if (fd->collapse > 1)
-		t = fd->loop.v;
+		tem = fd->loop.v;
 	      else
 		{
-		  t = fold_build2 (MINUS_EXPR, TREE_TYPE (fd->loops[0].v),
-				   fd->loops[0].v, fd->loops[0].n1);
-		  t = fold_convert (fd->iter_type, t);
+		  tem = fold_build2 (MINUS_EXPR, TREE_TYPE (fd->loops[0].v),
+				     fd->loops[0].v, fd->loops[0].n1);
+		  tem = fold_convert (fd->iter_type, tem);
 		}
 	      tree aref = build4 (ARRAY_REF, fd->iter_type,
 				  counts[fd->ordered], size_zero_node,
 				  NULL_TREE, NULL_TREE);
-	      t = force_gimple_operand_gsi (&gsi, t, true, NULL_TREE,
-					    true, GSI_SAME_STMT);
-	      expand_omp_build_assign (&gsi, aref, t);
+	      tem = force_gimple_operand_gsi (&gsi, tem, true, NULL_TREE,
+					      true, GSI_SAME_STMT);
+	      expand_omp_build_assign (&gsi, aref, tem);
 	    }
 
 	  t = build2 (fd->loop.cond_code, boolean_type_node,
--- gcc/testsuite/gcc.dg/gomp/pr85594.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/gomp/pr85594.c	(revision 267716)
@@ -0,0 +1,5 @@
+/* PR middle-end/85594 */
+/* { dg-do compile } */
+/* { dg-additional-options "-fwrapv" } */
+
+#include "pr81768-2.c"
--- gcc/testsuite/gcc.dg/gomp/pr88553.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/gomp/pr88553.c	(revision 267716)
@@ -0,0 +1,5 @@
+/* PR middle-end/88553 */
+/* { dg-do compile } */
+/* { dg-additional-options "-O1 -ftree-loop-vectorize -fwrapv" } */
+
+#include "pr81768-2.c"
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2019-01-03  Jakub Jelinek  <jakub@redhat.com>

	PR debug/88644
	* dwarf2out.c (modified_type_die): If type is equal to sizetype,
	change it to qualified_type.

	* gcc.dg/debug/dwarf2/pr88644.c: New test.

	2019-01-03  Iain Sandoe  <iain@sandoe.co.uk>

	* gcc.dg/pubtypes-2.c: Adjust expected pubtypes length.
	* gcc.dg/pubtypes-3.c: Likewise.
	* gcc.dg/pubtypes-4.c: Likewise.

--- gcc/dwarf2out.c	(revision 267717)
+++ gcc/dwarf2out.c	(revision 267718)
@@ -13144,6 +13144,8 @@ modified_type_die (tree type, int cv_qua
 	       && TYPE_PRECISION (sizetype) == TYPE_PRECISION (size_type_node)
 	       && TYPE_UNSIGNED (sizetype) == TYPE_UNSIGNED (size_type_node))
 	qualified_type = size_type_node;
+      if (type == sizetype)
+	type = qualified_type;
     }
 
   /* If we do, then we can just use its DIE, if it exists.  */
--- gcc/testsuite/gcc.dg/debug/dwarf2/pr88644.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/debug/dwarf2/pr88644.c	(revision 267718)
@@ -0,0 +1,7 @@
+/* PR debug/88644 */
+/* { dg-do compile } */
+/* { dg-options "-gdwarf-4 -dA -gpubnames" } */
+
+char array[1];
+
+/* { dg-final { scan-assembler-not {\msizetype} } } */
--- gcc/testsuite/gcc.dg/pubtypes-2.c	(revision 267717)
+++ gcc/testsuite/gcc.dg/pubtypes-2.c	(revision 267718)
@@ -2,7 +2,7 @@
 /* { dg-options "-O0 -gdwarf-2 -dA" } */
 /* { dg-skip-if "Unmatchable assembly" { mmix-*-* } } */
 /* { dg-final { scan-assembler "__debug_pubtypes" } } */
-/* { dg-final { scan-assembler "long+\[ \t\]+0x13b+\[ \t\]+\[#;]+\[ \t\]+Pub Info Length" } } */
+/* { dg-final { scan-assembler "long+\[ \t\]+0x12e+\[ \t\]+\[#;]+\[ \t\]+Pub Info Length" } } */
 /* { dg-final { scan-assembler "used_struct\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */
 /* { dg-final { scan-assembler-not "unused_struct\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */
 
--- gcc/testsuite/gcc.dg/pubtypes-3.c	(revision 267717)
+++ gcc/testsuite/gcc.dg/pubtypes-3.c	(revision 267718)
@@ -2,7 +2,7 @@
 /* { dg-options "-O0 -gdwarf-2 -dA" } */
 /* { dg-skip-if "Unmatchable assembly" { mmix-*-* } } */
 /* { dg-final { scan-assembler "__debug_pubtypes" } } */
-/* { dg-final { scan-assembler "long+\[ \t\]+0x13b+\[ \t\]+\[#;]+\[ \t\]+Pub Info Length" } } */
+/* { dg-final { scan-assembler "long+\[ \t\]+0x12e+\[ \t\]+\[#;]+\[ \t\]+Pub Info Length" } } */
 /* { dg-final { scan-assembler "used_struct\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */
 /* { dg-final { scan-assembler-not "unused_struct\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */
 /* { dg-final { scan-assembler-not "\"list_name_type\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */
--- gcc/testsuite/gcc.dg/pubtypes-4.c	(revision 267717)
+++ gcc/testsuite/gcc.dg/pubtypes-4.c	(revision 267718)
@@ -2,7 +2,7 @@
 /* { dg-options "-O0 -gdwarf-2 -dA" } */
 /* { dg-skip-if "Unmatchable assembly" { mmix-*-* } } */
 /* { dg-final { scan-assembler "__debug_pubtypes" } } */
-/* { dg-final { scan-assembler "long+\[ \t\]+0x172+\[ \t\]+\[#;]+\[ \t\]+Pub Info Length" } } */
+/* { dg-final { scan-assembler "long+\[ \t\]+0x165+\[ \t\]+\[#;]+\[ \t\]+Pub Info Length" } } */
 /* { dg-final { scan-assembler "used_struct\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */
 /* { dg-final { scan-assembler-not "unused_struct\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */
 /* { dg-final { scan-assembler "\"list_name_type\\\\0\"+\[ \t\]+\[#;]+\[ \t\]+external name" } } */
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2019-01-04  Jakub Jelinek  <jakub@redhat.com>

	PR target/88594
	* config/i386/i386.c (ix86_expand_divmod_libfunc): Use mode instead
	of GET_MODE (opN) as modes of the libcall arguments.

	* gcc.dg/pr88594.c: New test.

--- gcc/config/i386/i386.c	(revision 267718)
+++ gcc/config/i386/i386.c	(revision 267719)
@@ -52350,10 +52350,8 @@ ix86_expand_divmod_libfunc (rtx libfunc,
   rtx rem = assign_386_stack_local (mode, SLOT_TEMP);
 
   rtx quot = emit_library_call_value (libfunc, NULL_RTX, LCT_NORMAL,
-				    mode, 3,
-				    op0, GET_MODE (op0),
-				    op1, GET_MODE (op1),
-				    XEXP (rem, 0), Pmode);
+				      mode, 3, op0, mode, op1, mode,
+				      XEXP (rem, 0), Pmode);
   *quot_p = quot;
   *rem_p = rem;
 }
--- gcc/testsuite/gcc.dg/pr88594.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/pr88594.c	(revision 267719)
@@ -0,0 +1,16 @@
+/* PR target/88594 */
+/* { dg-do compile { target int128 } } */
+/* { dg-options "-O2 -fno-tree-dominator-opts -fno-tree-forwprop -fno-tree-vrp" } */
+
+__int128
+foo (__int128 x, __int128 *y)
+{
+  int a;
+  __int128 z, r;
+  for (a = 0; a < 17; ++a)
+    ;
+  z = x / a;
+  r = x % a;
+  *y = z;
+  return r;
+}
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2019-01-05  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/82564
	PR target/88620
	* expr.c (expand_assignment): For calls returning VLA structures
	if to_rtx is not a MEM, force it into a stack temporary.

	* gcc.dg/nested-func-12.c: New test.
	* gcc.c-torture/compile/pr82564.c: New test.

--- gcc/expr.c	(revision 267719)
+++ gcc/expr.c	(revision 267720)
@@ -5230,6 +5230,21 @@ expand_assignment (tree to, tree from, b
 	      emit_move_insn (XEXP (to_rtx, 1), read_complex_part (temp, true));
 	    }
 	}
+      /* For calls to functions returning variable length structures, if TO_RTX
+	 is not a MEM, go through a MEM because we must not create temporaries
+	 of the VLA type.  */
+      else if (!MEM_P (to_rtx)
+	       && TREE_CODE (from) == CALL_EXPR
+	       && COMPLETE_TYPE_P (TREE_TYPE (from))
+	       && TREE_CODE (TYPE_SIZE (TREE_TYPE (from))) != INTEGER_CST)
+	{
+	  rtx temp = assign_stack_temp (GET_MODE (to_rtx),
+					GET_MODE_SIZE (GET_MODE (to_rtx)));
+	  result = store_field (temp, bitsize, bitpos, bitregion_start,
+				bitregion_end, mode1, from, get_alias_set (to),
+				nontemporal, reversep);
+	  emit_move_insn (to_rtx, temp);
+	}
       else
 	{
 	  if (MEM_P (to_rtx))
--- gcc/testsuite/gcc.c-torture/compile/pr82564.c	(nonexistent)
+++ gcc/testsuite/gcc.c-torture/compile/pr82564.c	(revision 267720)
@@ -0,0 +1,15 @@
+/* PR middle-end/82564 */
+/* { dg-require-effective-target alloca } */
+
+int
+main ()
+{
+  int t = 8, i;
+  typedef struct { char v[t]; } B; 
+  B a, b;
+  B __attribute__ ((noinline)) f () { return b; }
+  for (i = 0; i < 8; i++)
+    b.v[i] = i;
+  a = f ();
+  return 0;
+}
--- gcc/testsuite/gcc.dg/nested-func-12.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/nested-func-12.c	(revision 267720)
@@ -0,0 +1,48 @@
+/* PR target/88620 */
+/* { dg-do run } */
+/* { dg-options "-Ofast --param ipa-cp-eval-threshold=0 -fno-guess-branch-probability -fno-inline-small-functions" } */
+/* { dg-require-effective-target alloca } */
+
+void
+foo (int n)
+{
+  struct S { int a[n]; };
+
+  struct S
+  fn (void)
+  {
+    struct S s;
+    s.a[0] = 42;
+    return s;
+  }
+
+  auto struct S
+  fn2 (void)
+  {
+    return fn ();
+  }
+
+  struct S x;
+  fn ();
+  fn2 ();
+  x = fn ();
+
+  if (x.a[0] != 42)
+    __builtin_abort ();
+
+  if (fn ().a[0] != 42)
+    __builtin_abort ();
+
+  __typeof__ (fn ()) *p = &x;
+  if (p->a[0] != 42)
+    __builtin_abort ();
+
+  if (fn2 ().a[0] != 42)
+    __builtin_abort ();
+}
+
+int
+main (void)
+{
+  foo (1);
+}
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2019-01-10  Jakub Jelinek  <jakub@redhat.com>

	PR c/88568
	* tree.c (handle_dll_attribute): Clear TREE_STATIC after setting
	DECL_EXTERNAL.

	* gcc.dg/pr88568.c: New test.

--- gcc/tree.c	(revision 268617)
+++ gcc/tree.c	(revision 268618)
@@ -6456,6 +6456,8 @@ handle_dll_attribute (tree * pnode, tree
 	     a function global scope, unless declared static.  */
 	  if (current_function_decl != NULL_TREE && !TREE_STATIC (node))
 	    TREE_PUBLIC (node) = 1;
+	  /* Clear TREE_STATIC because DECL_EXTERNAL is set.  */
+	  TREE_STATIC (node) = 0;
 	}
 
       if (*no_add_attrs == false)
--- gcc/testsuite/gcc.dg/pr88568.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/pr88568.c	(revision 268618)
@@ -0,0 +1,4 @@
+/* PR c/88568 */
+/* { dg-do compile } */
+/* { dg-require-dll "" } */
+__attribute__((dllimport)) struct S var;	/* { dg-bogus "storage size of .var. isn.t known" } */
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2019-01-17  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/88870
	* dce.c (deletable_insn_p): Never delete const/pure calls that can
	throw if we can't alter the cfg or delete dead exceptions.
	(mark_insn): Don't call find_call_stack_args for such calls.

	* gcc.dg/pr88870.c: New test.

--- gcc/dce.c	(revision 268620)
+++ gcc/dce.c	(revision 268621)
@@ -108,7 +108,10 @@ deletable_insn_p (rtx_insn *insn, bool f
       /* We can delete dead const or pure calls as long as they do not
          infinite loop.  */
       && (RTL_CONST_OR_PURE_CALL_P (insn)
-	  && !RTL_LOOPING_CONST_OR_PURE_CALL_P (insn)))
+	  && !RTL_LOOPING_CONST_OR_PURE_CALL_P (insn))
+      /* Don't delete calls that may throw if we cannot do so.  */
+      && ((cfun->can_delete_dead_exceptions && can_alter_cfg)
+	  || insn_nothrow_p (insn)))
     return find_call_stack_args (as_a <rtx_call_insn *> (insn), false,
 				 fast, arg_stores);
 
@@ -200,7 +203,9 @@ mark_insn (rtx_insn *insn, bool fast)
 	  && !df_in_progress
 	  && !SIBLING_CALL_P (insn)
 	  && (RTL_CONST_OR_PURE_CALL_P (insn)
-	      && !RTL_LOOPING_CONST_OR_PURE_CALL_P (insn)))
+	      && !RTL_LOOPING_CONST_OR_PURE_CALL_P (insn))
+	  && ((cfun->can_delete_dead_exceptions && can_alter_cfg)
+	      || insn_nothrow_p (insn)))
 	find_call_stack_args (as_a <rtx_call_insn *> (insn), true, fast, NULL);
     }
 }
--- gcc/testsuite/gcc.dg/pr88870.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/pr88870.c	(revision 268621)
@@ -0,0 +1,23 @@
+/* PR rtl-optimization/88870 */
+/* { dg-do compile } */
+/* { dg-options "-O1 -fexceptions -fnon-call-exceptions -ftrapv -fno-tree-dominator-opts" } */
+
+int a, b;
+
+void
+foo (int *x)
+{
+  int c = 0;
+  {
+    int d;
+    x = &c;
+    for (;;)
+      {
+        x = &d;
+        b = 0;
+        d = c + 1;
+        b = c = 1;
+        ++a;
+      }
+  }
+}
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2019-01-19  Jakub Jelinek  <jakub@redhat.com>

	PR fortran/88902
	* trans-decl.c (gfc_get_symbol_decl): Don't add length to function
	or parent function if it has been added there already.

	* gfortran.dg/pr88902.f90: New test.

--- gcc/fortran/trans-decl.c	(revision 268622)
+++ gcc/fortran/trans-decl.c	(revision 268623)
@@ -1602,13 +1602,17 @@ gfc_get_symbol_decl (gfc_symbol * sym)
 	  if (VAR_P (length) && DECL_FILE_SCOPE_P (length))
 	    {
 	      /* Add the string length to the same context as the symbol.  */
-	      if (DECL_CONTEXT (sym->backend_decl) == current_function_decl)
-	        gfc_add_decl_to_function (length);
-	      else
-		gfc_add_decl_to_parent_function (length);
+	      if (DECL_CONTEXT (length) == NULL_TREE)
+		{
+		  if (DECL_CONTEXT (sym->backend_decl)
+		      == current_function_decl)
+		    gfc_add_decl_to_function (length);
+		  else
+		    gfc_add_decl_to_parent_function (length);
+		}
 
-	      gcc_assert (DECL_CONTEXT (sym->backend_decl) ==
-			    DECL_CONTEXT (length));
+	      gcc_assert (DECL_CONTEXT (sym->backend_decl)
+			  == DECL_CONTEXT (length));
 
 	      gfc_defer_symbol_init (sym);
 	    }
--- gcc/testsuite/gfortran.dg/pr88902.f90	(nonexistent)
+++ gcc/testsuite/gfortran.dg/pr88902.f90	(revision 268623)
@@ -0,0 +1,6 @@
+! PR fortran/88902
+! { dg-do compile }
+! { dg-require-effective-target lto }
+! { dg-options "-flto --param ggc-min-heapsize=0" }
+
+include 'pr50069_2.f90'
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2019-01-21  Jakub Jelinek  <jakub@redhat.com>

	PR c++/88949
	* optimize.c (cxx_copy_decl): New function.
	(clone_body): Use it instead of copy_decl_no_change.

	* g++.dg/gomp/pr88949.C: New test.

--- gcc/cp/optimize.c	(revision 268624)
+++ gcc/cp/optimize.c	(revision 268625)
@@ -61,6 +61,25 @@ update_cloned_parm (tree parm, tree clon
   DECL_GIMPLE_REG_P (cloned_parm) = DECL_GIMPLE_REG_P (parm);
 }
 
+/* Like copy_decl_no_change, but handle DECL_OMP_PRIVATIZED_MEMBER
+   properly.  */
+
+static tree
+cxx_copy_decl (tree decl, copy_body_data *id)
+{
+  tree copy = copy_decl_no_change (decl, id);
+  if (VAR_P (decl)
+      && DECL_HAS_VALUE_EXPR_P (decl)
+      && DECL_ARTIFICIAL (decl)
+      && DECL_LANG_SPECIFIC (decl)
+      && DECL_OMP_PRIVATIZED_MEMBER (decl))
+    {
+      tree expr = DECL_VALUE_EXPR (copy);
+      walk_tree (&expr, copy_tree_body_r, id, NULL);
+      SET_DECL_VALUE_EXPR (copy, expr);
+    }
+  return copy;
+}
 
 /* FN is a function in High GIMPLE form that has a complete body and no
    CFG.  CLONE is a function whose body is to be set to a copy of FN,
@@ -80,7 +99,7 @@ clone_body (tree clone, tree fn, void *a
   id.src_cfun = DECL_STRUCT_FUNCTION (fn);
   id.decl_map = static_cast<hash_map<tree, tree> *> (arg_map);
 
-  id.copy_decl = copy_decl_no_change;
+  id.copy_decl = cxx_copy_decl;
   id.transform_call_graph_edges = CB_CGE_DUPLICATE;
   id.transform_new_cfg = true;
   id.transform_return_to_modify = false;
--- gcc/testsuite/g++.dg/gomp/pr88949.C	(nonexistent)
+++ gcc/testsuite/g++.dg/gomp/pr88949.C	(revision 268625)
@@ -0,0 +1,23 @@
+// PR c++/88949
+// { dg-do compile }
+
+struct A {
+  int a;
+  A (int x) : a (x) {
+#pragma omp parallel firstprivate (a)
+    --a;
+  }
+  void foo () {
+#pragma omp parallel firstprivate (a)
+    --a;
+  }
+};
+
+int c;
+
+int
+main ()
+{
+  A d(c);
+  d.foo ();
+}
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2019-01-22  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/49429
	PR target/49454
	PR rtl-optimization/86334
	PR target/88906
	* expr.c (emit_block_move_hints): Move marking of MEM_EXPRs
	addressable from here...
	(emit_block_op_via_libcall): ... to here.

	* gcc.target/i386/pr86334.c: New test.
	* gcc.target/i386/pr88906.c: New test.

--- gcc/expr.c	(revision 268625)
+++ gcc/expr.c	(revision 268626)
@@ -1607,18 +1607,8 @@ emit_block_move_hints (rtx x, rtx y, rtx
   else if (may_use_call
 	   && ADDR_SPACE_GENERIC_P (MEM_ADDR_SPACE (x))
 	   && ADDR_SPACE_GENERIC_P (MEM_ADDR_SPACE (y)))
-    {
-      /* Since x and y are passed to a libcall, mark the corresponding
-	 tree EXPR as addressable.  */
-      tree y_expr = MEM_EXPR (y);
-      tree x_expr = MEM_EXPR (x);
-      if (y_expr)
-	mark_addressable (y_expr);
-      if (x_expr)
-	mark_addressable (x_expr);
-      retval = emit_block_copy_via_libcall (x, y, size,
-					    method == BLOCK_OP_TAILCALL);
-    }
+    retval = emit_block_copy_via_libcall (x, y, size,
+					  method == BLOCK_OP_TAILCALL);
 
   else
     emit_block_move_via_loop (x, y, size, align);
@@ -1859,6 +1849,15 @@ emit_block_op_via_libcall (enum built_in
   tree call_expr, dst_tree, src_tree, size_tree;
   machine_mode size_mode;
 
+  /* Since dst and src are passed to a libcall, mark the corresponding
+     tree EXPR as addressable.  */
+  tree dst_expr = MEM_EXPR (dst);
+  tree src_expr = MEM_EXPR (src);
+  if (dst_expr)
+    mark_addressable (dst_expr);
+  if (src_expr)
+    mark_addressable (src_expr);
+
   dst_addr = copy_addr_to_reg (XEXP (dst, 0));
   dst_addr = convert_memory_address (ptr_mode, dst_addr);
   dst_tree = make_tree (ptr_type_node, dst_addr);
--- gcc/testsuite/gcc.target/i386/pr86334.c	(nonexistent)
+++ gcc/testsuite/gcc.target/i386/pr86334.c	(revision 268626)
@@ -0,0 +1,21 @@
+/* PR rtl-optimization/86334 */
+/* { dg-do run { target ia32 } } */
+/* { dg-options "-O -march=i386 -mtune=athlon -minline-all-stringops -minline-stringops-dynamically -mmemcpy-strategy=libcall:-1:align -Wno-psabi" } */
+
+typedef int V __attribute__ ((vector_size (64)));
+
+static inline V
+foo (V g)
+{
+  g[0] = 4;
+  return g;
+}
+
+int
+main ()
+{
+  V x = foo ((V) { });
+  if (x[0] != 4 || x[1] || x[2] || x[3] || x[4] || x[5] || x[6] || x[7])
+    __builtin_abort ();
+  return 0;
+}
--- gcc/testsuite/gcc.target/i386/pr88906.c	(nonexistent)
+++ gcc/testsuite/gcc.target/i386/pr88906.c	(revision 268626)
@@ -0,0 +1,21 @@
+/* PR target/88906 */
+/* { dg-do run { target ia32 } } */
+/* { dg-options "-O -march=i386 -mtune=k6 -minline-all-stringops -minline-stringops-dynamically -mmemcpy-strategy=libcall:-1:align -Wno-psabi" } */
+
+typedef unsigned V __attribute__ ((vector_size (16)));
+
+static inline V
+foo (V v)
+{
+  __builtin_sub_overflow (0, 0, &v[0]);
+  return v;
+}
+
+int
+main ()
+{
+  V v = foo ((V) { ~0 });
+  if (v[0] || v[1] || v[2] || v[3])
+    __builtin_abort ();
+  return 0;
+}
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2019-01-24  Jakub Jelinek  <jakub@redhat.com>

	PR c++/88976
	* semantics.c (finish_omp_cancel): Use maybe_convert_cond when not in
	template or build_x_binary_op otherwise.

	* c-c++-common/gomp/cancel-2.c: New test.
	* gcc.dg/gomp/cancel-1.c: New test.
	* g++.dg/gomp/cancel-1.C: New test.
	* g++.dg/gomp/cancel-2.C: New test.
	* g++.dg/gomp/cancel-3.C: New test.

--- gcc/cp/semantics.c	(revision 268630)
+++ gcc/cp/semantics.c	(revision 268631)
@@ -8518,10 +8518,13 @@ finish_omp_cancel (tree clauses)
   tree ifc = omp_find_clause (clauses, OMP_CLAUSE_IF);
   if (ifc != NULL_TREE)
     {
-      tree type = TREE_TYPE (OMP_CLAUSE_IF_EXPR (ifc));
-      ifc = fold_build2_loc (OMP_CLAUSE_LOCATION (ifc), NE_EXPR,
-			     boolean_type_node, OMP_CLAUSE_IF_EXPR (ifc),
-			     build_zero_cst (type));
+      if (!processing_template_decl)
+	ifc = maybe_convert_cond (OMP_CLAUSE_IF_EXPR (ifc));
+      else
+	ifc = build_x_binary_op (OMP_CLAUSE_LOCATION (ifc), NE_EXPR,
+				 OMP_CLAUSE_IF_EXPR (ifc), ERROR_MARK,
+				 integer_zero_node, ERROR_MARK,
+				 NULL, tf_warning_or_error);
     }
   else
     ifc = boolean_true_node;
--- gcc/testsuite/gcc.dg/gomp/cancel-1.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/gomp/cancel-1.c	(revision 268631)
@@ -0,0 +1,12 @@
+/* { dg-do compile } */
+
+struct S { int s; } s;
+
+void
+foo (void)
+{
+  #pragma omp parallel
+  {
+    #pragma omp cancel parallel if (s)	/* { dg-error "used struct type value where scalar is required" } */
+  }
+}
--- gcc/testsuite/c-c++-common/gomp/cancel-2.c	(nonexistent)
+++ gcc/testsuite/c-c++-common/gomp/cancel-2.c	(revision 268631)
@@ -0,0 +1,10 @@
+/* { dg-do compile } */
+
+void
+foo (void)
+{
+  #pragma omp parallel
+  {
+    #pragma omp cancel parallel if (1) if (1)			/* { dg-error "too many 'if' clauses without modifier" } */
+  }
+}
--- gcc/testsuite/g++.dg/gomp/cancel-1.C	(nonexistent)
+++ gcc/testsuite/g++.dg/gomp/cancel-1.C	(revision 268631)
@@ -0,0 +1,26 @@
+// PR c++/88976
+// { dg-do compile }
+
+template <class T> void
+foo (T x)
+{
+#pragma omp parallel
+  {
+  #pragma omp cancel parallel if (x)
+  }
+#pragma omp parallel
+  {
+  #pragma omp cancel parallel if (1 == 1)
+  }
+}
+
+void
+bar (int x, double y, long long z)
+{
+  foo (0);
+  foo (1LL);
+  foo (1.25);
+  foo (x);
+  foo (y);
+  foo (z);
+}
--- gcc/testsuite/g++.dg/gomp/cancel-2.C	(nonexistent)
+++ gcc/testsuite/g++.dg/gomp/cancel-2.C	(revision 268631)
@@ -0,0 +1,20 @@
+// PR c++/88976
+// { dg-do compile }
+
+template <class T> void
+foo (T x)
+{
+#pragma omp parallel
+  {
+  #pragma omp cancel parallel if (x)	// { dg-error "no match for" }
+  }
+}
+
+struct S {};
+
+void
+bar ()
+{
+  S s;
+  foo (s);
+}
--- gcc/testsuite/g++.dg/gomp/cancel-3.C	(nonexistent)
+++ gcc/testsuite/g++.dg/gomp/cancel-3.C	(revision 268631)
@@ -0,0 +1,12 @@
+// { dg-do compile }
+
+struct S { int s; } s;
+
+void
+foo (void)
+{
+  #pragma omp parallel
+  {
+    #pragma omp cancel parallel if (s)	// { dg-error "could not convert 's' from 'S' to 'bool'" }
+  }
+}
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2019-01-27  Jakub Jelinek  <jakub@redhat.com>

	PR target/87214
	* config/i386/sse.md
	(<mask_codefor>avx512dq_shuf_<shuffletype>64x2_1<mask_name>,
	avx512f_shuf_<shuffletype>64x2_1<mask_name>): Ensure the
	first constants in pairs are multiples of 2.  Formatting fixes.
	(avx512vl_shuf_<shuffletype>32x4_1<mask_name>,
	avx512vl_shuf_<shuffletype>32x4_1<mask_name>): Ensure the
	first constants in each quadruple are multiples of 4.  Formatting fixes.

	* gcc.target/i386/avx512vl-pr87214-1.c: New test.
	* gcc.target/i386/avx512vl-pr87214-2.c: New test.

--- gcc/config/i386/sse.md	(revision 268632)
+++ gcc/config/i386/sse.md	(revision 268633)
@@ -12866,13 +12866,15 @@ (define_insn "<mask_codefor>avx512dq_shu
 	  (vec_concat:<ssedoublemode>
 	    (match_operand:VI8F_256 1 "register_operand" "v")
 	    (match_operand:VI8F_256 2 "nonimmediate_operand" "vm"))
-	  (parallel [(match_operand 3  "const_0_to_3_operand")
-		     (match_operand 4  "const_0_to_3_operand")
-		     (match_operand 5  "const_4_to_7_operand")
-		     (match_operand 6  "const_4_to_7_operand")])))]
+	  (parallel [(match_operand 3 "const_0_to_3_operand")
+		     (match_operand 4 "const_0_to_3_operand")
+		     (match_operand 5 "const_4_to_7_operand")
+		     (match_operand 6 "const_4_to_7_operand")])))]
   "TARGET_AVX512VL
-   && (INTVAL (operands[3]) == (INTVAL (operands[4]) - 1)
-       && INTVAL (operands[5]) == (INTVAL (operands[6]) - 1))"
+   && (INTVAL (operands[3]) & 1) == 0
+   && INTVAL (operands[3]) == INTVAL (operands[4]) - 1
+   && (INTVAL (operands[5]) & 1) == 0
+   && INTVAL (operands[5]) == INTVAL (operands[6]) - 1"
 {
   int mask;
   mask = INTVAL (operands[3]) / 2;
@@ -12915,19 +12917,23 @@ (define_insn "avx512f_shuf_<shuffletype>
 	  (vec_concat:<ssedoublemode>
 	    (match_operand:V8FI 1 "register_operand" "v")
 	    (match_operand:V8FI 2 "nonimmediate_operand" "vm"))
-	  (parallel [(match_operand 3  "const_0_to_7_operand")
-		     (match_operand 4  "const_0_to_7_operand")
-		     (match_operand 5  "const_0_to_7_operand")
-		     (match_operand 6  "const_0_to_7_operand")
-		     (match_operand 7  "const_8_to_15_operand")
-		     (match_operand 8  "const_8_to_15_operand")
-		     (match_operand 9  "const_8_to_15_operand")
-		     (match_operand 10  "const_8_to_15_operand")])))]
+	  (parallel [(match_operand 3 "const_0_to_7_operand")
+		     (match_operand 4 "const_0_to_7_operand")
+		     (match_operand 5 "const_0_to_7_operand")
+		     (match_operand 6 "const_0_to_7_operand")
+		     (match_operand 7 "const_8_to_15_operand")
+		     (match_operand 8 "const_8_to_15_operand")
+		     (match_operand 9 "const_8_to_15_operand")
+		     (match_operand 10 "const_8_to_15_operand")])))]
   "TARGET_AVX512F
-   && (INTVAL (operands[3]) == (INTVAL (operands[4]) - 1)
-       && INTVAL (operands[5]) == (INTVAL (operands[6]) - 1)
-       && INTVAL (operands[7]) == (INTVAL (operands[8]) - 1)
-       && INTVAL (operands[9]) == (INTVAL (operands[10]) - 1))"
+   && (INTVAL (operands[3]) & 1) == 0
+   && INTVAL (operands[3]) == INTVAL (operands[4]) - 1
+   && (INTVAL (operands[5]) & 1) == 0
+   && INTVAL (operands[5]) == INTVAL (operands[6]) - 1
+   && (INTVAL (operands[7]) & 1) == 0
+   && INTVAL (operands[7]) == INTVAL (operands[8]) - 1
+   && (INTVAL (operands[9]) & 1) == 0
+   && INTVAL (operands[9]) == INTVAL (operands[10]) - 1"
 {
   int mask;
   mask = INTVAL (operands[3]) / 2;
@@ -12973,21 +12979,23 @@ (define_insn "avx512vl_shuf_<shuffletype
 	  (vec_concat:<ssedoublemode>
 	    (match_operand:VI4F_256 1 "register_operand" "v")
 	    (match_operand:VI4F_256 2 "nonimmediate_operand" "vm"))
-	  (parallel [(match_operand 3  "const_0_to_7_operand")
-		     (match_operand 4  "const_0_to_7_operand")
-		     (match_operand 5  "const_0_to_7_operand")
-		     (match_operand 6  "const_0_to_7_operand")
-		     (match_operand 7  "const_8_to_15_operand")
-		     (match_operand 8  "const_8_to_15_operand")
-		     (match_operand 9  "const_8_to_15_operand")
+	  (parallel [(match_operand 3 "const_0_to_7_operand")
+		     (match_operand 4 "const_0_to_7_operand")
+		     (match_operand 5 "const_0_to_7_operand")
+		     (match_operand 6 "const_0_to_7_operand")
+		     (match_operand 7 "const_8_to_15_operand")
+		     (match_operand 8 "const_8_to_15_operand")
+		     (match_operand 9 "const_8_to_15_operand")
 		     (match_operand 10 "const_8_to_15_operand")])))]
   "TARGET_AVX512VL
-   && (INTVAL (operands[3]) == (INTVAL (operands[4]) - 1)
-       && INTVAL (operands[3]) == (INTVAL (operands[5]) - 2)
-       && INTVAL (operands[3]) == (INTVAL (operands[6]) - 3)
-       && INTVAL (operands[7]) == (INTVAL (operands[8]) - 1)
-       && INTVAL (operands[7]) == (INTVAL (operands[9]) - 2)
-       && INTVAL (operands[7]) == (INTVAL (operands[10]) - 3))"
+   && (INTVAL (operands[3]) & 3) == 0
+   && INTVAL (operands[3]) == INTVAL (operands[4]) - 1
+   && INTVAL (operands[3]) == INTVAL (operands[5]) - 2
+   && INTVAL (operands[3]) == INTVAL (operands[6]) - 3
+   && (INTVAL (operands[7]) & 3) == 0
+   && INTVAL (operands[7]) == INTVAL (operands[8]) - 1
+   && INTVAL (operands[7]) == INTVAL (operands[9]) - 2
+   && INTVAL (operands[7]) == INTVAL (operands[10]) - 3"
 {
   int mask;
   mask = INTVAL (operands[3]) / 4;
@@ -13039,35 +13047,39 @@ (define_insn "avx512f_shuf_<shuffletype>
 	  (vec_concat:<ssedoublemode>
 	    (match_operand:V16FI 1 "register_operand" "v")
 	    (match_operand:V16FI 2 "nonimmediate_operand" "vm"))
-	  (parallel [(match_operand 3  "const_0_to_15_operand")
-		     (match_operand 4  "const_0_to_15_operand")
-		     (match_operand 5  "const_0_to_15_operand")
-		     (match_operand 6  "const_0_to_15_operand")
-		     (match_operand 7  "const_0_to_15_operand")
-		     (match_operand 8  "const_0_to_15_operand")
-		     (match_operand 9  "const_0_to_15_operand")
-		     (match_operand 10  "const_0_to_15_operand")
-		     (match_operand 11  "const_16_to_31_operand")
-		     (match_operand 12  "const_16_to_31_operand")
-		     (match_operand 13  "const_16_to_31_operand")
-		     (match_operand 14  "const_16_to_31_operand")
-		     (match_operand 15  "const_16_to_31_operand")
-		     (match_operand 16  "const_16_to_31_operand")
-		     (match_operand 17  "const_16_to_31_operand")
-		     (match_operand 18  "const_16_to_31_operand")])))]
+	  (parallel [(match_operand 3 "const_0_to_15_operand")
+		     (match_operand 4 "const_0_to_15_operand")
+		     (match_operand 5 "const_0_to_15_operand")
+		     (match_operand 6 "const_0_to_15_operand")
+		     (match_operand 7 "const_0_to_15_operand")
+		     (match_operand 8 "const_0_to_15_operand")
+		     (match_operand 9 "const_0_to_15_operand")
+		     (match_operand 10 "const_0_to_15_operand")
+		     (match_operand 11 "const_16_to_31_operand")
+		     (match_operand 12 "const_16_to_31_operand")
+		     (match_operand 13 "const_16_to_31_operand")
+		     (match_operand 14 "const_16_to_31_operand")
+		     (match_operand 15 "const_16_to_31_operand")
+		     (match_operand 16 "const_16_to_31_operand")
+		     (match_operand 17 "const_16_to_31_operand")
+		     (match_operand 18 "const_16_to_31_operand")])))]
   "TARGET_AVX512F
-   && (INTVAL (operands[3]) == (INTVAL (operands[4]) - 1)
-       && INTVAL (operands[3]) == (INTVAL (operands[5]) - 2)
-       && INTVAL (operands[3]) == (INTVAL (operands[6]) - 3)
-       && INTVAL (operands[7]) == (INTVAL (operands[8]) - 1)
-       && INTVAL (operands[7]) == (INTVAL (operands[9]) - 2)
-       && INTVAL (operands[7]) == (INTVAL (operands[10]) - 3)
-       && INTVAL (operands[11]) == (INTVAL (operands[12]) - 1)
-       && INTVAL (operands[11]) == (INTVAL (operands[13]) - 2)
-       && INTVAL (operands[11]) == (INTVAL (operands[14]) - 3)
-       && INTVAL (operands[15]) == (INTVAL (operands[16]) - 1)
-       && INTVAL (operands[15]) == (INTVAL (operands[17]) - 2)
-       && INTVAL (operands[15]) == (INTVAL (operands[18]) - 3))"
+   && (INTVAL (operands[3]) & 3) == 0
+   && INTVAL (operands[3]) == INTVAL (operands[4]) - 1
+   && INTVAL (operands[3]) == INTVAL (operands[5]) - 2
+   && INTVAL (operands[3]) == INTVAL (operands[6]) - 3
+   && (INTVAL (operands[7]) & 3) == 0
+   && INTVAL (operands[7]) == INTVAL (operands[8]) - 1
+   && INTVAL (operands[7]) == INTVAL (operands[9]) - 2
+   && INTVAL (operands[7]) == INTVAL (operands[10]) - 3
+   && (INTVAL (operands[11]) & 3) == 0
+   && INTVAL (operands[11]) == INTVAL (operands[12]) - 1
+   && INTVAL (operands[11]) == INTVAL (operands[13]) - 2
+   && INTVAL (operands[11]) == INTVAL (operands[14]) - 3
+   && (INTVAL (operands[15]) & 3) == 0
+   && INTVAL (operands[15]) == INTVAL (operands[16]) - 1
+   && INTVAL (operands[15]) == INTVAL (operands[17]) - 2
+   && INTVAL (operands[15]) == INTVAL (operands[18]) - 3"
 {
   int mask;
   mask = INTVAL (operands[3]) / 4;
--- gcc/testsuite/gcc.target/i386/avx512vl-pr87214-1.c	(nonexistent)
+++ gcc/testsuite/gcc.target/i386/avx512vl-pr87214-1.c	(revision 268633)
@@ -0,0 +1,39 @@
+/* PR target/87214 */
+/* { dg-do run { target { avx512vl } } } */
+/* { dg-options "-O3 -mavx512vl -mtune=skylake-avx512" } */
+
+#define AVX512VL
+#define AVX512F_LEN 512
+#define AVX512F_LEN_HALF 256
+#include "avx512f-check.h"
+
+struct s { unsigned long a, b, c; };
+
+void __attribute__ ((noinline, noclone))
+foo (struct s *restrict s1, struct s *restrict s2, int n)
+{
+  for (int i = 0; i < n; ++i)
+    {
+      s1[i].b = s2[i].b;
+      s1[i].c = s2[i].c;
+      s2[i].c = 0;
+    }
+}
+                            
+#define N 12
+
+static void
+avx512f_test (void)
+{
+  struct s s1[N], s2[N];
+  for (unsigned int j = 0; j < N; ++j)
+    {
+      s2[j].a = j * 5;
+      s2[j].b = j * 5 + 2;
+      s2[j].c = j * 5 + 4;
+    }
+  foo (s1, s2, N);
+  for (unsigned int j = 0; j < N; ++j)
+  if (s1[j].b != j * 5 + 2)
+    __builtin_abort ();
+}
--- gcc/testsuite/gcc.target/i386/avx512vl-pr87214-2.c	(nonexistent)
+++ gcc/testsuite/gcc.target/i386/avx512vl-pr87214-2.c	(revision 268633)
@@ -0,0 +1,123 @@
+/* PR target/87214 */
+/* { dg-do run { target { avx512vl } } } */
+/* { dg-options "-O2 -mavx512vl" } */
+
+#define AVX512VL
+#define AVX512F_LEN 512
+#define AVX512F_LEN_HALF 256
+#include "avx512f-check.h"
+
+typedef long long int v4di __attribute__((vector_size (4 * sizeof (long long int))));
+typedef double v4df __attribute__((vector_size (4 * sizeof (double))));
+typedef long long int v8di __attribute__((vector_size (8 * sizeof (long long int))));
+typedef double v8df __attribute__((vector_size (8 * sizeof (double))));
+typedef int v8si __attribute__((vector_size (8 * sizeof (int))));
+typedef float v8sf __attribute__((vector_size (8 * sizeof (float))));
+typedef int v16si __attribute__((vector_size (16 * sizeof (int))));
+typedef float v16sf __attribute__((vector_size (16 * sizeof (float))));
+
+__attribute__((noinline, noclone)) void
+f1 (v4di *p)
+{
+  p[0] = __builtin_shuffle (p[1], p[2], (v4di) { 2, 3, 5, 6 });
+}
+
+__attribute__((noinline, noclone)) void
+f2 (v4df *p)
+{
+  p[0] = __builtin_shuffle (p[1], p[2], (v4di) { 1, 2, 6, 7 });
+}
+
+__attribute__((noinline, noclone)) void
+f3 (v8di *p)
+{
+  p[0] = __builtin_shuffle (p[1], p[2], (v8di) { 2, 3, 5, 6, 8, 9, 11, 12 });
+}
+
+__attribute__((noinline, noclone)) void
+f4 (v8df *p)
+{
+  p[0] = __builtin_shuffle (p[1], p[2], (v8di) { 1, 2, 6, 7, 9, 10, 12, 13 });
+}
+
+__attribute__((noinline, noclone)) void
+f5 (v8si *p)
+{
+  p[0] = __builtin_shuffle (p[1], p[2], (v8si) { 2, 3, 4, 5, 9, 10, 11, 12 });
+}
+
+__attribute__((noinline, noclone)) void
+f6 (v8sf *p)
+{
+  p[0] = __builtin_shuffle (p[1], p[2], (v8si) { 1, 2, 3, 4, 12, 13, 14, 15 });
+}
+
+__attribute__((noinline, noclone)) void
+f7 (v16si *p)
+{
+  p[0] = __builtin_shuffle (p[1], p[2], (v16si) { 0, 1, 2, 3, 1, 2, 3, 4, 16, 17, 18, 19, 25, 26, 27, 28 });
+}
+
+__attribute__((noinline, noclone)) void
+f8 (v16sf *p)
+{
+  p[0] = __builtin_shuffle (p[1], p[2], (v16si) { 1, 2, 3, 4, 4, 5, 6, 7, 17, 18, 19, 20, 18, 19, 20, 21 });
+}
+
+static void
+avx512f_test (void)
+{
+  v4di a[3] = { { 0, 0, 0, 0 }, { 10, 11, 12, 13 }, { 14, 15, 16, 17 } };
+  f1 (a);
+  if (a[0][0] != 12 || a[0][1] != 13 || a[0][2] != 15 || a[0][3] != 16)
+    __builtin_abort ();
+  v4df b[3] = { { 0.0, 0.0, 0.0, 0.0 }, { 10.0, 11.0, 12.0, 13.0 }, { 14.0, 15.0, 16.0, 17.0 } };
+  f2 (b);
+  if (b[0][0] != 11.0 || b[0][1] != 12.0 || b[0][2] != 16.0 || b[0][3] != 17.0)
+    __builtin_abort ();
+  v8di c[3] = { { 0, 0, 0, 0, 0, 0, 0, 0 }, { 10, 11, 12, 13, 14, 15, 16, 17 }, { 18, 19, 20, 21, 22, 23, 24, 25 } };
+  f3 (c);
+  if (c[0][0] != 12 || c[0][1] != 13 || c[0][2] != 15 || c[0][3] != 16
+      || c[0][4] != 18 || c[0][5] != 19 || c[0][6] != 21 || c[0][7] != 22)
+    __builtin_abort ();
+  v8df d[3] = { { 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 },
+		{ 10.0, 11.0, 12.0, 13.0, 14.0, 15.0, 16.0, 17.0 },
+		{ 18.0, 19.0, 20.0, 21.0, 22.0, 23.0, 24.0, 25.0 } };
+  f4 (d);
+  if (d[0][0] != 11.0 || d[0][1] != 12.0 || d[0][2] != 16.0 || d[0][3] != 17.0
+      || d[0][4] != 19.0 || d[0][5] != 20.0 || d[0][6] != 22.0 || d[0][7] != 23.0)
+    __builtin_abort ();
+  v8si e[3] = { { 0, 0, 0, 0, 0, 0, 0, 0 }, { 10, 11, 12, 13, 14, 15, 16, 17 }, { 18, 19, 20, 21, 22, 23, 24, 25 } };
+  f5 (e);
+  if (e[0][0] != 12 || e[0][1] != 13 || e[0][2] != 14 || e[0][3] != 15
+      || e[0][4] != 19 || e[0][5] != 20 || e[0][6] != 21 || e[0][7] != 22)
+    __builtin_abort ();
+  v8sf f[3] = { { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
+		{ 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f },
+		{ 18.0f, 19.0f, 20.0f, 21.0f, 22.0f, 23.0f, 24.0f, 25.0f } };
+  f6 (f);
+  if (f[0][0] != 11.0f || f[0][1] != 12.0f || f[0][2] != 13.0f || f[0][3] != 14.0f
+      || f[0][4] != 22.0f || f[0][5] != 23.0f || f[0][6] != 24.0f || f[0][7] != 25.0f)
+    __builtin_abort ();
+  v16si g[3] = { { 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
+		 { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 },
+		 { 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41 } };
+  f7 (g);
+  if (g[0][0] != 10 || g[0][1] != 11 || g[0][2] != 12 || g[0][3] != 13
+      || g[0][4] != 11 || g[0][5] != 12 || g[0][6] != 13 || g[0][7] != 14
+      || g[0][8] != 26 || g[0][9] != 27 || g[0][10] != 28 || g[0][11] != 29
+      || g[0][12] != 35 || g[0][13] != 36 || g[0][14] != 37 || g[0][15] != 38)
+    __builtin_abort ();
+  v16sf h[3] = { { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
+		   0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f },
+		 { 10.0f, 11.0f, 12.0f, 13.0f, 14.0f, 15.0f, 16.0f, 17.0f,
+		   18.0f, 19.0f, 20.0f, 21.0f, 22.0f, 23.0f, 24.0f, 25.0f },
+		 { 26.0f, 27.0f, 28.0f, 29.0f, 30.0f, 31.0f, 32.0f, 33.0f,
+		   34.0f, 35.0f, 36.0f, 37.0f, 38.0f, 39.0f, 40.0f, 41.0f } };
+  f8 (h);
+  if (h[0][0] != 11.0f || h[0][1] != 12.0f || h[0][2] != 13.0f || h[0][3] != 14.0f
+      || h[0][4] != 14.0f || h[0][5] != 15.0f || h[0][6] != 16.0f || h[0][7] != 17.0f
+      || h[0][8] != 27.0f || h[0][9] != 28.0f || h[0][10] != 29.0f || h[0][11] != 30.0f
+      || h[0][12] != 28.0f || h[0][13] != 29.0f || h[0][14] != 30.0f || h[0][15] != 31.0f)
+    __builtin_abort ();
+}
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2019-01-28  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/89002
	* gimplify.c (gimplify_omp_for): When adding OMP_CLAUSE_*_GIMPLE_SEQ
	for lastprivate/linear IV, push gimplify context around gimplify_assign
	and, if it needed any temporaries, pop it into a gimple bind around the
	sequence.

	* testsuite/libgomp.c/pr89002.c: New test.

--- gcc/gimplify.c	(revision 268634)
+++ gcc/gimplify.c	(revision 268635)
@@ -10314,8 +10314,17 @@ gimplify_omp_for (tree *expr_p, gimple_s
 		  seq = &OMP_CLAUSE_LASTPRIVATE_GIMPLE_SEQ (c);
 		else
 		  seq = &OMP_CLAUSE_LINEAR_GIMPLE_SEQ (c);
+		push_gimplify_context ();
 		gimplify_assign (decl, t, seq);
-	    }
+		gimple *bind = NULL;
+		if (gimplify_ctxp->temps)
+		  {
+		    bind = gimple_build_bind (NULL_TREE, *seq, NULL_TREE);
+		    *seq = NULL;
+		    gimplify_seq_add_stmt (seq, bind);
+		  }
+		pop_gimplify_context (bind);
+	      }
 	}
     }
 
--- libgomp/testsuite/libgomp.c/pr89002.c	(nonexistent)
+++ libgomp/testsuite/libgomp.c/pr89002.c	(revision 268635)
@@ -0,0 +1,43 @@
+/* PR middle-end/89002 */
+
+extern void abort (void);
+
+int
+foo (int x)
+{
+  int a;
+  int *p = &a;
+
+#pragma omp taskloop lastprivate (a)
+  for (a = 0; a < x; ++a)
+    ;
+  return *p;
+}
+
+int
+bar (int x)
+{
+  int a;
+  int *p = &a;
+
+#pragma omp parallel
+#pragma omp single
+#pragma omp taskloop lastprivate (a)
+  for (a = 0; a < x; ++a)
+    ;
+  return *p;
+}
+
+int
+main ()
+{
+#pragma omp parallel
+#pragma omp single
+  {
+    if (foo (4) != 4)
+      abort ();
+  }
+  if (bar (6) != 6)
+    abort ();
+  return 0;
+}
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2019-01-29  Jakub Jelinek  <jakub@redhat.com>

	PR c++/66676
	PR ipa/89104
	* omp-simd-clone.c (simd_clone_clauses_extract)
	<case OMP_CLAUSE_ALIGNED>: Ignore clauses with NULL
	OMP_CLAUSE_ALIGNED_ALIGNMENT.

	* gcc.dg/gomp/pr89104.c: New test.

--- gcc/omp-simd-clone.c	(revision 268635)
+++ gcc/omp-simd-clone.c	(revision 268636)
@@ -242,6 +242,10 @@ simd_clone_clauses_extract (struct cgrap
 	  }
 	case OMP_CLAUSE_ALIGNED:
 	  {
+	    /* Ignore aligned (x) for declare simd, for the ABI we really
+	       need an alignment specified.  */
+	    if (OMP_CLAUSE_ALIGNED_ALIGNMENT (t) == NULL_TREE)
+	      break;
 	    tree decl = OMP_CLAUSE_DECL (t);
 	    int argno = tree_to_uhwi (decl);
 	    clone_info->args[argno].alignment
--- gcc/testsuite/gcc.dg/gomp/pr89104.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/gomp/pr89104.c	(revision 268636)
@@ -0,0 +1,11 @@
+/* PR c++/66676 */
+/* PR ipa/89104 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fopenmp-simd" } */
+
+#pragma omp declare simd uniform (x) aligned (x)
+int
+foo (int *x, int y)
+{
+  return x[y];
+}
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2019-02-01  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/88107
	* tree-cfg.c (find_outermost_region_in_block): Add ALL argument,
	instead of assertion that eh_region_outermost is non-NULL, if it
	is NULL, set *ALL to true and return NULL.
	(move_sese_region_to_fn): Adjust caller, if all is set, call
	duplicate_eh_regions with NULL region.

	* gcc.dg/gomp/pr88107.c: New test.

--- gcc/tree-cfg.c	(revision 268639)
+++ gcc/tree-cfg.c	(revision 268640)
@@ -7287,11 +7287,14 @@ move_block_to_fn (struct function *dest_
 }
 
 /* Examine the statements in BB (which is in SRC_CFUN); find and return
-   the outermost EH region.  Use REGION as the incoming base EH region.  */
+   the outermost EH region.  Use REGION as the incoming base EH region.
+   If there is no single outermost region, return NULL and set *ALL to
+   true.  */
 
 static eh_region
 find_outermost_region_in_block (struct function *src_cfun,
-				basic_block bb, eh_region region)
+				basic_block bb, eh_region region,
+				bool *all)
 {
   gimple_stmt_iterator si;
 
@@ -7310,7 +7313,11 @@ find_outermost_region_in_block (struct f
 	  else if (stmt_region != region)
 	    {
 	      region = eh_region_outermost (src_cfun, stmt_region, region);
-	      gcc_assert (region != NULL);
+	      if (region == NULL)
+		{
+		  *all = true;
+		  return NULL;
+		}
 	    }
 	}
     }
@@ -7645,12 +7652,17 @@ move_sese_region_to_fn (struct function
   if (saved_cfun->eh)
     {
       eh_region region = NULL;
+      bool all = false;
 
       FOR_EACH_VEC_ELT (bbs, i, bb)
-	region = find_outermost_region_in_block (saved_cfun, bb, region);
+	{
+	  region = find_outermost_region_in_block (saved_cfun, bb, region, &all);
+	  if (all)
+	    break;
+	}
 
       init_eh_for_function ();
-      if (region != NULL)
+      if (region != NULL || all)
 	{
 	  new_label_map = htab_create (17, tree_map_hash, tree_map_eq, free);
 	  eh_map = duplicate_eh_regions (saved_cfun, region, 0,
--- gcc/testsuite/gcc.dg/gomp/pr88107.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/gomp/pr88107.c	(revision 268640)
@@ -0,0 +1,35 @@
+/* PR tree-optimization/88107 */
+/* { dg-do compile { target fgraphite } } */
+/* { dg-require-effective-target vect_simd_clones } */
+/* { dg-options "-O2 -fexceptions -floop-nest-optimize -fnon-call-exceptions -fopenmp-simd -ftree-parallelize-loops=2" } */
+
+#define N 1024
+int a[N], b[N];
+long int c[N];
+unsigned char d[N];
+
+#pragma omp declare simd notinbranch
+__attribute__((noinline)) static int
+foo (long int a, int b, int c)
+{
+  return a + b + c;
+}
+
+#pragma omp declare simd notinbranch
+__attribute__((noinline)) static long int
+bar (int a, int b, long int c)
+{
+  return a + b + c;
+}
+
+void
+baz (void)
+{
+  int i;
+  #pragma omp simd
+  for (i = 0; i < N; i++)
+    a[i] = foo (c[i], a[i], b[i]) + 6;
+  #pragma omp simd
+  for (i = 0; i < N; i++)
+    c[i] = bar (a[i], b[i], c[i]) * 2;
+}
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2019-02-01  Jakub Jelinek  <jakub@redhat.com>

	PR fortran/83246
	PR fortran/89084
	* trans-decl.c (generate_local_decl): Add referenced FL_PARAMETERs
	if sym->ns->construct_entities rather than if
	sym->ns->parent->code->op == EXEC_BLOCK.

	* gfortran.dg/pr89084.f90: New test.
	* gfortran.dg/lto/pr89084_0.f90: New test.
	* gfortran.dg/pr83246.f90: New test.

--- gcc/fortran/trans-decl.c	(revision 268641)
+++ gcc/fortran/trans-decl.c	(revision 268642)
@@ -5720,10 +5720,7 @@ generate_local_decl (gfc_symbol * sym)
 			  "imported at %L", sym->name, &sym->declared_at);
 	}
 
-      if (sym->ns
-	  && sym->ns->parent
-	  && sym->ns->parent->code
-	  && sym->ns->parent->code->op == EXEC_BLOCK)
+      if (sym->ns && sym->ns->construct_entities)
 	{
 	  if (sym->attr.referenced)
 	    gfc_get_symbol_decl (sym);
--- gcc/testsuite/gfortran.dg/pr83246.f90	(nonexistent)
+++ gcc/testsuite/gfortran.dg/pr83246.f90	(revision 268642)
@@ -0,0 +1,9 @@
+! PR fortran/83246
+! { dg-do link }
+   program dusty_corner 
+   write(*,*)'BLOCK TESTS' 
+   MAKEDATAP: block
+   integer,parameter :: scratch(*)=[1,2,3]
+   write(*,*)scratch
+   endblock MAKEDATAP
+   end program dusty_corner
--- gcc/testsuite/gfortran.dg/lto/pr89084_0.f90	(nonexistent)
+++ gcc/testsuite/gfortran.dg/lto/pr89084_0.f90	(revision 268642)
@@ -0,0 +1,24 @@
+! PR fortran/89084
+! { dg-lto-do link }
+! { dg-lto-options {{ -O0 -flto }} }
+
+integer function foo ()
+  write (*,*) 'foo'
+  block
+    integer, parameter :: idxs(3) = (/ 1, 2, 3 /)
+    integer :: i
+    foo = 0
+    do i = 1, size(idxs)
+      foo = foo + idxs(i)
+    enddo
+  end block
+end function foo
+program pr89084
+  integer :: i
+  interface
+    integer function foo ()
+    end function
+  end interface
+  i = foo ()
+  if (i.ne.6) stop 1
+end
--- gcc/testsuite/gfortran.dg/pr89084.f90	(nonexistent)
+++ gcc/testsuite/gfortran.dg/pr89084.f90	(revision 268642)
@@ -0,0 +1,23 @@
+! PR fortran/89084
+! { dg-do run }
+
+integer function foo ()
+  write (*,*) 'foo'
+  block
+    integer, parameter :: idxs(3) = (/ 1, 2, 3 /)
+    integer :: i
+    foo = 0
+    do i = 1, size(idxs)
+      foo = foo + idxs(i)
+    enddo
+  end block
+end function foo
+program pr89084
+  integer :: i
+  interface
+    integer function foo ()
+    end function
+  end interface
+  i = foo ()
+  if (i.ne.6) stop 1
+end
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2019-02-02  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/87887
	* config/i386/i386.c (ix86_simd_clone_compute_vecsize_and_simdlen):
	Punt with warning on aggregate return or argument types.  Ignore
	type/mode checking for uniform arguments.

	* gcc.dg/gomp/pr87887-1.c: New test.
	* gcc.dg/gomp/pr87887-2.c: New test.

--- gcc/config/i386/i386.c	(revision 268642)
+++ gcc/config/i386/i386.c	(revision 268643)
@@ -51743,7 +51743,9 @@ ix86_simd_clone_compute_vecsize_and_simd
       case DFmode:
       /* case SCmode: */
       /* case DCmode: */
-	break;
+	if (!AGGREGATE_TYPE_P (ret_type))
+	  break;
+	/* FALLTHRU */
       default:
 	warning_at (DECL_SOURCE_LOCATION (node->decl), 0,
 		    "unsupported return type %qT for simd\n", ret_type);
@@ -51754,7 +51756,6 @@ ix86_simd_clone_compute_vecsize_and_simd
   int i;
 
   for (t = DECL_ARGUMENTS (node->decl), i = 0; t; t = DECL_CHAIN (t), i++)
-    /* FIXME: Shouldn't we allow such arguments if they are uniform?  */
     switch (TYPE_MODE (TREE_TYPE (t)))
       {
       case QImode:
@@ -51765,8 +51766,12 @@ ix86_simd_clone_compute_vecsize_and_simd
       case DFmode:
       /* case SCmode: */
       /* case DCmode: */
-	break;
+	if (!AGGREGATE_TYPE_P (TREE_TYPE (t)))
+	  break;
+	/* FALLTHRU */
       default:
+	if (clonei->args[i].arg_type == SIMD_CLONE_ARG_TYPE_UNIFORM)
+	  break;
 	warning_at (DECL_SOURCE_LOCATION (node->decl), 0,
 		    "unsupported argument type %qT for simd\n", TREE_TYPE (t));
 	return 0;
--- gcc/testsuite/gcc.dg/gomp/pr87887-1.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/gomp/pr87887-1.c	(revision 268643)
@@ -0,0 +1,26 @@
+/* PR middle-end/87887 */
+/* { dg-do compile } */
+/* { dg-require-effective-target vect_simd_clones } */
+/* { dg-additional-options "-w" } */
+
+struct S { int n; };
+#pragma omp declare simd
+struct S
+foo (int x)
+{
+  return (struct S) { x };
+}
+
+#pragma omp declare simd
+int
+bar (struct S x)
+{
+  return x.n;
+}
+
+#pragma omp declare simd uniform (x)
+int
+baz (int w, struct S x, int y)
+{
+  return w + x.n + y;
+}
--- gcc/testsuite/gcc.dg/gomp/pr87887-2.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/gomp/pr87887-2.c	(revision 268643)
@@ -0,0 +1,25 @@
+/* PR middle-end/87887 */
+/* { dg-do compile { target i?86-*-* x86_64-*-* } } */
+/* { dg-require-effective-target vect_simd_clones } */
+
+struct S { int n; };
+#pragma omp declare simd
+struct S
+foo (int x)		/* { dg-warning "unsupported return type 'struct S' for simd" } */
+{
+  return (struct S) { x };
+}
+
+#pragma omp declare simd
+int
+bar (struct S x)	/* { dg-warning "unsupported argument type 'struct S' for simd" } */
+{
+  return x.n;
+}
+
+#pragma omp declare simd uniform (x)
+int
+baz (int w, struct S x, int y)
+{
+  return w + x.n + y;
+}
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2019-02-05  Jakub Jelinek  <jakub@redhat.com>

	PR target/89186
	* optabs.c (prepare_cmp_insn): Pass x and y to
	emit_block_comp_via_libcall rather than XEXP (x, 0) and XEXP (y, 0).

	* g++.dg/ext/vector36.C: New test.

--- gcc/optabs.c	(revision 268644)
+++ gcc/optabs.c	(revision 268645)
@@ -3876,7 +3876,7 @@ prepare_cmp_insn (rtx x, rtx y, enum rtx
 	goto fail;
 
       /* Otherwise call a library function.  */
-      result = emit_block_comp_via_libcall (XEXP (x, 0), XEXP (y, 0), size);
+      result = emit_block_comp_via_libcall (x, y, size);
 
       x = result;
       y = const0_rtx;
--- gcc/testsuite/g++.dg/ext/vector36.C	(nonexistent)
+++ gcc/testsuite/g++.dg/ext/vector36.C	(revision 268645)
@@ -0,0 +1,6 @@
+// PR target/89186
+// { dg-do compile }
+// { dg-options "-fnon-call-exceptions" }
+// { dg-additional-options "-mno-sse" { target i?86-*-* x86_64-*-* } }
+
+#include "vector27.C"
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2019-02-05  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/89195
	* combine.c (make_extraction): For MEMs, don't extract bytes outside
	of the original MEM.

	* gcc.c-torture/execute/pr89195.c: New test.

--- gcc/combine.c	(revision 268645)
+++ gcc/combine.c	(revision 268646)
@@ -7481,6 +7481,7 @@ make_extraction (machine_mode mode, rtx
 	      /* We can't do this if we are widening INNER_MODE (it
 		 may not be aligned, for one thing).  */
 	      && GET_MODE_PRECISION (inner_mode) >= GET_MODE_PRECISION (tmode)
+	      && pos + len <= GET_MODE_PRECISION (is_mode)
 	      && (inner_mode == tmode
 		  || (! mode_dependent_address_p (XEXP (inner, 0),
 						  MEM_ADDR_SPACE (inner))
--- gcc/testsuite/gcc.c-torture/execute/pr89195.c	(nonexistent)
+++ gcc/testsuite/gcc.c-torture/execute/pr89195.c	(revision 268646)
@@ -0,0 +1,22 @@
+/* PR rtl-optimization/89195 */
+/* { dg-require-effective-target int32plus } */
+
+struct S { unsigned i : 24; };
+
+volatile unsigned char x;
+
+__attribute__((noipa)) int
+foo (struct S d) 
+{
+  return d.i & x;
+}
+
+int
+main ()
+{
+  struct S d = { 0x123456 };
+  x = 0x75;
+  if (foo (d) != (0x56 & 0x75))
+    __builtin_abort ();
+  return 0;
+}
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2019-02-05  Jakub Jelinek  <jakub@redhat.com>

	PR target/89188
	* dce.c (delete_unmarked_insns): Don't remove no-op moves if they
	can throw, non-call exceptions are enabled and we can't delete
	dead exceptions or alter cfg.  Set must_clean if
	delete_insn_and_edges returns true, don't set it blindly for calls.

	* g++.dg/opt/pr89188.C: New test.

--- gcc/dce.c	(revision 268646)
+++ gcc/dce.c	(revision 268647)
@@ -577,7 +577,12 @@ delete_unmarked_insns (void)
 	  rtx turn_into_use = NULL_RTX;
 
 	  /* Always delete no-op moves.  */
-	  if (noop_move_p (insn))
+	  if (noop_move_p (insn)
+	      /* Unless the no-op move can throw and we are not allowed
+		 to alter cfg.  */
+	      && (!cfun->can_throw_non_call_exceptions
+		  || (cfun->can_delete_dead_exceptions && can_alter_cfg)
+		  || insn_nothrow_p (insn)))
 	    {
 	      if (RTX_FRAME_RELATED_P (insn))
 		turn_into_use
@@ -620,12 +625,6 @@ delete_unmarked_insns (void)
 	     for the destination regs in order to avoid dangling notes.  */
 	  remove_reg_equal_equiv_notes_for_defs (insn);
 
-	  /* If a pure or const call is deleted, this may make the cfg
-	     have unreachable blocks.  We rememeber this and call
-	     delete_unreachable_blocks at the end.  */
-	  if (CALL_P (insn))
-	    must_clean = true;
-
 	  if (turn_into_use)
 	    {
 	      /* Don't remove frame related noop moves if they cary
@@ -638,7 +637,7 @@ delete_unmarked_insns (void)
 	    }
 	  else
 	    /* Now delete the insn.  */
-	    delete_insn_and_edges (insn);
+	    must_clean |= delete_insn_and_edges (insn);
 	}
 
   /* Deleted a pure or const call.  */
--- gcc/testsuite/g++.dg/opt/pr89188.C	(nonexistent)
+++ gcc/testsuite/g++.dg/opt/pr89188.C	(revision 268647)
@@ -0,0 +1,13 @@
+// PR target/89188
+// { dg-do compile { target c++11 } }
+// { dg-options "-Og -flive-range-shrinkage -fnon-call-exceptions" }
+
+struct Ax {
+  int n, a[];
+};
+
+int i = 12345678;
+int main() {
+  static Ax s{456, i};
+  ((s.a[0]) ? (void)0 : (void)0);
+}
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2019-02-05  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/11304
	* gcc.target/i386/call-1.c (set_eax): Add "eax" clobber.
	* gcc.target/i386/call-2.c: New test.

--- gcc/testsuite/gcc.target/i386/call-1.c	(revision 268647)
+++ gcc/testsuite/gcc.target/i386/call-1.c	(revision 268648)
@@ -11,7 +11,7 @@ volatile int r;
 
 void set_eax(int val)
 {
-  __asm__ __volatile__ ("mov %0, %%eax" : : "m" (val));
+  __asm__ __volatile__ ("mov %0, %%eax" : : "m" (val) : "eax");
 }
 
 void foo(int val)
--- gcc/testsuite/gcc.target/i386/call-2.c	(nonexistent)
+++ gcc/testsuite/gcc.target/i386/call-2.c	(revision 268648)
@@ -0,0 +1,12 @@
+/* PR optimization/11304 */
+/* Originator: <manuel.serrano@sophia.inria.fr> */
+/* { dg-do run } */
+/* { dg-options "-O -fomit-frame-pointer" } */
+
+/* Verify that %eax is always restored after a call.  */
+
+__attribute__((noinline, noclone)) void set_eax(int val);
+__attribute__((noinline, noclone)) void foo(int val);
+__attribute__((noinline, noclone)) int bar(int x);
+
+#include "call-1.c"
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2019-02-05  Jakub Jelinek  <jakub@redhat.com>

	PR c++/89187
	* optimize.c (maybe_thunk_body): Clear TREE_ADDRESSABLE on
	PARM_DECLs of the thunk.
	* lambda.c (maybe_add_lambda_conv_op): Likewise.

	* g++.dg/opt/pr89187.C: New test.

--- gcc/cp/optimize.c	(revision 268648)
+++ gcc/cp/optimize.c	(revision 268649)
@@ -407,6 +407,8 @@ maybe_thunk_body (tree fn, bool force)
 		  gcc_assert (clone_parm);
 		  DECL_ABSTRACT_ORIGIN (clone_parm) = NULL;
 		  args[parmno] = clone_parm;
+		  /* Clear TREE_ADDRESSABLE on thunk arguments.  */
+		  TREE_ADDRESSABLE (clone_parm) = 0;
 		  clone_parm = TREE_CHAIN (clone_parm);
 		}
 	      if (fn_parm_typelist)
--- gcc/cp/lambda.c	(revision 268648)
+++ gcc/cp/lambda.c	(revision 268649)
@@ -1118,6 +1118,9 @@ maybe_add_lambda_conv_op (tree type)
       {
 	tree new_node = copy_node (src);
 
+	/* Clear TREE_ADDRESSABLE on thunk arguments.  */
+	TREE_ADDRESSABLE (new_node) = 0;
+
 	if (!fn_args)
 	  fn_args = tgt = new_node;
 	else
--- gcc/testsuite/g++.dg/opt/pr89187.C	(nonexistent)
+++ gcc/testsuite/g++.dg/opt/pr89187.C	(revision 268649)
@@ -0,0 +1,23 @@
+// PR c++/89187
+// { dg-do compile { target c++11 } }
+// { dg-options "-Os -fno-tree-ccp -fno-tree-sra -fno-inline" }
+
+template <typename T, int N> struct A {
+  typedef T __attribute__((vector_size (N))) type;
+};
+template <typename T, int N> using B = typename A<T, N>::type;
+template <typename T> using C = B<T, 4>;
+struct D {
+  D (C<int> x) : d{x[3]} {}
+  D foo () { return d; }
+  C<int> d;
+};
+extern D d;
+struct { D bar () { return d; } } l;
+struct E { void baz () const; };
+
+void
+E::baz () const
+{
+  l.bar ().foo ();
+}
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2019-02-08  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/89234
	* except.c (copy_reg_eh_region_note_forward): Return if note_or_insn
	is a NOTE, CODE_LABEL etc. - rtx_insn * other than INSN_P.
	(copy_reg_eh_region_note_backward): Likewise.

	* g++.dg/ubsan/pr89234.C: New test.

--- gcc/except.c	(revision 268715)
+++ gcc/except.c	(revision 268716)
@@ -1755,6 +1755,8 @@ copy_reg_eh_region_note_forward (rtx not
       if (note == NULL)
 	return;
     }
+  else if (is_a <rtx_insn *> (note_or_insn))
+    return;
   note = XEXP (note, 0);
 
   for (insn = first; insn != last ; insn = NEXT_INSN (insn))
@@ -1777,6 +1779,8 @@ copy_reg_eh_region_note_backward (rtx no
       if (note == NULL)
 	return;
     }
+  else if (is_a <rtx_insn *> (note_or_insn))
+    return;
   note = XEXP (note, 0);
 
   for (insn = last; insn != first; insn = PREV_INSN (insn))
--- gcc/testsuite/g++.dg/ubsan/pr89234.C	(nonexistent)
+++ gcc/testsuite/g++.dg/ubsan/pr89234.C	(revision 268716)
@@ -0,0 +1,11 @@
+// PR rtl-optimization/89234
+// { dg-do compile { target dfp } }
+// { dg-options "-O2 -fnon-call-exceptions -fsanitize=null" }
+
+typedef float __attribute__((mode (SD))) _Decimal32;
+
+void
+foo (_Decimal32 *b, _Decimal32 c)
+{
+  *b = c + 1.5;
+}
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2019-01-16  David Malcolm  <dmalcolm@redhat.com>

	PR target/88861
	* combine.c (delete_noop_moves): Convert to "bool" return,
	returning true if any edges are eliminated.
	(combine_instructions): Also return true if delete_noop_moves
	returns true.

	* g++.dg/opt/pr89188.C: Include ../torture/pr88861.C.

	2019-01-16  David Malcolm  <dmalcolm@redhat.com>

	PR target/88861
	* g++.dg/torture/pr88861.C: New test.

--- gcc/combine.c	(revision 268716)
+++ gcc/combine.c	(revision 268717)
@@ -981,14 +981,17 @@ combine_validate_cost (rtx_insn *i0, rtx
 }
 
 
-/* Delete any insns that copy a register to itself.  */
+/* Delete any insns that copy a register to itself.
+   Return true if the CFG was changed.  */
 
-static void
+static bool
 delete_noop_moves (void)
 {
   rtx_insn *insn, *next;
   basic_block bb;
 
+  bool edges_deleted = false;
+
   FOR_EACH_BB_FN (bb, cfun)
     {
       for (insn = BB_HEAD (bb); insn != NEXT_INSN (BB_END (bb)); insn = next)
@@ -999,10 +1002,12 @@ delete_noop_moves (void)
 	      if (dump_file)
 		fprintf (dump_file, "deleting noop move %d\n", INSN_UID (insn));
 
-	      delete_insn_and_edges (insn);
+	      edges_deleted |= delete_insn_and_edges (insn);
 	    }
 	}
     }
+
+  return edges_deleted;
 }
 
 
@@ -1141,8 +1146,8 @@ insn_a_feeds_b (rtx_insn *a, rtx_insn *b
 /* Main entry point for combiner.  F is the first insn of the function.
    NREGS is the first unused pseudo-reg number.
 
-   Return nonzero if the combiner has turned an indirect jump
-   instruction into a direct jump.  */
+   Return nonzero if the CFG was changed (e.g. if the combiner has
+   turned an indirect jump instruction into a direct jump).  */
 static int
 combine_instructions (rtx_insn *f, unsigned int nregs)
 {
@@ -1527,7 +1532,7 @@ retry:
   default_rtl_profile ();
   clear_bb_flags ();
   new_direct_jump_p |= purge_all_dead_edges ();
-  delete_noop_moves ();
+  new_direct_jump_p |= delete_noop_moves ();
 
   /* Clean up.  */
   obstack_free (&insn_link_obstack, NULL);
--- gcc/testsuite/g++.dg/opt/pr89188.C	(revision 268716)
+++ gcc/testsuite/g++.dg/opt/pr89188.C	(revision 268717)
@@ -2,12 +2,4 @@
 // { dg-do compile { target c++11 } }
 // { dg-options "-Og -flive-range-shrinkage -fnon-call-exceptions" }
 
-struct Ax {
-  int n, a[];
-};
-
-int i = 12345678;
-int main() {
-  static Ax s{456, i};
-  ((s.a[0]) ? (void)0 : (void)0);
-}
+#include "../torture/pr88861.C"
--- gcc/testsuite/g++.dg/torture/pr88861.C	(nonexistent)
+++ gcc/testsuite/g++.dg/torture/pr88861.C	(revision 268717)
@@ -0,0 +1,11 @@
+// { dg-options "-fnon-call-exceptions" }
+
+struct Ax {
+  int n, a[];
+};
+
+int i = 12345678;
+int main() {
+  static Ax s{456, i};
+  ((s.a[0]) ? (void)0 : (void)0);
+}
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2019-02-09  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/89246
	* config/i386/i386.c (ix86_simd_clone_compute_vecsize_and_simdlen):
	If !node->definition and TYPE_ARG_TYPES is non-NULL, use
	TYPE_ARG_TYPES instead of DECL_ARGUMENTS.

	* gcc.dg/gomp/pr89246-1.c: New test.
	* gcc.dg/gomp/pr89246-2.c: New test.

--- gcc/config/i386/i386.c	(revision 268862)
+++ gcc/config/i386/i386.c	(revision 268863)
@@ -51754,28 +51754,34 @@ ix86_simd_clone_compute_vecsize_and_simd
 
   tree t;
   int i;
+  tree type_arg_types = TYPE_ARG_TYPES (TREE_TYPE (node->decl));
+  bool decl_arg_p = (node->definition || type_arg_types == NULL_TREE);
 
-  for (t = DECL_ARGUMENTS (node->decl), i = 0; t; t = DECL_CHAIN (t), i++)
-    switch (TYPE_MODE (TREE_TYPE (t)))
-      {
-      case QImode:
-      case HImode:
-      case SImode:
-      case DImode:
-      case SFmode:
-      case DFmode:
-      /* case SCmode: */
-      /* case DCmode: */
-	if (!AGGREGATE_TYPE_P (TREE_TYPE (t)))
-	  break;
-	/* FALLTHRU */
-      default:
-	if (clonei->args[i].arg_type == SIMD_CLONE_ARG_TYPE_UNIFORM)
-	  break;
-	warning_at (DECL_SOURCE_LOCATION (node->decl), 0,
-		    "unsupported argument type %qT for simd\n", TREE_TYPE (t));
-	return 0;
-      }
+  for (t = (decl_arg_p ? DECL_ARGUMENTS (node->decl) : type_arg_types), i = 0;
+       t && t != void_list_node; t = TREE_CHAIN (t), i++)
+    {
+      tree arg_type = decl_arg_p ? TREE_TYPE (t) : TREE_VALUE (t);
+      switch (TYPE_MODE (arg_type))
+	{
+	case QImode:
+	case HImode:
+	case SImode:
+	case DImode:
+	case SFmode:
+	case DFmode:
+	/* case SCmode: */
+	/* case DCmode: */
+	  if (!AGGREGATE_TYPE_P (arg_type))
+	    break;
+	  /* FALLTHRU */
+	default:
+	  if (clonei->args[i].arg_type == SIMD_CLONE_ARG_TYPE_UNIFORM)
+	    break;
+	  warning_at (DECL_SOURCE_LOCATION (node->decl), 0,
+		      "unsupported argument type %qT for simd\n", arg_type);
+	  return 0;
+	}
+    }
 
   if (clonei->cilk_elemental)
     {
--- gcc/testsuite/gcc.dg/gomp/pr89246-1.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/gomp/pr89246-1.c	(revision 268863)
@@ -0,0 +1,19 @@
+/* PR middle-end/89246 */
+/* { dg-do link { target { int128 && vect_simd_clones } } } */
+/* { dg-options "-O2 -fopenmp-simd -w" } */
+/* { dg-additional-sources "pr89246-2.c" } */
+
+#pragma omp declare simd
+int foo (__int128 x)
+{
+  return x;
+}
+
+#pragma omp declare simd
+extern int bar (int x);
+
+int
+main ()
+{
+  return foo (0) + bar (0);
+}
--- gcc/testsuite/gcc.dg/gomp/pr89246-2.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/gomp/pr89246-2.c	(revision 268863)
@@ -0,0 +1,13 @@
+/* PR middle-end/89246 */
+/* { dg-do compile { target int128 } } */
+/* { dg-options "-O0 -fno-openmp -fno-openmp-simd" } */
+
+#pragma omp declare simd
+extern int foo (__int128 x);
+
+#pragma omp declare simd
+int
+bar (int x)
+{
+  return x + foo (0);
+}
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2019-02-13  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/89281
	* optabs.c (prepare_cmp_insn): Use UINTVAL (size) instead of
	INTVAL (size), compare it to GET_MODE_MASK instead of
	1 << GET_MODE_BITSIZE.

--- gcc/optabs.c	(revision 268864)
+++ gcc/optabs.c	(revision 268865)
@@ -3811,7 +3811,7 @@ prepare_cmp_insn (rtx x, rtx y, enum rtx
 
 	  /* Must make sure the size fits the insn's mode.  */
 	  if ((CONST_INT_P (size)
-	       && INTVAL (size) >= (1 << GET_MODE_BITSIZE (cmp_mode)))
+	       && UINTVAL (size) > GET_MODE_MASK (cmp_mode))
 	      || (GET_MODE_BITSIZE (GET_MODE (size))
 		  > GET_MODE_BITSIZE (cmp_mode)))
 	    continue;
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2019-02-13  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/89303
	* tree-ssa-structalias.c (set_uids_in_ptset): Or in vi->is_heap_var
	into pt->vars_contains_escaped_heap instead of setting
	pt->vars_contains_escaped_heap to it.

	2019-02-13  Jonathan Wakely  <jwakely@redhat.com>
		    Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/89303
	* g++.dg/torture/pr89303.C: New test.

--- gcc/tree-ssa-structalias.c	(revision 268865)
+++ gcc/tree-ssa-structalias.c	(revision 268866)
@@ -6385,7 +6385,7 @@ set_uids_in_ptset (bitmap into, bitmap f
 	      && bitmap_bit_p (escaped_vi->solution, i)))
 	{
 	  pt->vars_contains_escaped = true;
-	  pt->vars_contains_escaped_heap = vi->is_heap_var;
+	  pt->vars_contains_escaped_heap |= vi->is_heap_var;
 	}
 
       if (vi->is_restrict_var)
--- gcc/testsuite/g++.dg/torture/pr89303.C	(nonexistent)
+++ gcc/testsuite/g++.dg/torture/pr89303.C	(revision 268866)
@@ -0,0 +1,792 @@
+// PR middle-end/89303
+// { dg-do run }
+// { dg-additional-options "-std=c++14" }
+
+namespace std
+{
+  typedef __SIZE_TYPE__ size_t;
+  typedef decltype(nullptr) nullptr_t;
+
+  template<typename _Tp, _Tp __v>
+    struct integral_constant
+    {
+      static constexpr _Tp value = __v;
+      typedef _Tp value_type;
+      typedef integral_constant<_Tp, __v> type;
+      constexpr operator value_type() const noexcept { return value; }
+      constexpr value_type operator()() const noexcept { return value; }
+    };
+
+  template<typename _Tp, _Tp __v>
+    constexpr _Tp integral_constant<_Tp, __v>::value;
+
+  typedef integral_constant<bool, true> true_type;
+  typedef integral_constant<bool, false> false_type;
+
+  template<bool __v>
+    using __bool_constant = integral_constant<bool, __v>;
+
+  template<bool, typename, typename>
+    struct conditional;
+
+  template<typename...>
+    struct __and_;
+
+  template<>
+    struct __and_<>
+    : public true_type
+    { };
+
+  template<typename _B1>
+    struct __and_<_B1>
+    : public _B1
+    { };
+
+  template<typename _B1, typename _B2>
+    struct __and_<_B1, _B2>
+    : public conditional<_B1::value, _B2, _B1>::type
+    { };
+
+  template<typename _B1, typename _B2, typename _B3, typename... _Bn>
+    struct __and_<_B1, _B2, _B3, _Bn...>
+    : public conditional<_B1::value, __and_<_B2, _B3, _Bn...>, _B1>::type
+    { };
+
+  template<typename>
+    struct remove_cv;
+
+  template<typename>
+    struct __is_void_helper
+    : public false_type { };
+
+  template<>
+    struct __is_void_helper<void>
+    : public true_type { };
+
+  template<typename _Tp>
+    struct is_void
+    : public __is_void_helper<typename remove_cv<_Tp>::type>::type
+    { };
+
+  template<typename _Tp, typename _Up = _Tp&&>
+    _Up
+    __declval(int);
+
+  template<typename _Tp>
+    _Tp
+    __declval(long);
+
+  template<typename _Tp>
+    auto declval() noexcept -> decltype(__declval<_Tp>(0));
+
+  template<typename, typename>
+    struct is_same
+    : public false_type { };
+
+  template<typename _Tp>
+    struct is_same<_Tp, _Tp>
+    : public true_type { };
+
+  template<typename _Tp>
+    struct remove_const
+    { typedef _Tp type; };
+
+  template<typename _Tp>
+    struct remove_const<_Tp const>
+    { typedef _Tp type; };
+
+  template<typename _Tp>
+    struct remove_volatile
+    { typedef _Tp type; };
+
+  template<typename _Tp>
+    struct remove_volatile<_Tp volatile>
+    { typedef _Tp type; };
+
+  template<typename _Tp>
+    struct remove_cv
+    {
+      typedef typename
+      remove_const<typename remove_volatile<_Tp>::type>::type type;
+    };
+
+  template<typename _Tp>
+    struct remove_reference
+    { typedef _Tp type; };
+
+  template<typename _Tp>
+    struct remove_reference<_Tp&>
+    { typedef _Tp type; };
+
+  template<typename _Tp>
+    struct remove_reference<_Tp&&>
+    { typedef _Tp type; };
+
+  template<bool, typename _Tp = void>
+    struct enable_if
+    { };
+
+  template<typename _Tp>
+    struct enable_if<true, _Tp>
+    { typedef _Tp type; };
+
+  template<typename... _Cond>
+    using _Require = typename enable_if<__and_<_Cond...>::value>::type;
+
+  template<bool _Cond, typename _Iftrue, typename _Iffalse>
+    struct conditional
+    { typedef _Iftrue type; };
+
+  template<typename _Iftrue, typename _Iffalse>
+    struct conditional<false, _Iftrue, _Iffalse>
+    { typedef _Iffalse type; };
+
+  template<typename _Tp>
+    struct __declval_protector
+    {
+      static const bool __stop = false;
+    };
+
+  template<typename _Tp>
+    auto declval() noexcept -> decltype(__declval<_Tp>(0))
+    {
+      static_assert(__declval_protector<_Tp>::__stop,
+      "declval() must not be used!");
+      return __declval<_Tp>(0);
+    }
+
+  namespace void_details {
+    template <class... >
+    struct make_void { using type = void; };
+}
+
+template <class... T> using __void_t = typename void_details ::make_void<T...>::type;
+
+  template<typename _Tp>
+    inline constexpr _Tp*
+    __addressof(_Tp& __r) noexcept
+    {
+      return reinterpret_cast<_Tp*>
+	(&const_cast<char&>(reinterpret_cast<const volatile char&>(__r)));
+    }
+
+  template<typename _Tp>
+    constexpr _Tp&&
+    forward(typename std::remove_reference<_Tp>::type& __t) noexcept
+    { return static_cast<_Tp&&>(__t); }
+
+  template<typename _Tp>
+    constexpr _Tp&&
+    forward(typename std::remove_reference<_Tp>::type&& __t) noexcept
+    {
+      return static_cast<_Tp&&>(__t);
+    }
+
+  template<typename _Tp>
+    constexpr typename std::remove_reference<_Tp>::type&&
+    move(_Tp&& __t) noexcept
+    { return static_cast<typename std::remove_reference<_Tp>::type&&>(__t); }
+}
+       
+inline void* operator new(std::size_t, void* p) { return p; }
+
+extern "C" void* malloc(std::size_t);
+extern "C" void free(void*);
+
+namespace std
+{
+  template<typename T>
+    class allocator
+    {
+    public:
+      using value_type = T;
+
+      allocator() { }
+
+      template<typename U>
+        allocator(const allocator<U>&) { }
+
+      T* allocate(size_t n) { return (T*)malloc(n*sizeof(T)); }
+      void deallocate(T* p, size_t) { free(p); }
+
+      template<typename U, typename... Args>
+        void construct(U* p, Args&&... args)
+        { ::new((void*)p) U(args...); }
+
+      template<typename U>
+        void destroy(U* p)
+        { p->~U(); }
+    };
+
+  class __undefined;
+
+  template<typename _Tp, typename _Up>
+    struct __replace_first_arg
+    { };
+
+  template<template<typename, typename...> class _Template, typename _Up,
+           typename _Tp, typename... _Types>
+    struct __replace_first_arg<_Template<_Tp, _Types...>, _Up>
+    { using type = _Template<_Up, _Types...>; };
+
+  struct __allocator_traits_base
+  {
+    template<typename _Tp, typename _Up, typename = void>
+      struct __rebind : __replace_first_arg<_Tp, _Up> { };
+
+    template<typename _Tp, typename _Up>
+      struct __rebind<_Tp, _Up,
+        __void_t<typename _Tp::template rebind<_Up>::other>>
+      { using type = typename _Tp::template rebind<_Up>::other; };
+  };
+
+  template<typename _Alloc, typename _Up>
+    using __alloc_rebind
+      = typename __allocator_traits_base::template __rebind<_Alloc, _Up>::type;
+
+  template<typename _Alloc>
+    struct allocator_traits;
+
+  template<typename _Tp>
+    struct allocator_traits<allocator<_Tp>>
+    {
+      using allocator_type = allocator<_Tp>;
+      using value_type = _Tp;
+      using pointer = _Tp*;
+      using const_pointer = const _Tp*;
+      using size_type = std::size_t;
+
+      static pointer
+      allocate(allocator_type& __a, size_type __n)
+      { return __a.allocate(__n); }
+
+      static void
+      deallocate(allocator_type& __a, pointer __p, size_type __n)
+      { __a.deallocate(__p, __n); }
+
+      template<typename _Up, typename... _Args>
+        static void
+        construct(allocator_type& __a, _Up* __p, _Args&&... __args)
+        { __a.construct(__p, std::forward<_Args>(__args)...); }
+
+      template<typename _Up>
+        static void
+        destroy(allocator_type& __a, _Up* __p)
+        { __a.destroy(__p); }
+    };
+
+  template<typename _Alloc>
+    struct __allocated_ptr
+    {
+      using pointer = typename allocator_traits<_Alloc>::pointer;
+      using value_type = typename allocator_traits<_Alloc>::value_type;
+
+      __allocated_ptr(_Alloc& __a, pointer __ptr) noexcept
+      : _M_alloc(std::__addressof(__a)), _M_ptr(__ptr)
+      { }
+
+      template<typename _Ptr,
+        typename _Req = _Require<is_same<_Ptr, value_type*>>>
+      __allocated_ptr(_Alloc& __a, _Ptr __ptr)
+      : _M_alloc(std::__addressof(__a)),
+      _M_ptr(__ptr)
+      { }
+
+      __allocated_ptr(__allocated_ptr&& __gd) noexcept
+      : _M_alloc(__gd._M_alloc), _M_ptr(__gd._M_ptr)
+      { __gd._M_ptr = nullptr; }
+
+      ~__allocated_ptr()
+      {
+        if (_M_ptr != nullptr)
+          std::allocator_traits<_Alloc>::deallocate(*_M_alloc, _M_ptr, 1);
+      }
+
+      __allocated_ptr&
+      operator=(std::nullptr_t) noexcept
+      {
+        _M_ptr = nullptr;
+        return *this;
+      }
+
+      value_type* get() { return _M_ptr; }
+
+    private:
+      _Alloc* _M_alloc;
+      pointer _M_ptr;
+    };
+
+  template<typename _Alloc>
+    __allocated_ptr<_Alloc>
+    __allocate_guarded(_Alloc& __a)
+    {
+      return { __a, std::allocator_traits<_Alloc>::allocate(__a, 1) };
+    }
+
+  template<typename _Tp>
+    struct __aligned_buffer
+    {
+      alignas(__alignof__(_Tp)) unsigned char _M_storage[sizeof(_Tp)];
+      __aligned_buffer() = default;
+
+      void*
+      _M_addr() noexcept
+      {
+        return static_cast<void*>(&_M_storage);
+      }
+
+      const void*
+      _M_addr() const noexcept
+      {
+        return static_cast<const void*>(&_M_storage);
+      }
+
+      _Tp*
+      _M_ptr() noexcept
+      { return static_cast<_Tp*>(_M_addr()); }
+
+      const _Tp*
+      _M_ptr() const noexcept
+      { return static_cast<const _Tp*>(_M_addr()); }
+    };
+
+  class bad_weak_ptr { };
+
+  inline void
+  __throw_bad_weak_ptr()
+  { (throw (bad_weak_ptr())); }
+
+    class _Sp_counted_base
+    {
+    public:
+      _Sp_counted_base() noexcept
+      : _M_use_count(1), _M_weak_count(1) { }
+
+      virtual
+      ~_Sp_counted_base() noexcept
+      { }
+
+      virtual void
+      _M_dispose() noexcept = 0;
+
+      virtual void
+      _M_destroy() noexcept
+      { delete this; }
+
+      void
+      _M_add_ref_copy()
+      { ++_M_use_count; }
+
+      void
+      _M_add_ref_lock()
+      {
+        if (_M_use_count == 0)
+          __throw_bad_weak_ptr();
+        ++_M_use_count;
+      }
+
+      void
+      _M_release() noexcept
+      {
+        if (--_M_use_count == 0)
+        {
+          _M_dispose();
+          if (--_M_weak_count == 0)
+            _M_destroy();
+        }
+      }
+
+      void
+      _M_weak_add_ref() noexcept
+      { ++_M_weak_count; }
+
+      void
+      _M_weak_release() noexcept
+      {
+        if (--_M_weak_count == 0)
+          _M_destroy();
+      }
+
+      long
+      _M_get_use_count() const noexcept
+      {
+        return _M_use_count;
+      }
+
+    private:
+      _Sp_counted_base(_Sp_counted_base const&) = delete;
+      _Sp_counted_base& operator=(_Sp_counted_base const&) = delete;
+
+      int _M_use_count;
+      int _M_weak_count;
+    };
+
+  template<typename _Tp>
+    class shared_ptr;
+
+  template<typename _Tp>
+    class weak_ptr;
+
+  template<typename _Tp>
+    class enable_shared_from_this;
+
+  class __weak_count;
+
+  class __shared_count;
+
+  template<typename _Alloc>
+    struct _Sp_alloc_shared_tag
+    {
+      const _Alloc& _M_a;
+    };
+
+  template<typename _Tp, typename _Alloc>
+    class _Sp_counted_ptr_inplace final : public _Sp_counted_base
+    {
+      class _Impl : _Alloc
+      {
+      public:
+        explicit _Impl(_Alloc __a) noexcept : _Alloc(__a) { }
+
+        _Alloc& _M_alloc() noexcept { return *this; }
+
+        __aligned_buffer<_Tp> _M_storage;
+      };
+
+    public:
+      using __allocator_type = __alloc_rebind<_Alloc, _Sp_counted_ptr_inplace>;
+
+      template<typename... _Args>
+        _Sp_counted_ptr_inplace(_Alloc __a, _Args&&... __args)
+        : _M_impl(__a)
+        {
+          allocator_traits<_Alloc>::construct(__a, _M_ptr(),
+              std::forward<_Args>(__args)...);
+        }
+
+      ~_Sp_counted_ptr_inplace() noexcept { }
+
+      virtual void
+      _M_dispose() noexcept
+      {
+        allocator_traits<_Alloc>::destroy(_M_impl._M_alloc(), _M_ptr());
+      }
+
+      virtual void
+      _M_destroy() noexcept
+      {
+        __allocator_type __a(_M_impl._M_alloc());
+        __allocated_ptr<__allocator_type> __guard_ptr{ __a, this };
+        this->~_Sp_counted_ptr_inplace();
+      }
+
+    private:
+      friend class __shared_count;
+
+      _Tp* _M_ptr() noexcept { return _M_impl._M_storage._M_ptr(); }
+
+      _Impl _M_impl;
+    };
+
+  class __shared_count
+  {
+  public:
+    constexpr __shared_count() noexcept : _M_pi(0)
+    { }
+
+    template<typename _Tp, typename _Alloc, typename... _Args>
+      __shared_count(_Tp*& __p, _Sp_alloc_shared_tag<_Alloc> __a,
+          _Args&&... __args)
+      {
+        typedef _Sp_counted_ptr_inplace<_Tp, _Alloc> _Sp_cp_type;
+        typename _Sp_cp_type::__allocator_type __a2(__a._M_a);
+        auto __guard = std::__allocate_guarded(__a2);
+        _Sp_cp_type* __mem = __guard.get();
+        auto __pi = ::new (__mem)
+          _Sp_cp_type(__a._M_a, std::forward<_Args>(__args)...);
+        __guard = nullptr;
+        _M_pi = __pi;
+        __p = __pi->_M_ptr();
+      }
+
+    ~__shared_count() noexcept
+    {
+      if (_M_pi != nullptr)
+        _M_pi->_M_release();
+    }
+
+    __shared_count(const __shared_count& __r) noexcept
+    : _M_pi(__r._M_pi)
+    {
+      if (_M_pi != 0)
+        _M_pi->_M_add_ref_copy();
+    }
+
+    explicit __shared_count(const __weak_count& __r);
+
+    long
+    _M_get_use_count() const noexcept
+    { return _M_pi != 0 ? _M_pi->_M_get_use_count() : 0; }
+
+  private:
+    friend class __weak_count;
+
+    _Sp_counted_base* _M_pi;
+  };
+
+  class __weak_count
+  {
+  public:
+    constexpr __weak_count() noexcept : _M_pi(nullptr)
+    { }
+
+    __weak_count(const __shared_count& __r) noexcept
+    : _M_pi(__r._M_pi)
+    {
+      if (_M_pi != nullptr)
+        _M_pi->_M_weak_add_ref();
+    }
+
+    __weak_count(const __weak_count& __r) noexcept
+    : _M_pi(__r._M_pi)
+    {
+      if (_M_pi != nullptr)
+        _M_pi->_M_weak_add_ref();
+    }
+
+    __weak_count(__weak_count&& __r) noexcept
+    : _M_pi(__r._M_pi)
+    { __r._M_pi = nullptr; }
+
+    ~__weak_count() noexcept
+    {
+      if (_M_pi != nullptr)
+      {
+        _M_pi->_M_weak_release();
+      }
+    }
+
+    __weak_count&
+    operator=(const __shared_count& __r) noexcept
+    {
+      _Sp_counted_base* __tmp = __r._M_pi;
+      if (__tmp != nullptr)
+        __tmp->_M_weak_add_ref();
+      if (_M_pi != nullptr)
+        _M_pi->_M_weak_release();
+      _M_pi = __tmp;
+      return *this;
+    }
+
+    long
+    _M_get_use_count() const noexcept
+    { return _M_pi != nullptr ? _M_pi->_M_get_use_count() : 0; }
+
+  private:
+    friend class __shared_count;
+
+    _Sp_counted_base* _M_pi;
+  };
+
+  inline
+  __shared_count::__shared_count(const __weak_count& __r)
+  : _M_pi(__r._M_pi)
+  {
+    if (_M_pi != nullptr)
+      _M_pi->_M_add_ref_lock();
+    else
+      __throw_bad_weak_ptr();
+  }
+
+  template<typename _Tp>
+    class shared_ptr
+    {
+    public:
+      using element_type = _Tp;
+
+      constexpr shared_ptr() noexcept
+        : _M_ptr(0), _M_refcount()
+        { }
+
+      shared_ptr(const shared_ptr&) noexcept = default;
+      shared_ptr& operator=(const shared_ptr&) noexcept = default;
+      ~shared_ptr() = default;
+
+      template<typename _Yp>
+	explicit shared_ptr(const weak_ptr<_Yp>& __r)
+	: _M_refcount(__r._M_refcount) // may throw
+	{
+	  // It is now safe to copy __r._M_ptr, as
+	  // _M_refcount(__r._M_refcount) did not throw.
+	  _M_ptr = __r._M_ptr;
+	}
+
+      long
+      use_count() const noexcept
+      { return _M_refcount._M_get_use_count(); }
+
+      element_type* operator->() const noexcept { return _M_ptr; }
+
+    protected:
+
+      template<typename _Alloc, typename... _Args>
+        shared_ptr(_Sp_alloc_shared_tag<_Alloc> __tag, _Args&&... __args)
+        : _M_ptr(), _M_refcount(_M_ptr, __tag, std::forward<_Args>(__args)...)
+        { _M_enable_shared_from_this_with(_M_ptr); }
+
+      template<typename _Tp1, typename _Alloc,
+        typename... _Args>
+          friend shared_ptr<_Tp1>
+          allocate_shared(const _Alloc& __a, _Args&&... __args);
+
+      friend class weak_ptr<_Tp>;
+
+    private:
+
+      template<typename _Yp>
+        using __esft_base_t = decltype(__enable_shared_from_this_base(
+              std::declval<const __shared_count&>(),
+              std::declval<_Yp*>()));
+
+      template<typename _Yp, typename = void>
+        struct __has_esft_base
+        : false_type { };
+
+      template<typename _Yp>
+        struct __has_esft_base<_Yp, __void_t<__esft_base_t<_Yp>>>
+        : true_type { };
+
+      template<typename _Yp, typename _Yp2 = typename remove_cv<_Yp>::type>
+        typename enable_if<__has_esft_base<_Yp2>::value>::type
+        _M_enable_shared_from_this_with(_Yp* __p) noexcept
+        {
+          if (auto __base = __enable_shared_from_this_base(_M_refcount, __p))
+            __base->_M_weak_assign(const_cast<_Yp2*>(__p), _M_refcount);
+        }
+
+      template<typename _Tp1> friend class shared_ptr;
+      template<typename _Tp1> friend class weak_ptr;
+
+      element_type* _M_ptr;
+      __shared_count _M_refcount;
+    };
+
+  template<typename _Tp>
+    class weak_ptr
+    {
+    public:
+      using element_type = _Tp;
+
+      constexpr weak_ptr() noexcept
+      : _M_ptr(nullptr), _M_refcount()
+      { }
+
+      weak_ptr(const weak_ptr&) noexcept = default;
+
+      ~weak_ptr() = default;
+
+      weak_ptr&
+      operator=(const weak_ptr& __r) noexcept = default;
+
+      long
+      use_count() const noexcept
+      { return _M_refcount._M_get_use_count(); }
+
+    private:
+
+      void
+      _M_assign(_Tp* __ptr, const __shared_count& __refcount) noexcept
+      {
+        if (use_count() == 0)
+        {
+          _M_ptr = __ptr;
+          _M_refcount = __refcount;
+        }
+      }
+
+      template<typename _Tp1> friend class shared_ptr;
+      template<typename _Tp1> friend class weak_ptr;
+      friend class enable_shared_from_this<_Tp>;
+
+      element_type* _M_ptr;
+      __weak_count _M_refcount;
+    };
+
+  template<typename _Tp>
+    class enable_shared_from_this
+    {
+    protected:
+      constexpr enable_shared_from_this() noexcept { }
+
+      enable_shared_from_this(const enable_shared_from_this&) noexcept { }
+
+      enable_shared_from_this&
+      operator=(const enable_shared_from_this&) noexcept
+      { return *this; }
+
+      ~enable_shared_from_this() { }
+
+    public:
+      shared_ptr<_Tp>
+      shared_from_this()
+      { return shared_ptr<_Tp>(this->_M_weak_this); }
+
+      shared_ptr<const _Tp>
+      shared_from_this() const
+      { return shared_ptr<const _Tp>(this->_M_weak_this); }
+
+    private:
+      template<typename _Tp1>
+        void
+        _M_weak_assign(_Tp1* __p, const __shared_count& __n) const noexcept
+        { _M_weak_this._M_assign(__p, __n); }
+
+      friend const enable_shared_from_this*
+      __enable_shared_from_this_base(const __shared_count&,
+         const enable_shared_from_this* __p)
+      { return __p; }
+
+      template<typename>
+        friend class shared_ptr;
+
+      mutable weak_ptr<_Tp> _M_weak_this;
+    };
+
+  template<typename _Tp, typename _Alloc, typename... _Args>
+    inline shared_ptr<_Tp>
+    allocate_shared(const _Alloc& __a, _Args&&... __args)
+    {
+      return shared_ptr<_Tp>(_Sp_alloc_shared_tag<_Alloc>{__a},
+        std::forward<_Args>(__args)...);
+    }
+
+  template<typename _Tp, typename... _Args>
+    inline shared_ptr<_Tp>
+    make_shared(_Args&&... __args)
+    {
+      typedef typename std::remove_const<_Tp>::type _Tp_nc;
+      return std::allocate_shared<_Tp>(std::allocator<_Tp_nc>(),
+           std::forward<_Args>(__args)...);
+    }
+}
+
+class blob final: public std::enable_shared_from_this<blob>
+{
+  int* data;
+
+public:
+  blob() { data = new int; }
+  ~blob() { delete data; }
+};
+
+static int
+bar(std::shared_ptr<blob>)
+{
+  return 0;
+}
+
+int main()
+{
+  std::shared_ptr<blob> tg = std::make_shared<blob>();
+  return tg->shared_from_this().use_count() - 2;
+}
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2019-02-14  Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/89314
	* fold-const.c (fold_binary_loc): Cast strlen argument to
	const char * before dereferencing it.  Formatting fixes.

	* gcc.dg/pr89314.c: New test.

--- gcc/fold-const.c	(revision 268869)
+++ gcc/fold-const.c	(revision 268870)
@@ -10799,8 +10799,7 @@ fold_binary_loc (location_t loc, enum tr
 		strlen(ptr) != 0   =>  *ptr != 0
 	 Other cases should reduce to one of these two (or a constant)
 	 due to the return value of strlen being unsigned.  */
-      if (TREE_CODE (arg0) == CALL_EXPR
-	  && integer_zerop (arg1))
+      if (TREE_CODE (arg0) == CALL_EXPR && integer_zerop (arg1))
 	{
 	  tree fndecl = get_callee_fndecl (arg0);
 
@@ -10808,12 +10807,17 @@ fold_binary_loc (location_t loc, enum tr
 	      && DECL_BUILT_IN_CLASS (fndecl) == BUILT_IN_NORMAL
 	      && DECL_FUNCTION_CODE (fndecl) == BUILT_IN_STRLEN
 	      && call_expr_nargs (arg0) == 1
-	      && TREE_CODE (TREE_TYPE (CALL_EXPR_ARG (arg0, 0))) == POINTER_TYPE)
+	      && (TREE_CODE (TREE_TYPE (CALL_EXPR_ARG (arg0, 0)))
+		  == POINTER_TYPE))
 	    {
-	      tree iref = build_fold_indirect_ref_loc (loc,
-						   CALL_EXPR_ARG (arg0, 0));
+	      tree ptrtype
+		= build_pointer_type (build_qualified_type (char_type_node,
+							    TYPE_QUAL_CONST));
+	      tree ptr = fold_convert_loc (loc, ptrtype,
+					   CALL_EXPR_ARG (arg0, 0));
+	      tree iref = build_fold_indirect_ref_loc (loc, ptr);
 	      return fold_build2_loc (loc, code, type, iref,
-				  build_int_cst (TREE_TYPE (iref), 0));
+				      build_int_cst (TREE_TYPE (iref), 0));
 	    }
 	}
 
--- gcc/testsuite/gcc.dg/pr89314.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/pr89314.c	(revision 268870)
@@ -0,0 +1,13 @@
+/* PR tree-optimization/89314 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+extern __SIZE_TYPE__ strlen (const float *);
+void bar (void);
+
+void
+foo (float *s)
+{
+  if (strlen (s) > 0)
+    bar ();
+}
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2019-02-14  Jakub Jelinek  <jakub@redhat.com>

	PR rtl-optimization/89354
	* combine.c (make_extraction): Punt if extraction_mode is narrower
	than len bits.

	* gcc.dg/pr89354.c: New test.

--- gcc/combine.c	(revision 268913)
+++ gcc/combine.c	(revision 268914)
@@ -7750,6 +7750,10 @@ make_extraction (machine_mode mode, rtx
       && partial_subreg_p (extraction_mode, mode))
     extraction_mode = mode;
 
+  /* Punt if len is too large for extraction_mode.  */
+  if (len > GET_MODE_PRECISION (extraction_mode))
+    return NULL_RTX;
+
   if (!MEM_P (inner))
     wanted_inner_mode = wanted_inner_reg_mode;
   else
--- gcc/testsuite/gcc.dg/pr89354.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/pr89354.c	(revision 268914)
@@ -0,0 +1,22 @@
+/* PR rtl-optimization/89354 */
+/* { dg-do run } */
+/* { dg-options "-O2" } */
+/* { dg-additional-options "-msse2" { target sse2_runtime } } */
+
+static unsigned long long q = 0;
+
+__attribute__((noinline, noclone)) static void
+foo (void)
+{
+  q = (q & ~0x1ffffffffULL) | 0x100000000ULL;
+}
+
+int
+main ()
+{
+  __asm volatile ("" : "+m" (q));
+  foo ();
+  if (q != 0x100000000ULL)
+    __builtin_abort ();
+  return 0;
+}
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2019-02-15  Jakub Jelinek  <jakub@redhat.com>

	PR other/89342
	* optc-save-gen.awk: Handle optimize_fast like optimize_size or
	optimize_debug.
	* opth-gen.awk: Likewise.

	* gcc.dg/pr89342.c: New test.

--- gcc/optc-save-gen.awk	(revision 268924)
+++ gcc/optc-save-gen.awk	(revision 268925)
@@ -81,7 +81,7 @@ print "void";
 print "cl_optimization_save (struct cl_optimization *ptr, struct gcc_options *opts)";
 print "{";
 
-n_opt_char = 3;
+n_opt_char = 4;
 n_opt_short = 0;
 n_opt_int = 0;
 n_opt_enum = 0;
@@ -89,9 +89,11 @@ n_opt_other = 0;
 var_opt_char[0] = "optimize";
 var_opt_char[1] = "optimize_size";
 var_opt_char[2] = "optimize_debug";
+var_opt_char[3] = "optimize_fast";
 var_opt_range["optimize"] = "0, 255";
 var_opt_range["optimize_size"] = "0, 1";
 var_opt_range["optimize_debug"] = "0, 1";
+var_opt_range["optimize_fast"] = "0, 1";
 
 # Sort by size to mimic how the structure is laid out to be friendlier to the
 # cache.
@@ -732,13 +734,15 @@ for (i = 0; i < n_target_val; i++) {
 
 print "}";
 
-n_opt_val = 3;
+n_opt_val = 4;
 var_opt_val[0] = "x_optimize"
 var_opt_val_type[0] = "char "
 var_opt_val[1] = "x_optimize_size"
-var_opt_val[2] = "x_optimize_debug"
 var_opt_val_type[1] = "char "
+var_opt_val[2] = "x_optimize_debug"
 var_opt_val_type[2] = "char "
+var_opt_val[3] = "x_optimize_fast"
+var_opt_val_type[3] = "char "
 for (i = 0; i < n_opts; i++) {
 	if (flag_set_p("(Optimization|PerFunction)", flags[i])) {
 		name = var_name(flags[i])
--- gcc/opth-gen.awk	(revision 268924)
+++ gcc/opth-gen.awk	(revision 268925)
@@ -132,7 +132,7 @@ print "/* Structure to save/restore opti
 print "struct GTY(()) cl_optimization";
 print "{";
 
-n_opt_char = 3;
+n_opt_char = 4;
 n_opt_short = 0;
 n_opt_int = 0;
 n_opt_enum = 0;
@@ -140,6 +140,7 @@ n_opt_other = 0;
 var_opt_char[0] = "unsigned char x_optimize";
 var_opt_char[1] = "unsigned char x_optimize_size";
 var_opt_char[2] = "unsigned char x_optimize_debug";
+var_opt_char[3] = "unsigned char x_optimize_fast";
 
 for (i = 0; i < n_opts; i++) {
 	if (flag_set_p("(Optimization|PerFunction)", flags[i])) {
--- gcc/testsuite/gcc.dg/pr89342.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/pr89342.c	(revision 268925)
@@ -0,0 +1,11 @@
+/* PR other/89342 */
+/* { dg-do compile } */
+/* { dg-options "-O0" } */
+
+__attribute__((optimize("Ofast")))
+void foo (void)
+{
+  __attribute__((optimize("no-inline")))
+  void bar (void) {}
+  bar ();
+}
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2019-02-15  Richard Biener  <rguenther@suse.de>
		    Jakub Jelinek  <jakub@redhat.com>

	PR tree-optimization/89278
	* tree-loop-distribution.c: Include tree-eh.h.
	(generate_memset_builtin, generate_memcpy_builtin): Call
	rewrite_to_non_trapping_overflow on builtin->size before passing it
	to force_gimple_operand_gsi.

	* gcc.dg/pr89278.c: New test.

--- gcc/tree-loop-distribution.c	(revision 268927)
+++ gcc/tree-loop-distribution.c	(revision 268928)
@@ -64,6 +64,7 @@ along with GCC; see the file COPYING3.
 #include "cfgloop.h"
 #include "tree-scalar-evolution.h"
 #include "tree-vectorizer.h"
+#include "tree-eh.h"
 
 
 /* A Reduced Dependence Graph (RDG) vertex representing a statement.  */
@@ -815,6 +816,7 @@ generate_memset_builtin (struct loop *lo
 
   nb_bytes = build_size_arg_loc (loc, partition->main_dr, partition->niter,
 				 partition->plus_one);
+  nb_bytes = rewrite_to_non_trapping_overflow (nb_bytes);
   nb_bytes = force_gimple_operand_gsi (&gsi, nb_bytes, true, NULL_TREE,
 				       false, GSI_CONTINUE_LINKING);
   mem = build_addr_arg_loc (loc, partition->main_dr, nb_bytes);
@@ -871,6 +873,7 @@ generate_memcpy_builtin (struct loop *lo
 
   nb_bytes = build_size_arg_loc (loc, partition->main_dr, partition->niter,
 				 partition->plus_one);
+  nb_bytes = rewrite_to_non_trapping_overflow (nb_bytes);
   nb_bytes = force_gimple_operand_gsi (&gsi, nb_bytes, true, NULL_TREE,
 				       false, GSI_CONTINUE_LINKING);
   dest = build_addr_arg_loc (loc, partition->main_dr, nb_bytes);
--- gcc/testsuite/gcc.dg/pr89278.c	(nonexistent)
+++ gcc/testsuite/gcc.dg/pr89278.c	(revision 268928)
@@ -0,0 +1,23 @@
+/* PR tree-optimization/89278 */
+/* { dg-do compile } */
+/* { dg-options "-O1 -ftrapv -ftree-loop-distribute-patterns --param max-loop-header-insns=2" } */
+
+void
+foo (int *w, int x, int y, int z)
+{
+  while (x < y + z)
+    {
+      w[x] = 0;
+      ++x;
+    }
+}
+
+void
+bar (int *__restrict u, int *__restrict w, int x, int y, int z)
+{
+  while (x < y + z)
+    {
+      w[x] = u[x];
+      ++x;
+    }
+}
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2019-02-19  Jakub Jelinek  <jakub@redhat.com>

	PR middle-end/89303
	* g++.dg/torture/pr89303.C: Move everything from std namespace to my
	namespace.

--- gcc/testsuite/g++.dg/torture/pr89303.C	(revision 269010)
+++ gcc/testsuite/g++.dg/torture/pr89303.C	(revision 269011)
@@ -2,7 +2,7 @@
 // { dg-do run }
 // { dg-additional-options "-std=c++14" }
 
-namespace std
+namespace my
 {
   typedef __SIZE_TYPE__ size_t;
   typedef decltype(nullptr) nullptr_t;
@@ -172,28 +172,28 @@ template <class... T> using __void_t = t
 
   template<typename _Tp>
     constexpr _Tp&&
-    forward(typename std::remove_reference<_Tp>::type& __t) noexcept
+    forward(typename my::remove_reference<_Tp>::type& __t) noexcept
     { return static_cast<_Tp&&>(__t); }
 
   template<typename _Tp>
     constexpr _Tp&&
-    forward(typename std::remove_reference<_Tp>::type&& __t) noexcept
+    forward(typename my::remove_reference<_Tp>::type&& __t) noexcept
     {
       return static_cast<_Tp&&>(__t);
     }
 
   template<typename _Tp>
-    constexpr typename std::remove_reference<_Tp>::type&&
+    constexpr typename my::remove_reference<_Tp>::type&&
     move(_Tp&& __t) noexcept
-    { return static_cast<typename std::remove_reference<_Tp>::type&&>(__t); }
+    { return static_cast<typename my::remove_reference<_Tp>::type&&>(__t); }
 }
        
-inline void* operator new(std::size_t, void* p) { return p; }
+inline void* operator new(my::size_t, void* p) { return p; }
 
-extern "C" void* malloc(std::size_t);
+extern "C" void* malloc(my::size_t);
 extern "C" void free(void*);
 
-namespace std
+namespace my
 {
   template<typename T>
     class allocator
@@ -254,7 +254,7 @@ namespace std
       using value_type = _Tp;
       using pointer = _Tp*;
       using const_pointer = const _Tp*;
-      using size_type = std::size_t;
+      using size_type = my::size_t;
 
       static pointer
       allocate(allocator_type& __a, size_type __n)
@@ -267,7 +267,7 @@ namespace std
       template<typename _Up, typename... _Args>
         static void
         construct(allocator_type& __a, _Up* __p, _Args&&... __args)
-        { __a.construct(__p, std::forward<_Args>(__args)...); }
+        { __a.construct(__p, my::forward<_Args>(__args)...); }
 
       template<typename _Up>
         static void
@@ -282,13 +282,13 @@ namespace std
       using value_type = typename allocator_traits<_Alloc>::value_type;
 
       __allocated_ptr(_Alloc& __a, pointer __ptr) noexcept
-      : _M_alloc(std::__addressof(__a)), _M_ptr(__ptr)
+      : _M_alloc(my::__addressof(__a)), _M_ptr(__ptr)
       { }
 
       template<typename _Ptr,
         typename _Req = _Require<is_same<_Ptr, value_type*>>>
       __allocated_ptr(_Alloc& __a, _Ptr __ptr)
-      : _M_alloc(std::__addressof(__a)),
+      : _M_alloc(my::__addressof(__a)),
       _M_ptr(__ptr)
       { }
 
@@ -299,11 +299,11 @@ namespace std
       ~__allocated_ptr()
       {
         if (_M_ptr != nullptr)
-          std::allocator_traits<_Alloc>::deallocate(*_M_alloc, _M_ptr, 1);
+          my::allocator_traits<_Alloc>::deallocate(*_M_alloc, _M_ptr, 1);
       }
 
       __allocated_ptr&
-      operator=(std::nullptr_t) noexcept
+      operator=(my::nullptr_t) noexcept
       {
         _M_ptr = nullptr;
         return *this;
@@ -320,7 +320,7 @@ namespace std
     __allocated_ptr<_Alloc>
     __allocate_guarded(_Alloc& __a)
     {
-      return { __a, std::allocator_traits<_Alloc>::allocate(__a, 1) };
+      return { __a, my::allocator_traits<_Alloc>::allocate(__a, 1) };
     }
 
   template<typename _Tp>
@@ -461,7 +461,7 @@ namespace std
         : _M_impl(__a)
         {
           allocator_traits<_Alloc>::construct(__a, _M_ptr(),
-              std::forward<_Args>(__args)...);
+              my::forward<_Args>(__args)...);
         }
 
       ~_Sp_counted_ptr_inplace() noexcept { }
@@ -500,10 +500,10 @@ namespace std
       {
         typedef _Sp_counted_ptr_inplace<_Tp, _Alloc> _Sp_cp_type;
         typename _Sp_cp_type::__allocator_type __a2(__a._M_a);
-        auto __guard = std::__allocate_guarded(__a2);
+        auto __guard = my::__allocate_guarded(__a2);
         _Sp_cp_type* __mem = __guard.get();
         auto __pi = ::new (__mem)
-          _Sp_cp_type(__a._M_a, std::forward<_Args>(__args)...);
+          _Sp_cp_type(__a._M_a, my::forward<_Args>(__args)...);
         __guard = nullptr;
         _M_pi = __pi;
         __p = __pi->_M_ptr();
@@ -631,7 +631,7 @@ namespace std
 
       template<typename _Alloc, typename... _Args>
         shared_ptr(_Sp_alloc_shared_tag<_Alloc> __tag, _Args&&... __args)
-        : _M_ptr(), _M_refcount(_M_ptr, __tag, std::forward<_Args>(__args)...)
+        : _M_ptr(), _M_refcount(_M_ptr, __tag, my::forward<_Args>(__args)...)
         { _M_enable_shared_from_this_with(_M_ptr); }
 
       template<typename _Tp1, typename _Alloc,
@@ -645,8 +645,8 @@ namespace std
 
       template<typename _Yp>
         using __esft_base_t = decltype(__enable_shared_from_this_base(
-              std::declval<const __shared_count&>(),
-              std::declval<_Yp*>()));
+              my::declval<const __shared_count&>(),
+              my::declval<_Yp*>()));
 
       template<typename _Yp, typename = void>
         struct __has_esft_base
@@ -757,20 +757,20 @@ namespace std
     allocate_shared(const _Alloc& __a, _Args&&... __args)
     {
       return shared_ptr<_Tp>(_Sp_alloc_shared_tag<_Alloc>{__a},
-        std::forward<_Args>(__args)...);
+        my::forward<_Args>(__args)...);
     }
 
   template<typename _Tp, typename... _Args>
     inline shared_ptr<_Tp>
     make_shared(_Args&&... __args)
     {
-      typedef typename std::remove_const<_Tp>::type _Tp_nc;
-      return std::allocate_shared<_Tp>(std::allocator<_Tp_nc>(),
-           std::forward<_Args>(__args)...);
+      typedef typename my::remove_const<_Tp>::type _Tp_nc;
+      return my::allocate_shared<_Tp>(my::allocator<_Tp_nc>(),
+           my::forward<_Args>(__args)...);
     }
 }
 
-class blob final: public std::enable_shared_from_this<blob>
+class blob final: public my::enable_shared_from_this<blob>
 {
   int* data;
 
@@ -780,13 +780,13 @@ public:
 };
 
 static int
-bar(std::shared_ptr<blob>)
+bar(my::shared_ptr<blob>)
 {
   return 0;
 }
 
 int main()
 {
-  std::shared_ptr<blob> tg = std::make_shared<blob>();
+  my::shared_ptr<blob> tg = my::make_shared<blob>();
   return tg->shared_from_this().use_count() - 2;
 }
-------------- next part --------------
2019-08-30  Jakub Jelinek  <jakub@redhat.com>

	Backported from mainline
	2019-02-18  Jakub Jelinek  <jakub@redhat.com>
 
	PR target/89361
	* config/s390/s390.c (s390_indirect_branch_attrvalue,
	s390_indirect_branch_settings): Define unconditionally.
	(s390_set_current_function): Likewise, but guard the whole body except
	the s390_indirect_branch_settings call with
	#if S390_USE_TARGET_ATTRIBUTE.
	(TARGET_SET_CURRENT_FUNCTION): Redefine unconditionally.

--- gcc/config/s390/s390.c	(revision 269243)
+++ gcc/config/s390/s390.c	(revision 269244)
@@ -16039,6 +16039,7 @@ s390_can_inline_p (tree caller, tree cal
 
   return ret;
 }
+#endif
 
 /* Set VAL to correct enum value according to the indirect-branch or
    function-return attribute in ATTR.  */
@@ -16112,6 +16113,7 @@ s390_indirect_branch_settings (tree fnde
     s390_indirect_branch_attrvalue (attr, &cfun->machine->function_return_mem);
 }
 
+#if S390_USE_TARGET_ATTRIBUTE
 /* Restore targets globals from NEW_TREE and invalidate s390_previous_fndecl
    cache.  */
 
@@ -16127,6 +16129,7 @@ s390_activate_target_options (tree new_t
     TREE_TARGET_GLOBALS (new_tree) = save_target_globals_default_opts ();
   s390_previous_fndecl = NULL_TREE;
 }
+#endif
 
 /* Establish appropriate back-end context for processing the function
    FNDECL.  The argument might be NULL to indicate processing at top
@@ -16134,6 +16137,7 @@ s390_activate_target_options (tree new_t
 static void
 s390_set_current_function (tree fndecl)
 {
+#if S390_USE_TARGET_ATTRIBUTE
   /* Only change the context if the function changes.  This hook is called
      several times in the course of compiling a function, and we don't want to
      slow things down too much or call target_reinit when it isn't safe.  */
@@ -16165,10 +16169,9 @@ s390_set_current_function (tree fndecl)
   if (old_tree != new_tree)
     s390_activate_target_options (new_tree);
   s390_previous_fndecl = fndecl;
-
+#endif
   s390_indirect_branch_settings (fndecl);
 }
-#endif
 
 /* Implement TARGET_USE_BY_PIECES_INFRASTRUCTURE_P.  */
 
@@ -16907,10 +16910,10 @@ s390_case_values_threshold (void)
 #undef TARGET_ASM_FILE_END
 #define TARGET_ASM_FILE_END s390_asm_file_end
 
-#if S390_USE_TARGET_ATTRIBUTE
 #undef TARGET_SET_CURRENT_FUNCTION
 #define TARGET_SET_CURRENT_FUNCTION s390_set_current_function
 
+#if S390_USE_TARGET_ATTRIBUTE
 #undef TARGET_OPTION_VALID_ATTRIBUTE_P
 #define TARGET_OPTION_VALID_ATTRIBUTE_P s390_valid_target_attribute_p
 


More information about the Gcc-patches mailing list