Hi!

I've bootstrapped/regtested on x86_64-linux and i686-linux following
backports from trunk and committed them to gcc-5-branch.

        Jakub
2016-03-30  Jakub Jelinek  <ja...@redhat.com>

        Backported from mainline
        2016-02-12  Jakub Jelinek  <ja...@redhat.com>

        PR ipa/68672
        * ipa-split.c (split_function): Compute retval early in all cases
        if split_part_return_p and return_bb is not EXIT.  Remove all
        clobber stmts and reset all debug stmts that refer to SSA_NAMEs
        defined in split part, except if it is retval, in that case replace
        the old retval with the lhs of the call to the split part.

        * g++.dg/ipa/pr68672-1.C: New test.
        * g++.dg/ipa/pr68672-2.C: New test.
        * g++.dg/ipa/pr68672-3.C: New test.

--- gcc/ipa-split.c     (revision 233373)
+++ gcc/ipa-split.c     (revision 233374)
@@ -1306,8 +1306,8 @@ split_function (basic_block return_bb, s
      FIXME: Once we are able to change return type, we should change function
      to return void instead of just outputting function with undefined return
      value.  For structures this affects quality of codegen.  */
-  else if (!split_point->split_part_set_retval
-           && find_retval (return_bb))
+  else if ((retval = find_retval (return_bb))
+          && !split_point->split_part_set_retval)
     {
       bool redirected = true;
       basic_block new_return_bb = create_basic_block (NULL, 0, return_bb);
@@ -1402,6 +1402,44 @@ split_function (basic_block return_bb, s
       DECL_FUNCTION_CODE (node->decl) = (enum built_in_function) 0;
     }
 
+  /* If return_bb contains any clobbers that refer to SSA_NAMEs
+     set in the split part, remove them.  Also reset debug stmts that
+     refer to SSA_NAMEs set in the split part.  */
+  if (return_bb != EXIT_BLOCK_PTR_FOR_FN (cfun))
+    {
+      gimple_stmt_iterator gsi = gsi_start_bb (return_bb);
+      while (!gsi_end_p (gsi))
+       {
+         tree op;
+         ssa_op_iter iter;
+         gimple stmt = gsi_stmt (gsi);
+         bool remove = false;
+         if (gimple_clobber_p (stmt) || is_gimple_debug (stmt))
+           FOR_EACH_SSA_TREE_OPERAND (op, stmt, iter, SSA_OP_USE)
+             {
+               basic_block bb = gimple_bb (SSA_NAME_DEF_STMT (op));
+               if (op != retval
+                   && bb
+                   && bb != return_bb
+                   && bitmap_bit_p (split_point->split_bbs, bb->index))
+                 {
+                   if (is_gimple_debug (stmt))
+                     {
+                       gimple_debug_bind_reset_value (stmt);
+                       update_stmt (stmt);
+                     }
+                   else
+                     remove = true;
+                   break;
+                 }
+             }
+         if (remove)
+           gsi_remove (&gsi, true);
+         else
+           gsi_next (&gsi);
+       }
+    }
+
   /* If the original function is instrumented then it's
      part is also instrumented.  */
   if (with_bounds)
@@ -1554,7 +1592,7 @@ split_function (basic_block return_bb, s
          return value into and put call just before it.  */
       if (return_bb != EXIT_BLOCK_PTR_FOR_FN (cfun))
        {
-         real_retval = retval = find_retval (return_bb);
+         real_retval = retval;
          retbnd = find_retbnd (return_bb);
 
          if (real_retval && split_point->split_part_set_retval)
@@ -1600,6 +1638,28 @@ split_function (basic_block return_bb, s
                            break;
                          }
                      update_stmt (gsi_stmt (bsi));
+                     /* Also adjust clobbers and debug stmts in return_bb.  */
+                     for (bsi = gsi_start_bb (return_bb); !gsi_end_p (bsi);
+                          gsi_next (&bsi))
+                       {
+                         gimple stmt = gsi_stmt (bsi);
+                         if (gimple_clobber_p (stmt)
+                             || is_gimple_debug (stmt))
+                           {
+                             ssa_op_iter iter;
+                             use_operand_p use_p;
+                             bool update = false;
+                             FOR_EACH_SSA_USE_OPERAND (use_p, stmt, iter,
+                                                       SSA_OP_USE)
+                               if (USE_FROM_PTR (use_p) == real_retval)
+                                 {
+                                   SET_USE (use_p, retval);
+                                   update = true;
+                                 }
+                             if (update)
+                               update_stmt (stmt);
+                           }
+                       }
                    }
 
                  /* Replace retbnd with new one.  */
--- gcc/testsuite/g++.dg/ipa/pr68672-1.C        (revision 0)
+++ gcc/testsuite/g++.dg/ipa/pr68672-1.C        (revision 233374)
@@ -0,0 +1,20 @@
+// PR ipa/68672
+// { dg-do compile }
+// { dg-options "-O -finline-small-functions -fpartial-inlining 
--param=partial-inlining-entry-probability=100" }
+
+void f2 (void *);
+void *a;
+struct C { virtual void m1 (); };
+struct D { C *m2 () { if (a) __builtin_abort (); } };
+D f1 ();
+struct E { int e; ~E () { if (e) f2 (&e); } };
+E *b;
+struct I { virtual void m3 (); };
+
+void
+I::m3 ()
+{
+  if (a)
+    f1 ().m2 ()->m1 ();
+  b->~E ();
+}
--- gcc/testsuite/g++.dg/ipa/pr68672-2.C        (revision 0)
+++ gcc/testsuite/g++.dg/ipa/pr68672-2.C        (revision 233374)
@@ -0,0 +1,54 @@
+// PR ipa/68672
+// { dg-do compile }
+// { dg-options "-O3 --param=partial-inlining-entry-probability=100 -g" }
+
+struct S { ~S () {} };
+S *a;
+int *b;
+void bar ();
+void baz ();
+void fn (int *);
+
+static int
+foo ()
+{
+  S *c = a;
+  if (c)
+    {
+      bar ();
+      if (a)
+       __builtin_abort ();
+      baz ();
+    }
+  int p = *b;
+  if (p)
+    {
+      fn (b); fn (b); fn (b); fn (b); fn (b); fn (b); fn (b); fn (b); fn (b); 
fn (b);
+      fn (b); fn (b); fn (b); fn (b); fn (b); fn (b); fn (b); fn (b); fn (b); 
fn (b);
+      fn (b); fn (b); fn (b); fn (b); fn (b); fn (b); fn (b); fn (b); fn (b); 
fn (b);
+      fn (b); fn (b); fn (b); fn (b); fn (b); fn (b); fn (b); fn (b); fn (b); 
fn (b);
+    }
+  c->~S ();
+  int q = 2 * p;
+  int r = 3 * q;
+  S *d = c;
+  return p;
+}
+
+void
+use1 ()
+{
+  foo ();
+}
+
+void
+use2 ()
+{
+  foo ();
+}
+
+void
+use3 ()
+{
+  foo ();
+}
--- gcc/testsuite/g++.dg/ipa/pr68672-3.C        (revision 0)
+++ gcc/testsuite/g++.dg/ipa/pr68672-3.C        (revision 233374)
@@ -0,0 +1,57 @@
+// PR ipa/68672
+// { dg-do compile }
+// { dg-options "-O3 --param=partial-inlining-entry-probability=100 -g" }
+
+struct S { ~S () {} };
+S *a, *e;
+int *b;
+void bar ();
+void baz ();
+void fn (int *);
+void fn2 (S *);
+
+static int
+foo ()
+{
+  S *c = a;
+  if (c)
+    {
+      bar ();
+      if (a)
+       __builtin_abort ();
+      baz ();
+    }
+  int p = *b;
+  S *f = e;
+  if (p)
+    {
+      fn2 (f);
+      fn (b); fn (b); fn (b); fn (b); fn (b); fn (b); fn (b); fn (b); fn (b); 
fn (b);
+      fn (b); fn (b); fn (b); fn (b); fn (b); fn (b); fn (b); fn (b); fn (b); 
fn (b);
+      fn (b); fn (b); fn (b); fn (b); fn (b); fn (b); fn (b); fn (b); fn (b); 
fn (b);
+      fn (b); fn (b); fn (b); fn (b); fn (b); fn (b); fn (b); fn (b); fn (b); 
fn (b);
+    }
+  f->~S ();
+  int q = 2 * p;
+  int r = 3 * q;
+  S *d = c;
+  return p;
+}
+
+void
+use1 ()
+{
+  foo ();
+}
+
+void
+use2 ()
+{
+  foo ();
+}
+
+void
+use3 ()
+{
+  foo ();
+}
2016-03-30  Jakub Jelinek  <ja...@redhat.com>

        Backported from mainline
        2016-02-22  Jakub Jelinek  <ja...@redhat.com>

        PR target/69885
        * gcc.dg/pr69885.c: New test.

        2016-02-16  Jakub Jelinek  <ja...@redhat.com>

        PR rtl-optimization/69764
        PR rtl-optimization/69771
        * optabs.c (expand_binop): Ensure for shift optabs invalid CONST_INT
        op1 is valid for GET_MODE_INNER (mode) and force it into a reg.

        2016-02-12  Jakub Jelinek  <ja...@redhat.com>

        PR rtl-optimization/69764
        PR rtl-optimization/69771
        * optabs.c (expand_binop_directly): For shift_optab_p, force
        convert_modes with VOIDmode if xop1 has VOIDmode.

        * c-c++-common/pr69764.c: New test.
        * gcc.dg/torture/pr69771.c: New test.

--- gcc/optabs.c        (revision 233380)
+++ gcc/optabs.c        (revision 233456)
@@ -1419,6 +1419,7 @@ expand_binop_directly (machine_mode mode
   rtx pat;
   rtx xop0 = op0, xop1 = op1;
   rtx swap;
+  bool canonicalize_op1 = false;
 
   /* If it is a commutative operator and the modes would match
      if we would swap the operands, we can save the conversions.  */
@@ -1436,6 +1437,11 @@ expand_binop_directly (machine_mode mode
   xop0 = avoid_expensive_constant (xmode0, binoptab, 0, xop0, unsignedp);
   if (!shift_optab_p (binoptab))
     xop1 = avoid_expensive_constant (xmode1, binoptab, 1, xop1, unsignedp);
+  else if (xmode1 != VOIDmode)
+    /* Shifts and rotates often use a different mode for op1 from op0;
+       for VOIDmode constants we don't know the mode, so force it
+       to be canonicalized using convert_modes.  */
+    canonicalize_op1 = true;
 
   /* In case the insn wants input operands in modes different from
      those of the actual operands, convert the operands.  It would
@@ -1450,7 +1456,8 @@ expand_binop_directly (machine_mode mode
       mode0 = xmode0;
     }
 
-  mode1 = GET_MODE (xop1) != VOIDmode ? GET_MODE (xop1) : mode;
+  mode1 = ((GET_MODE (xop1) != VOIDmode || canonicalize_op1)
+          ? GET_MODE (xop1) : mode);
   if (xmode1 != VOIDmode && xmode1 != mode1)
     {
       xop1 = convert_modes (xmode1, mode1, xop1, unsignedp);
@@ -1535,7 +1542,7 @@ expand_binop (machine_mode mode, optab b
     = (methods == OPTAB_LIB || methods == OPTAB_LIB_WIDEN
        ? OPTAB_WIDEN : methods);
   enum mode_class mclass;
-  machine_mode wider_mode;
+  machine_mode wider_mode, inner_mode;
   rtx libfunc;
   rtx temp;
   rtx_insn *entry_last = get_last_insn ();
@@ -1551,6 +1558,18 @@ expand_binop (machine_mode mode, optab b
       op1 = negate_rtx (mode, op1);
       binoptab = add_optab;
     }
+  /* For shifts, constant invalid op1 might be expanded from different
+     mode than MODE.  As those are invalid, force them to a register
+     to avoid further problems during expansion.  */
+  else if (CONST_INT_P (op1)
+          && shift_optab_p (binoptab)
+          && (inner_mode = (GET_MODE_INNER (mode) == VOIDmode
+                            ? mode : GET_MODE_INNER (mode))) != VOIDmode
+          && UINTVAL (op1) >= GET_MODE_BITSIZE (inner_mode))
+    {
+      op1 = gen_int_mode (INTVAL (op1), inner_mode);
+      op1 = force_reg (inner_mode, op1);
+    }
 
   /* Record where to delete back to if we backtrack.  */
   last = get_last_insn ();
--- gcc/testsuite/gcc.dg/torture/pr69771.c      (revision 0)
+++ gcc/testsuite/gcc.dg/torture/pr69771.c      (revision 233381)
@@ -0,0 +1,12 @@
+/* PR rtl-optimization/69771 */
+/* { dg-do compile } */
+
+unsigned char a = 5, c;
+unsigned short b = 0;
+unsigned d = 0x76543210;
+
+void
+foo (void)
+{
+  c = d >> ~(a || ~b); /* { dg-warning "shift count is negative" "" { xfail 
*-*-* } } */
+}
--- gcc/testsuite/c-c++-common/pr69764.c        (revision 0)
+++ gcc/testsuite/c-c++-common/pr69764.c        (revision 233381)
@@ -0,0 +1,38 @@
+/* PR rtl-optimization/69764 */
+/* { dg-do compile { target int32plus } } */
+
+unsigned char
+fn1 (unsigned char a)
+{
+  return a >> ~6;      /* { dg-warning "right shift count is negative" } */
+}
+
+unsigned short
+fn2 (unsigned short a)
+{
+  return a >> ~6;      /* { dg-warning "right shift count is negative" } */
+}
+
+unsigned int
+fn3 (unsigned int a)
+{
+  return a >> ~6;      /* { dg-warning "right shift count is negative" } */
+}
+
+unsigned char
+fn4 (unsigned char a)
+{
+  return a >> 0xff03;  /* { dg-warning "right shift count >= width of type" } 
*/
+}
+
+unsigned short
+fn5 (unsigned short a)
+{
+  return a >> 0xff03;  /* { dg-warning "right shift count >= width of type" } 
*/
+}
+
+unsigned int
+fn6 (unsigned int a)
+{
+  return a >> 0xff03;  /* { dg-warning "right shift count >= width of type" } 
*/
+}
--- gcc/testsuite/gcc.dg/pr69885.c      (revision 0)
+++ gcc/testsuite/gcc.dg/pr69885.c      (revision 233603)
@@ -0,0 +1,13 @@
+/* PR target/69885 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+/* { dg-additional-options "-m68000" { target m68k*-*-* } } */
+
+void bar (void);
+
+void
+foo (long long x)
+{
+  if (x >> 1)
+    bar ();
+}
2016-03-30  Jakub Jelinek  <ja...@redhat.com>

        Backported from mainline
        2016-02-15  Jakub Jelinek  <ja...@redhat.com>

        PR c++/69797
        * c-common.c (sync_resolve_size): Diagnose too few arguments
        even when params is non-NULL empty vector.

        * c-c++-common/pr69797.c: New test.

--- gcc/c-family/c-common.c     (revision 233433)
+++ gcc/c-family/c-common.c     (revision 233434)
@@ -10675,7 +10675,7 @@ sync_resolve_size (tree function, vec<tr
   tree type;
   int size;
 
-  if (!params)
+  if (vec_safe_is_empty (params))
     {
       error ("too few arguments to function %qE", function);
       return 0;
--- gcc/testsuite/c-c++-common/pr69797.c        (revision 0)
+++ gcc/testsuite/c-c++-common/pr69797.c        (revision 233434)
@@ -0,0 +1,8 @@
+/* PR c++/69797 */
+/* { dg-do compile } */
+
+void
+foo () 
+{
+  __atomic_fetch_add ();       /* { dg-error "too few arguments to function" } 
*/
+}
2016-03-30  Jakub Jelinek  <ja...@redhat.com>

        Backported from mainline
        2016-02-16  Jakub Jelinek  <ja...@redhat.com>

        PR tree-optimization/69802
        * tree-ssa-reassoc.c (update_range_test): If op is
        SSA_NAME_IS_DEFAULT_DEF, give up unless tem is a positive
        op == 1 test of precision 1 integral op, otherwise handle
        that case as op itself.  Fix up formatting.
        (optimize_range_tests_to_bit_test, optimize_range_tests): Fix
        up formatting.

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

--- gcc/tree-ssa-reassoc.c      (revision 233445)
+++ gcc/tree-ssa-reassoc.c      (revision 233446)
@@ -2134,11 +2134,33 @@ update_range_test (struct range_entry *r
                                in_p, low, high);
   enum warn_strict_overflow_code wc = WARN_STRICT_OVERFLOW_COMPARISON;
   gimple_stmt_iterator gsi;
-  unsigned int i;
+  unsigned int i, uid;
 
   if (tem == NULL_TREE)
     return false;
 
+  /* If op is default def SSA_NAME, there is no place to insert the
+     new comparison.  Give up, unless we can use OP itself as the
+     range test.  */
+  if (op && SSA_NAME_IS_DEFAULT_DEF (op))
+    {
+      if (op == range->exp
+         && ((TYPE_PRECISION (optype) == 1 && TYPE_UNSIGNED (optype))
+             || TREE_CODE (optype) == BOOLEAN_TYPE)
+         && (op == tem
+             || (TREE_CODE (tem) == EQ_EXPR
+                 && TREE_OPERAND (tem, 0) == op
+                 && integer_onep (TREE_OPERAND (tem, 1))))
+         && opcode != BIT_IOR_EXPR
+         && (opcode != ERROR_MARK || oe->rank != BIT_IOR_EXPR))
+       {
+         stmt = NULL;
+         tem = op;
+       }
+      else
+       return false;
+    }
+
   if (strict_overflow_p && issue_strict_overflow_warning (wc))
     warning_at (loc, OPT_Wstrict_overflow,
                "assuming signed overflow does not occur "
@@ -2176,12 +2198,22 @@ update_range_test (struct range_entry *r
     tem = invert_truthvalue_loc (loc, tem);
 
   tem = fold_convert_loc (loc, optype, tem);
-  gsi = gsi_for_stmt (stmt);
-  unsigned int uid = gimple_uid (stmt);
+  if (stmt)
+    {
+      gsi = gsi_for_stmt (stmt);
+      uid = gimple_uid (stmt);
+    }
+  else
+    {
+      gsi = gsi_none ();
+      uid = 0;
+    }
+  if (stmt == NULL)
+    gcc_checking_assert (tem == op);
   /* In rare cases range->exp can be equal to lhs of stmt.
      In that case we have to insert after the stmt rather then before
      it.  If stmt is a PHI, insert it at the start of the basic block.  */
-  if (op != range->exp)
+  else if (op != range->exp)
     {
       gsi_insert_seq_before (&gsi, seq, GSI_SAME_STMT);
       tem = force_gimple_operand_gsi (&gsi, tem, true, NULL_TREE, true,
--- gcc/testsuite/gcc.dg/pr69802.c      (revision 0)
+++ gcc/testsuite/gcc.dg/pr69802.c      (revision 233446)
@@ -0,0 +1,23 @@
+/* PR tree-optimization/69802 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -Wall" } */
+
+struct S { unsigned f : 1; };
+int a, d;
+
+int
+foo (void)
+{
+  unsigned b = 0;
+  struct S c;
+  d = ((1 && b) < c.f) & c.f;  /* { dg-warning "is used uninitialized" } */
+  return a;
+}
+
+int
+bar (_Bool c)
+{
+  unsigned b = 0;
+  d = ((1 && b) < c) & c;
+  return a;
+}
2016-03-30  Jakub Jelinek  <ja...@redhat.com>

        Backported from mainline
        2016-02-19  Jakub Jelinek  <ja...@redhat.com>

        PR c++/67767
        * parser.c (cp_parser_std_attribute_spec_seq): Don't assume
        attr_spec is always single element chain, chain all the attributes
        properly together in the right order.

        * g++.dg/cpp0x/pr67767.C: New test.

--- gcc/cp/parser.c     (revision 233559)
+++ gcc/cp/parser.c     (revision 233560)
@@ -24104,7 +24104,8 @@ cp_parser_std_attribute_spec (cp_parser
 static tree
 cp_parser_std_attribute_spec_seq (cp_parser *parser)
 {
-  tree attr_specs = NULL;
+  tree attr_specs = NULL_TREE;
+  tree attr_last = NULL_TREE;
 
   while (true)
     {
@@ -24114,11 +24115,13 @@ cp_parser_std_attribute_spec_seq (cp_par
       if (attr_spec == error_mark_node)
        return error_mark_node;
 
-      TREE_CHAIN (attr_spec) = attr_specs;
-      attr_specs = attr_spec;
+      if (attr_last)
+       TREE_CHAIN (attr_last) = attr_spec;
+      else
+       attr_specs = attr_last = attr_spec;
+      attr_last = tree_last (attr_last);
     }
 
-  attr_specs = nreverse (attr_specs);
   return attr_specs;
 }
 
--- gcc/testsuite/g++.dg/cpp0x/pr67767.C        (revision 0)
+++ gcc/testsuite/g++.dg/cpp0x/pr67767.C        (revision 233560)
@@ -0,0 +1,10 @@
+// PR c++/67767
+// { dg-do compile { target c++11 } }
+// { dg-options "-Wsuggest-attribute=noreturn" }
+
+void foo [[gnu::cold, gnu::noreturn]] ();
+
+void foo ()    // { dg-bogus "function might be candidate for attribute" }
+{
+  throw 1;
+}
2016-03-30  Jakub Jelinek  <ja...@redhat.com>

        Backported from mainline
        2016-02-19  Jakub Jelinek  <ja...@redhat.com>

        PR middle-end/69838
        * lra.c (lra_process_new_insns): If non-call exceptions are enabled,
        call copy_reg_eh_region_note_forward on before and/or after sequences
        and remove note from insn if it no longer can throw.

--- gcc/lra.c   (revision 233561)
+++ gcc/lra.c   (revision 233562)
@@ -1742,20 +1742,29 @@ lra_process_new_insns (rtx_insn *insn, r
     }
   if (before != NULL_RTX)
     {
+      if (cfun->can_throw_non_call_exceptions)
+       copy_reg_eh_region_note_forward (insn, before, NULL);
       emit_insn_before (before, insn);
       push_insns (PREV_INSN (insn), PREV_INSN (before));
       setup_sp_offset (before, PREV_INSN (insn));
     }
   if (after != NULL_RTX)
     {
+      if (cfun->can_throw_non_call_exceptions)
+       copy_reg_eh_region_note_forward (insn, after, NULL);
       for (last = after; NEXT_INSN (last) != NULL_RTX; last = NEXT_INSN (last))
        ;
       emit_insn_after (after, insn);
       push_insns (last, insn);
       setup_sp_offset (after, last);
     }
+  if (cfun->can_throw_non_call_exceptions)
+    {
+      rtx note = find_reg_note (insn, REG_EH_REGION, NULL_RTX);
+      if (note && !insn_could_throw_p (insn))
+       remove_note (insn, note);
+    }
 }
-
 
 
 /* Replace all references to register OLD_REGNO in *LOC with pseudo
2016-03-30  Jakub Jelinek  <ja...@redhat.com>

        Backported from mainline
        2016-02-19  Jakub Jelinek  <ja...@redhat.com>

        PR c++/69826
        * c-pragma.c (c_pp_lookup_pragma): Handle PRAGMA_CILK_GRAINSIZE.
        (init_pragma): Register PRAGMA_CILK_GRAINSIZE even for
        flag_preprocess_only.

        * c-c++-common/cilk-plus/CK/pr69826-1.c: New test.
        * c-c++-common/cilk-plus/CK/pr69826-2.c: New test.

--- gcc/c-family/c-pragma.c     (revision 233570)
+++ gcc/c-family/c-pragma.c     (revision 233571)
@@ -1336,6 +1336,13 @@ c_pp_lookup_pragma (unsigned int id, con
       return;
     }
 
+  if (id == PRAGMA_CILK_GRAINSIZE)
+    {
+      *space = "cilk";
+      *name = "grainsize";
+      return;
+    }
+
   if (id >= PRAGMA_FIRST_EXTERNAL
       && (id < PRAGMA_FIRST_EXTERNAL + registered_pp_pragmas.length ()))
     {
@@ -1523,7 +1530,7 @@ init_pragma (void)
     cpp_register_deferred_pragma (parse_in, "GCC", "ivdep", PRAGMA_IVDEP, 
false,
                                  false);
 
-  if (flag_cilkplus && !flag_preprocess_only)
+  if (flag_cilkplus)
     cpp_register_deferred_pragma (parse_in, "cilk", "grainsize",
                                  PRAGMA_CILK_GRAINSIZE, true, false);
 
--- gcc/testsuite/c-c++-common/cilk-plus/CK/pr69826-1.c (revision 0)
+++ gcc/testsuite/c-c++-common/cilk-plus/CK/pr69826-1.c (revision 233571)
@@ -0,0 +1,25 @@
+/* { dg-do run { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-options "-fcilkplus" } */
+/* { dg-additional-options "-std=gnu99" { target c } } */
+/* { dg-additional-options "-lcilkrts" { target { i?86-*-* x86_64-*-* } } } */
+
+#define GRAINSIZE 2
+
+int
+main ()
+{
+  int a[64];
+  #pragma cilk grainsize=GRAINSIZE
+  _Cilk_for (int i = 0; i < 64; i++)
+    a[i] = 0;
+  #pragma cilk grainsize =GRAINSIZE
+  _Cilk_for (int i = 0; i < 64; i++)
+    a[i]++;
+  #pragma cilk grainsize = GRAINSIZE
+  _Cilk_for (int i = 0; i < 64; i++)
+    a[i]++;
+  for (int i = 0; i < 64; i++)
+    if (a[i] != 2)
+      __builtin_abort ();
+  return 0;
+}
--- gcc/testsuite/c-c++-common/cilk-plus/CK/pr69826-2.c (revision 0)
+++ gcc/testsuite/c-c++-common/cilk-plus/CK/pr69826-2.c (revision 233571)
@@ -0,0 +1,6 @@
+/* { dg-do run { target { i?86-*-* x86_64-*-* } } } */
+/* { dg-options "-fcilkplus -save-temps" } */
+/* { dg-additional-options "-std=gnu99" { target c } } */
+/* { dg-additional-options "-lcilkrts" { target { i?86-*-* x86_64-*-* } } } */
+
+#include "pr69826-1.c"
2016-03-30  Jakub Jelinek  <ja...@redhat.com>

        Backported from mainline
        2016-02-24  Jakub Jelinek  <ja...@redhat.com>

        PR debug/69705
        * dwarf2out.c (gen_variable_die): Work around buggy LTO
        - allow NULL decl for Fortran DW_TAG_common_block variables.

--- gcc/dwarf2out.c     (revision 233684)
+++ gcc/dwarf2out.c     (revision 233685)
@@ -19129,7 +19129,7 @@ gen_variable_die (tree decl, tree origin
                 DW_TAG_common_block and DW_TAG_variable.  */
              loc = loc_list_from_tree (com_decl, 2, NULL);
            }
-          else if (DECL_EXTERNAL (decl))
+         else if (DECL_EXTERNAL (decl_or_origin))
            add_AT_flag (com_die, DW_AT_declaration, 1);
          if (want_pubnames ())
            add_pubname_string (cnam, com_die); /* ??? needed? */
@@ -19144,9 +19144,9 @@ gen_variable_die (tree decl, tree origin
          remove_AT (com_die, DW_AT_declaration);
        }
       var_die = new_die (DW_TAG_variable, com_die, decl);
-      add_name_and_src_coords_attributes (var_die, decl);
-      add_type_attribute (var_die, TREE_TYPE (decl), decl_quals (decl),
-                         context_die);
+      add_name_and_src_coords_attributes (var_die, decl_or_origin);
+      add_type_attribute (var_die, TREE_TYPE (decl_or_origin),
+                         decl_quals (decl_or_origin), context_die);
       add_AT_flag (var_die, DW_AT_external, 1);
       if (loc)
        {
@@ -19167,9 +19167,10 @@ gen_variable_die (tree decl, tree origin
            }
          add_AT_location_description (var_die, DW_AT_location, loc);
        }
-      else if (DECL_EXTERNAL (decl))
+      else if (DECL_EXTERNAL (decl_or_origin))
        add_AT_flag (var_die, DW_AT_declaration, 1);
-      equate_decl_number_to_die (decl, var_die);
+      if (decl)
+       equate_decl_number_to_die (decl, var_die);
       return;
     }
 
2016-03-30  Jakub Jelinek  <ja...@redhat.com>

        Backported from mainline
        2016-02-26  Jakub Jelinek  <ja...@redhat.com>
                    Eric Botcazou  <ebotca...@adacore.com>

        PR rtl-optimization/69891
        * dse.c (scan_insn): If we can't figure out memset arguments
        or they are non-constant, call clear_rhs_from_active_local_stores.

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

--- gcc/dse.c   (revision 233742)
+++ gcc/dse.c   (revision 233743)
@@ -2556,6 +2556,8 @@ scan_insn (bb_info_t bb_info, rtx_insn *
                      active_local_stores = insn_info;
                    }
                }
+             else
+               clear_rhs_from_active_local_stores ();
            }
        }
       else if (SIBLING_CALL_P (insn) && reload_completed)
--- gcc/testsuite/gcc.target/i386/pr69891.c     (revision 0)
+++ gcc/testsuite/gcc.target/i386/pr69891.c     (revision 233743)
@@ -0,0 +1,30 @@
+/* PR rtl-optimization/69891 */
+/* { dg-do run } */
+/* { dg-options "-O -fno-tree-fre -mstringop-strategy=libcall -Wno-psabi" } */
+/* { dg-additional-options "-mno-sse" { target ia32 } } */
+
+typedef unsigned short A;
+typedef unsigned short B __attribute__ ((vector_size (32)));
+typedef unsigned int C;
+typedef unsigned int D __attribute__ ((vector_size (32)));
+typedef unsigned long long E;
+typedef unsigned long long F __attribute__ ((vector_size (32)));
+
+__attribute__((noinline, noclone)) unsigned
+foo(D a, B b, D c, F d)
+{
+  b /= (B) {1, -c[0]} | 1;
+  c[0] |= 7;
+  a %= c | 1;
+  c ^= c;
+  return a[0] + b[15] + c[0] + d[3];
+}
+
+int
+main ()
+{
+  unsigned x = foo ((D) {}, (B) {}, (D) {}, (F) {});
+  if (x != 0)
+    __builtin_abort ();
+  return 0;
+}
2016-03-30  Jakub Jelinek  <ja...@redhat.com>

        Backported from mainline
        2016-02-26  Jakub Jelinek  <ja...@redhat.com>

        PR target/69969
        * config/rs6000/rs6000.c (rs6000_option_override_internal): Don't
        complain about -mallow-movmisalign without -mvsx if
        TARGET_ALLOW_MOVMISALIGN was not set explicitly.

        * gcc.target/powerpc/pr69969.c: New test.

--- gcc/config/rs6000/rs6000.c  (revision 233766)
+++ gcc/config/rs6000/rs6000.c  (revision 233767)
@@ -4207,7 +4207,8 @@ rs6000_option_override_internal (bool gl
 
   else if (TARGET_ALLOW_MOVMISALIGN && !TARGET_VSX)
     {
-      if (TARGET_ALLOW_MOVMISALIGN > 0)
+      if (TARGET_ALLOW_MOVMISALIGN > 0
+         && global_options_set.x_TARGET_ALLOW_MOVMISALIGN)
        error ("-mallow-movmisalign requires -mvsx");
 
       TARGET_ALLOW_MOVMISALIGN = 0;
--- gcc/testsuite/gcc.target/powerpc/pr69969.c  (revision 0)
+++ gcc/testsuite/gcc.target/powerpc/pr69969.c  (revision 233767)
@@ -0,0 +1,7 @@
+/* PR target/69969 */
+/* { dg-do compile } */
+/* { dg-skip-if "do not override -mcpu" { powerpc*-*-* } { "-mcpu=*" } { 
"-mcpu=power8" } } */
+/* { dg-options "-mcpu=power8" } */
+
+int bar (int x) { return x; }
+__attribute__((__target__("no-vsx"))) int foo (int x) { return x; } /* { 
dg-bogus "-mallow-movmisalign requires -mvsx" } */
2016-03-30  Jakub Jelinek  <ja...@redhat.com>

        Backported from mainline
        2016-03-02  Jakub Jelinek  <ja...@redhat.com>

        PR target/70028
        * config/i386/i386.md (kmovw): Move m constraint to 2nd alternative.
        (*movhi_internal): Put mask moves from and to memory separately
        from moves from/to GPRs.

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

--- gcc/config/i386/i386.md     (revision 233903)
+++ gcc/config/i386/i386.md     (revision 233904)
@@ -2442,7 +2442,7 @@ (define_insn "*movsi_internal"
 (define_insn "kmovw"
   [(set (match_operand:HI 0 "nonimmediate_operand" "=k,k")
        (unspec:HI
-         [(match_operand:HI 1 "nonimmediate_operand" "rm,k")]
+         [(match_operand:HI 1 "nonimmediate_operand" "r,km")]
          UNSPEC_KMOV))]
   "!(MEM_P (operands[0]) && MEM_P (operands[1])) && TARGET_AVX512F"
   "@
@@ -2454,8 +2454,8 @@ (define_insn "kmovw"
 
 
 (define_insn "*movhi_internal"
-  [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r ,r ,m ,k,k,rm")
-       (match_operand:HI 1 "general_operand"      "r ,rn,rm,rn,rm,k,k"))]
+  [(set (match_operand:HI 0 "nonimmediate_operand" "=r,r ,r ,m ,k,k, r,m")
+       (match_operand:HI 1 "general_operand"      "r ,rn,rm,rn,r,km,k,k"))]
   "!(MEM_P (operands[0]) && MEM_P (operands[1]))"
 {
   switch (get_attr_type (insn))
@@ -2469,7 +2469,8 @@ (define_insn "*movhi_internal"
       switch (which_alternative)
         {
        case 4: return "kmovw\t{%k1, %0|%0, %k1}";
-       case 5: return "kmovw\t{%1, %0|%0, %1}";
+       case 5: /* FALLTHRU */
+       case 7: return "kmovw\t{%1, %0|%0, %1}";
        case 6: return "kmovw\t{%1, %k0|%k0, %1}";
        default: gcc_unreachable ();
        }
@@ -2482,7 +2483,7 @@ (define_insn "*movhi_internal"
     }
 }
   [(set (attr "type")
-     (cond [(eq_attr "alternative" "4,5,6")
+     (cond [(eq_attr "alternative" "4,5,6,7")
              (const_string "mskmov")
            (match_test "optimize_function_for_size_p (cfun)")
              (const_string "imov")
@@ -2499,7 +2500,7 @@ (define_insn "*movhi_internal"
           ]
           (const_string "imov")))
     (set (attr "prefix")
-      (if_then_else (eq_attr "alternative" "4,5,6")
+      (if_then_else (eq_attr "alternative" "4,5,6,7")
        (const_string "vex")
        (const_string "orig")))
     (set (attr "mode")
--- gcc/testsuite/gcc.target/i386/pr70028.c     (revision 0)
+++ gcc/testsuite/gcc.target/i386/pr70028.c     (revision 233904)
@@ -0,0 +1,19 @@
+/* PR target/70028 */
+/* { dg-do assemble { target avx512bw } } */
+/* { dg-require-effective-target int128 } */
+/* { dg-require-effective-target masm_intel } */
+/* { dg-options "-O2 -fno-forward-propagate -mavx512bw -masm=intel" } */
+
+typedef unsigned short A;
+typedef int B __attribute__ ((vector_size (32)));
+typedef unsigned __int128 C;
+typedef __int128 D __attribute__ ((vector_size (32)));
+
+C
+foo (A a, int b, unsigned c, C d, A e, unsigned f, B g, D h)
+{
+  g[1] ^= (A) ~ a;
+  a ^= (unsigned) g[0];
+  h %= (D) h | 1;
+  return a + b + c + d + e + g[0] + g[1] + h[1];
+}
2016-03-30  Jakub Jelinek  <ja...@redhat.com>

        Backported from mainline
        2016-03-04  Jakub Jelinek  <ja...@redhat.com>

        PR target/70062
        * config/i386/i386.c (decide_alg): Add RECUR argument.  Revert
        2016-02-22 changes, instead don't recurse if RECUR is already true.
        Don't change *dynamic_check if RECUR.  Adjust recursive caller
        to pass true to the new argument.
        (ix86_expand_set_or_movmem): Adjust decide_alg caller.

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

        2016-02-22  Jakub Jelinek  <ja...@redhat.com>

        PR target/69888
        * config/i386/i386.c (decide_alg): Ensure we don't recurse with
        identical arguments.  Formatting and spelling fixes.

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

--- gcc/config/i386/i386.c      (revision 233613)
+++ gcc/config/i386/i386.c      (revision 233979)
@@ -24671,9 +24671,10 @@ alg_usable_p (enum stringop_alg alg, boo
 static enum stringop_alg
 decide_alg (HOST_WIDE_INT count, HOST_WIDE_INT expected_size,
            unsigned HOST_WIDE_INT min_size, unsigned HOST_WIDE_INT max_size,
-           bool memset, bool zero_memset, int *dynamic_check, bool *noalign)
+           bool memset, bool zero_memset, int *dynamic_check, bool *noalign,
+           bool recur)
 {
-  const struct stringop_algs * algs;
+  const struct stringop_algs *algs;
   bool optimize_for_speed;
   int max = 0;
   const struct processor_costs *cost;
@@ -24707,7 +24708,7 @@ decide_alg (HOST_WIDE_INT count, HOST_WI
       any_alg_usable_p |= usable;
 
       if (candidate != libcall && candidate && usable)
-         max = algs->size[i].max;
+       max = algs->size[i].max;
     }
 
   /* If expected size is not known but max size is small enough
@@ -24717,7 +24718,7 @@ decide_alg (HOST_WIDE_INT count, HOST_WI
       && expected_size == -1)
     expected_size = min_size / 2 + max_size / 2;
 
-  /* If user specified the algorithm, honnor it if possible.  */
+  /* If user specified the algorithm, honor it if possible.  */
   if (ix86_stringop_alg != no_stringop
       && alg_usable_p (ix86_stringop_alg, memset))
     return ix86_stringop_alg;
@@ -24792,21 +24793,20 @@ decide_alg (HOST_WIDE_INT count, HOST_WI
          || !alg_usable_p (algs->unknown_size, memset)))
     {
       enum stringop_alg alg;
+      HOST_WIDE_INT new_expected_size = (max > 0 ? max : 4096) / 2;
 
-      /* If there aren't any usable algorithms, then recursing on
-         smaller sizes isn't going to find anything.  Just return the
-         simple byte-at-a-time copy loop.  */
-      if (!any_alg_usable_p)
-        {
-          /* Pick something reasonable.  */
-          if (TARGET_INLINE_STRINGOPS_DYNAMICALLY)
-            *dynamic_check = 128;
-          return loop_1_byte;
-        }
-      if (max <= 0)
-       max = 4096;
-      alg = decide_alg (count, max / 2, min_size, max_size, memset,
-                       zero_memset, dynamic_check, noalign);
+      /* If there aren't any usable algorithms or if recursing already,
+        then recursing on smaller sizes or same size isn't going to
+        find anything.  Just return the simple byte-at-a-time copy loop.  */
+      if (!any_alg_usable_p || recur)
+       {
+         /* Pick something reasonable.  */
+         if (TARGET_INLINE_STRINGOPS_DYNAMICALLY && !recur)
+           *dynamic_check = 128;
+         return loop_1_byte;
+       }
+      alg = decide_alg (count, new_expected_size, min_size, max_size, memset,
+                       zero_memset, dynamic_check, noalign, true);
       gcc_assert (*dynamic_check == -1);
       if (TARGET_INLINE_STRINGOPS_DYNAMICALLY)
        *dynamic_check = max;
@@ -25062,7 +25062,7 @@ ix86_expand_set_or_movmem (rtx dst, rtx
   alg = decide_alg (count, expected_size, min_size, probable_max_size,
                    issetmem,
                    issetmem && val_exp == const0_rtx,
-                   &dynamic_check, &noalign);
+                   &dynamic_check, &noalign, false);
   if (alg == libcall)
     return false;
   gcc_assert (alg != no_stringop);
--- gcc/testsuite/gcc.target/i386/pr69888.c     (revision 0)
+++ gcc/testsuite/gcc.target/i386/pr69888.c     (revision 233615)
@@ -0,0 +1,10 @@
+/* PR target/69888 */
+/* { dg-do compile } */
+/* { dg-options "-minline-all-stringops 
-mmemset-strategy=no_stringop:-1:noalign" } */
+/* { dg-additional-options "-march=geode" { target ia32 } } */
+
+void
+foo (char *p)
+{
+  __builtin_memset (p, 0, 32);
+}
--- gcc/testsuite/gcc.target/i386/pr70062.c     (revision 0)
+++ gcc/testsuite/gcc.target/i386/pr70062.c     (revision 233979)
@@ -0,0 +1,11 @@
+/* PR target/70062 */
+/* { dg-options "-minline-all-stringops -minline-stringops-dynamically 
-mmemcpy-strategy=libcall:-1:noalign -Wno-psabi" } */
+/* { dg-additional-options "-mtune=k6-2" { target ia32 } } */
+
+typedef int V __attribute__ ((vector_size (32)));
+
+V
+foo (V x)
+{
+  return (V) { x[0] };
+}
2016-03-30  Jakub Jelinek  <ja...@redhat.com>

        Backported from mainline
        2016-03-09  Jakub Jelinek  <ja...@redhat.com>

        PR tree-optimization/70152
        * tree-sra.c (replace_removed_params_ssa_names): Copy over
        SSA_NAME_OCCURS_IN_ABNORMAL_PHI from old_name to new_name.

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

--- gcc/tree-sra.c      (revision 234091)
+++ gcc/tree-sra.c      (revision 234092)
@@ -4758,6 +4758,8 @@ replace_removed_params_ssa_names (tree o
 
   repl = get_replaced_param_substitute (adj);
   new_name = make_ssa_name (repl, stmt);
+  SSA_NAME_OCCURS_IN_ABNORMAL_PHI (new_name)
+    = SSA_NAME_OCCURS_IN_ABNORMAL_PHI (old_name);
 
   if (dump_file)
     {
--- gcc/testsuite/gcc.dg/pr70152.c      (revision 0)
+++ gcc/testsuite/gcc.dg/pr70152.c      (revision 234092)
@@ -0,0 +1,27 @@
+/* PR tree-optimization/70152 */
+/* { dg-do compile } */
+/* { dg-options "-O2" } */
+
+int a;
+int foo (void);
+int setjmp (char *);
+char buf[64];
+
+static int
+bar (int x)
+{
+  x = 0;
+  setjmp (buf);
+  for (;;)
+    {
+    switch (x)
+      case 5:
+       x = foo ();
+    }
+}
+
+void
+baz (void)
+{
+  bar (a);
+}
2016-03-30  Jakub Jelinek  <ja...@redhat.com>

        Backported from mainline
        2016-03-11  Jakub Jelinek  <ja...@redhat.com>

        PR tree-optimization/70169
        * tree-ssa-loop.c (gen_lsm_tmp_name): Handle FUNCTION_DECL and
        LABEL_DECL like VAR_DECL.  Emit nothing instead of gcc_unreachable
        for unknown codes.

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

--- gcc/tree-ssa-loop.c (revision 234135)
+++ gcc/tree-ssa-loop.c (revision 234136)
@@ -769,6 +769,8 @@ gen_lsm_tmp_name (tree ref)
     case SSA_NAME:
     case VAR_DECL:
     case PARM_DECL:
+    case FUNCTION_DECL:
+    case LABEL_DECL:
       name = get_name (ref);
       if (!name)
        name = "D";
@@ -784,11 +786,9 @@ gen_lsm_tmp_name (tree ref)
       break;
 
     case INTEGER_CST:
+    default:
       /* Nothing.  */
       break;
-
-    default:
-      gcc_unreachable ();
     }
 }
 
--- gcc/testsuite/gcc.dg/pr70169.c      (revision 0)
+++ gcc/testsuite/gcc.dg/pr70169.c      (revision 234136)
@@ -0,0 +1,40 @@
+/* PR tree-optimization/70169 */
+/* { dg-do compile } */
+/* { dg-options "-O2 -fno-strict-aliasing -fno-tree-dce" } */
+
+int printf (const char *, ...); 
+
+void
+foo ()
+{
+  unsigned char *p = (unsigned char *) &printf;
+  for (;;)
+    (*p)++;
+}
+
+void
+bar (int x)
+{
+  unsigned char *p = (unsigned char *) &printf;
+  int i;
+  for (i = 0; i < x; i++)
+    (*p)++;
+}
+
+void
+baz (int x, int y)
+{
+  unsigned char *p = (unsigned char *) &&lab;
+  int i;
+  if (y)
+    {
+      for (i = 0; i < x; i++)
+       (*p)++;
+    }
+  else
+    {
+     lab:
+      asm volatile ("");
+      foo ();
+    }
+}
2016-03-30  Jakub Jelinek  <ja...@redhat.com>

        Backported from mainline
        2016-03-15  Jakub Jelinek  <ja...@redhat.com>

        PR rtl-optimization/70222
        * combine.c (simplify_shift_const_1): For A >> B >> C LSHIFTRT
        optimization if mode is different from result_mode, queue up masking
        of the result in outer_op.  Formatting fix.

        * gcc.c-torture/execute/pr70222-1.c: New test.
        * gcc.c-torture/execute/pr70222-2.c: New test.

--- gcc/combine.c       (revision 234221)
+++ gcc/combine.c       (revision 234222)
@@ -10524,9 +10524,19 @@ simplify_shift_const_1 (enum rtx_code co
                   && CONST_INT_P (XEXP (varop, 0))
                   && !CONST_INT_P (XEXP (varop, 1)))
            {
+             /* For ((unsigned) (cstULL >> count)) >> cst2 we have to make
+                sure the result will be masked.  See PR70222.  */
+             if (code == LSHIFTRT
+                 && mode != result_mode
+                 && !merge_outer_ops (&outer_op, &outer_const, AND,
+                                      GET_MODE_MASK (result_mode)
+                                      >> orig_count, result_mode,
+                                      &complement_p))
+               break;
+
              rtx new_rtx = simplify_const_binary_operation (code, mode,
-                                                        XEXP (varop, 0),
-                                                        GEN_INT (count));
+                                                            XEXP (varop, 0),
+                                                            GEN_INT (count));
              varop = gen_rtx_fmt_ee (code, mode, new_rtx, XEXP (varop, 1));
              count = 0;
              continue;
--- gcc/testsuite/gcc.c-torture/execute/pr70222-1.c     (revision 0)
+++ gcc/testsuite/gcc.c-torture/execute/pr70222-1.c     (revision 234222)
@@ -0,0 +1,30 @@
+/* PR rtl-optimization/70222 */
+
+int a = 1;
+unsigned int b = 2;
+int c = 0;
+int d = 0;
+
+void
+foo ()
+{
+  int e = ((-(c >= c)) < b) > ((int) (-1ULL >> ((a / a) * 15)));
+  d = -e;
+}
+
+__attribute__((noinline, noclone)) void
+bar (int x)
+{
+  if (x != -1)
+    __builtin_abort ();
+}
+
+int
+main ()
+{
+#if __CHAR_BIT__ == 8 && __SIZEOF_INT__ == 4 && __SIZEOF_LONG_LONG__ == 8
+  foo ();
+  bar (d);
+#endif
+  return 0;
+}
--- gcc/testsuite/gcc.c-torture/execute/pr70222-2.c     (revision 0)
+++ gcc/testsuite/gcc.c-torture/execute/pr70222-2.c     (revision 234222)
@@ -0,0 +1,20 @@
+/* PR rtl-optimization/70222 */
+
+#if __CHAR_BIT__ == 8 && __SIZEOF_INT__ == 4 && __SIZEOF_LONG_LONG__ == 8
+__attribute__((noinline, noclone)) unsigned int
+foo (int x)
+{
+  unsigned long long y = -1ULL >> x;
+  return (unsigned int) y >> 31;
+}
+#endif
+
+int
+main ()
+{
+#if __CHAR_BIT__ == 8 && __SIZEOF_INT__ == 4 && __SIZEOF_LONG_LONG__ == 8
+  if (foo (15) != 1 || foo (32) != 1 || foo (33) != 0)
+    __builtin_abort ();
+#endif
+  return 0;
+}
2016-03-30  Jakub Jelinek  <ja...@redhat.com>

        Backported from mainline
        2016-03-17  Jakub Jelinek  <ja...@redhat.com>

        PR c++/70272
        * decl.c (begin_destructor_body): Don't insert clobber if
        is_empty_class (current_class_type).

        * g++.dg/opt/flifetime-dse6.C: New test.
        * g++.dg/tree-ssa/ehcleanup-1.C: Adjust unreachable count.

--- gcc/cp/decl.c       (revision 234295)
+++ gcc/cp/decl.c       (revision 234296)
@@ -14354,7 +14354,9 @@ begin_destructor_body (void)
       initialize_vtbl_ptrs (current_class_ptr);
       finish_compound_stmt (compound_stmt);
 
-      if (flag_lifetime_dse)
+      if (flag_lifetime_dse
+         /* Clobbering an empty base is harmful if it overlays real data.  */
+         && !is_empty_class (current_class_type))
        {
          /* Insert a cleanup to let the back end know that the object is dead
             when we exit the destructor, either normally or via exception.  */
--- gcc/testsuite/g++.dg/opt/flifetime-dse6.C   (revision 0)
+++ gcc/testsuite/g++.dg/opt/flifetime-dse6.C   (revision 234296)
@@ -0,0 +1,11 @@
+// PR c++/70272
+// { dg-options -O2 }
+// { dg-do run }
+
+struct Empty { };
+struct A { A() : a(true) { } bool a; ~A() { if (!a) __builtin_abort(); } };
+struct B : Empty { B() : Empty() { } ~B() { } };
+struct C : A, B { C() : A(), B() { } ~C() { } };
+int main() {
+  C c;
+}
--- gcc/testsuite/g++.dg/tree-ssa/ehcleanup-1.C (revision 234295)
+++ gcc/testsuite/g++.dg/tree-ssa/ehcleanup-1.C (revision 234296)
@@ -26,5 +26,5 @@ t (void)
 // { dg-final { scan-tree-dump-times "Empty EH handler" 2 "ehcleanup1" } }
 //
 // And as a result also contained control flow.
-// { dg-final { scan-tree-dump-times "Removing unreachable" 6 "ehcleanup1" } }
+// { dg-final { scan-tree-dump-times "Removing unreachable" 4 "ehcleanup1" } }
 //
2016-03-30  Jakub Jelinek  <ja...@redhat.com>

        Backported from mainline
        2016-03-21  Jakub Jelinek  <ja...@redhat.com>

        PR target/70296
        * config/rs6000/rs6000-c.c (rs6000_macro_to_expand): If IDENT is
        function-like macro, peek following token(s) if it is followed
        by CPP_OPEN_PAREN token with optional padding in between, and
        if not, don't treat it like a macro.

        * include/cpplib.h (cpp_fun_like_macro_p): New prototype.
        * macro.c (cpp_fun_like_macro_p): New function.

        * gcc.target/powerpc/altivec-36.c: New test.

--- gcc/config/rs6000/rs6000-c.c        (revision 234370)
+++ gcc/config/rs6000/rs6000-c.c        (revision 234371)
@@ -216,7 +216,21 @@ rs6000_macro_to_expand (cpp_reader *pfil
       else if (ident && (ident != C_CPP_HASHNODE (__vector_keyword)))
        {
          enum rid rid_code = (enum rid)(ident->rid_code);
-         if (ident->type == NT_MACRO)
+         enum node_type itype = ident->type;
+         /* If there is a function-like macro, check if it is going to be
+            invoked with or without arguments.  Without following ( treat
+            it like non-macro, otherwise the following cpp_get_token eats
+            what should be preserved.  */
+         if (itype == NT_MACRO && cpp_fun_like_macro_p (ident))
+           {
+             int idx2 = idx;
+             do
+               tok = cpp_peek_token (pfile, idx2++);
+             while (tok->type == CPP_PADDING);
+             if (tok->type != CPP_OPEN_PAREN)
+               itype = NT_VOID;
+           }
+         if (itype == NT_MACRO)
            {
              do
                (void) cpp_get_token (pfile);
--- libcpp/macro.c      (revision 234370)
+++ libcpp/macro.c      (revision 234371)
@@ -3301,6 +3301,15 @@ check_trad_stringification (cpp_reader *
     }
 }
 
+/* Returns true of NODE is a function-like macro.  */
+bool
+cpp_fun_like_macro_p (cpp_hashnode *node)
+{
+  return (node->type == NT_MACRO
+         && (node->flags & (NODE_BUILTIN | NODE_MACRO_ARG)) == 0
+         && node->value.macro->fun_like);
+}
+
 /* Returns the name, arguments and expansion of a macro, in a format
    suitable to be read back in again, and therefore also for DWARF 2
    debugging info.  e.g. "PASTE(X, Y) X ## Y", or "MACNAME EXPANSION".
--- libcpp/include/cpplib.h     (revision 234370)
+++ libcpp/include/cpplib.h     (revision 234371)
@@ -813,6 +813,7 @@ extern int cpp_avoid_paste (cpp_reader *
 extern const cpp_token *cpp_get_token (cpp_reader *);
 extern const cpp_token *cpp_get_token_with_location (cpp_reader *,
                                                     source_location *);
+extern bool cpp_fun_like_macro_p (cpp_hashnode *);
 extern const unsigned char *cpp_macro_definition (cpp_reader *,
                                                  cpp_hashnode *);
 extern void _cpp_backup_tokens (cpp_reader *, unsigned int);
--- gcc/testsuite/gcc.target/powerpc/altivec-36.c       (revision 0)
+++ gcc/testsuite/gcc.target/powerpc/altivec-36.c       (revision 234371)
@@ -0,0 +1,46 @@
+/* PR target/70296 */
+/* { dg-do compile } */
+/* { dg-require-effective-target powerpc_altivec_ok } */
+/* { dg-options "-maltivec -std=gnu11" } */
+
+#define c(x) x
+#define f(x)
+#define i int
+#define k
+typedef int vector;
+typedef vector int V;
+vector int a;
+vector b;
+vector c(int) d;
+vector c(e);
+vector c;
+vector f(int) int g;
+vector f(int) h;
+vector i j;
+vector k int l;
+vector k m;
+#define int(x) x
+vector int n;
+vector int(int) o;
+vector int(r);
+#undef int
+
+void
+foo ()
+{
+  V *p;
+  p = &a;
+  p = &d;
+  p = &g;
+  p = &j;
+  p = &l;
+  p = &n;
+  p = &o;
+  int *q;
+  q = &b;
+  q = &e;
+  q = &c;
+  q = &h;
+  q = &m;
+  q = &r;
+}
2016-03-30  Jakub Jelinek  <ja...@redhat.com>

        Backported from mainline
        2016-03-22  Jakub Jelinek  <ja...@redhat.com>

        PR target/70329
        * config/i386/i386.c (ix86_expand_vecop_qihi): Don't bother computing
        d.perm[i] for i >= d.nelt.  If not full_interleave, compute d.perm[i]
        in a way that works also for AVX512BW.

        * gcc.target/i386/avx512bw-pr70329-1.c: New test.
        * gcc.target/i386/avx512bw-pr70329-2.c: New test.

--- gcc/config/i386/i386.c      (revision 234393)
+++ gcc/config/i386/i386.c      (revision 234394)
@@ -51910,16 +51910,24 @@ ix86_expand_vecop_qihi (enum rtx_code co
     {
       /* For SSE2, we used an full interleave, so the desired
         results are in the even elements.  */
-      for (i = 0; i < 64; ++i)
+      for (i = 0; i < d.nelt; ++i)
        d.perm[i] = i * 2;
     }
   else
     {
       /* For AVX, the interleave used above was not cross-lane.  So the
         extraction is evens but with the second and third quarter swapped.
-        Happily, that is even one insn shorter than even extraction.  */
-      for (i = 0; i < 64; ++i)
-       d.perm[i] = i * 2 + ((i & 24) == 8 ? 16 : (i & 24) == 16 ? -16 : 0);
+        Happily, that is even one insn shorter than even extraction.
+        For AVX512BW we have 4 lanes.  We extract evens from within a lane,
+        always first from the first and then from the second source operand,
+        the index bits above the low 4 bits remains the same.
+        Thus, for d.nelt == 32 we want permutation
+        0,2,4,..14, 32,34,36,..46, 16,18,20,..30, 48,50,52,..62
+        and for d.nelt == 64 we want permutation
+        0,2,4,..14, 64,66,68,..78, 16,18,20,..30, 80,82,84,..94,
+        32,34,36,..46, 96,98,100,..110, 48,50,52,..62, 112,114,116,..126.  */
+      for (i = 0; i < d.nelt; ++i)
+       d.perm[i] = ((i * 2) & 14) + ((i & 8) ? d.nelt : 0) + (i & ~15);
     }
 
   ok = ix86_expand_vec_perm_const_1 (&d);
--- gcc/testsuite/gcc.target/i386/avx512bw-pr70329-1.c  (revision 0)
+++ gcc/testsuite/gcc.target/i386/avx512bw-pr70329-1.c  (revision 234394)
@@ -0,0 +1,27 @@
+/* PR target/70329 */
+/* { dg-do run } */
+/* { dg-options "-O0 -mavx512bw" } */
+/* { dg-require-effective-target avx512bw } */
+
+#define AVX512BW
+#include "avx512f-helper.h"
+
+typedef unsigned char A __attribute__ ((vector_size (64)));
+typedef unsigned int B __attribute__ ((vector_size (64)));
+
+unsigned __attribute__ ((noinline, noclone))
+foo (A a, A b, B c)
+{
+  a *= b;
+  c[1] += a[8];
+  return c[1];
+}
+
+void
+TEST (void)
+{
+  A a = (A) { 1, 2, 3, 4, 5, 6, 7, 8, 9 };
+  unsigned x = foo (a, a, (B) { 1, 2 });
+  if (x != 83)
+    abort ();
+}
--- gcc/testsuite/gcc.target/i386/avx512bw-pr70329-2.c  (revision 0)
+++ gcc/testsuite/gcc.target/i386/avx512bw-pr70329-2.c  (revision 234394)
@@ -0,0 +1,33 @@
+/* PR target/70329 */
+/* { dg-do run } */
+/* { dg-options "-O2 -ftree-vectorize -mavx512bw" } */
+/* { dg-require-effective-target avx512bw } */
+
+#define AVX512BW
+#include "avx512f-helper.h"
+
+__attribute__((noinline, noclone)) void
+foo (unsigned char *src1, unsigned char *src2, unsigned char *dst)
+{
+  int i;
+
+  for (i = 0; i < 64; i++)
+    dst[i] = (unsigned char) ((int) src1[i] * (int) src2[i]);
+}
+
+void
+TEST (void)
+{
+  unsigned char a[64], b[64], c[64];
+  int i;
+
+  for (i = 0; i < 64; i++)
+    {
+      a[i] = i;
+      b[i] = (i + 1);
+    }
+  foo (a, b, c);
+  for (i = 0; i < 64; i++)
+    if (c[i] != (unsigned char) (i * (i + 1)))
+      abort ();
+}
2016-03-30  Jakub Jelinek  <ja...@redhat.com>

        Backported from mainline
        2016-03-29  Jakub Jelinek  <ja...@redhat.com>

        PR rtl-optimization/70429
        * combine.c (simplify_shift_const_1): For ASHIFTRT don't optimize
        (cst1 >> count) >> cst2 into (cst1 >> cst2) >> count if
        mode != result_mode.

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

--- gcc/combine.c       (revision 234530)
+++ gcc/combine.c       (revision 234531)
@@ -10533,6 +10533,11 @@ simplify_shift_const_1 (enum rtx_code co
                                       >> orig_count, result_mode,
                                       &complement_p))
                break;
+             /* For ((int) (cstLL >> count)) >> cst2 just give up.  Queuing
+                up outer sign extension (often left and right shift) is
+                hardly more efficient than the original.  See PR70429.  */
+             if (code == ASHIFTRT && mode != result_mode)
+               break;
 
              rtx new_rtx = simplify_const_binary_operation (code, mode,
                                                             XEXP (varop, 0),
--- gcc/testsuite/gcc.c-torture/execute/pr70429.c       (revision 0)
+++ gcc/testsuite/gcc.c-torture/execute/pr70429.c       (revision 234531)
@@ -0,0 +1,17 @@
+/* PR rtl-optimization/70429 */
+
+__attribute__((noinline, noclone)) int
+foo (int a)
+{
+  return (int) (0x14ff6e2207db5d1fLL >> a) >> 4;
+}
+
+int
+main ()
+{
+  if (sizeof (int) != 4 || sizeof (long long) != 8 || __CHAR_BIT__ != 8)
+    return 0;
+  if (foo (1) != 0x3edae8 || foo (2) != -132158092)
+    __builtin_abort ();
+  return 0;
+}

Reply via email to