]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Backport PRs 79666, 79732, 79756, 79894
authorRichard Biener <rguenther@suse.de>
Wed, 10 May 2017 10:01:23 +0000 (10:01 +0000)
committerRichard Biener <rguenth@gcc.gnu.org>
Wed, 10 May 2017 10:01:23 +0000 (10:01 +0000)
2017-05-10  Richard Biener  <rguenther@suse.de>

Backport from mainline
2017-03-06  Richard Biener  <rguenther@suse.de>

PR fortran/79894
* trans.c (gfc_add_modify_loc): Weaken assert.

2017-03-02  Richard Biener  <rguenther@suse.de>

PR c/79756
* c-common.c (c_common_mark_addressable_vec): Look through
C_MAYBE_CONST_EXPR.

* gcc.dg/vector-1.c: New testcase.

2017-02-28  Richard Biener  <rguenther@suse.de>

PR tree-optimization/79732
* tree-inline.c (expand_call_inline): Handle anonymous
SSA lhs properly when inlining a function without return
value.

* gcc.dg/torture/pr79732.c: New testcase.

2017-02-22  Richard Biener  <rguenther@suse.de>

PR tree-optimization/79666
* tree-vrp.c (extract_range_from_binary_expr_1): Make sure
to not symbolically negate if that may introduce undefined
overflow.

* gcc.dg/torture/pr79666.c: New testcase.

From-SVN: r247829

gcc/ChangeLog
gcc/c-family/ChangeLog
gcc/c-family/c-common.c
gcc/fortran/ChangeLog
gcc/fortran/trans.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/torture/pr79666.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/torture/pr79732.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vector-1.c [new file with mode: 0644]
gcc/tree-inline.c
gcc/tree-vrp.c

index 9d509b935b1e6f7b40ed597c34fe3fb484bd5db7..b26b3552369183244264796c5f4a4e90f258cba8 100644 (file)
@@ -1,3 +1,20 @@
+2017-05-10  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2017-02-28  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/79732
+       * tree-inline.c (expand_call_inline): Handle anonymous
+       SSA lhs properly when inlining a function without return
+       value.
+
+       2017-02-22  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/79666
+       * tree-vrp.c (extract_range_from_binary_expr_1): Make sure
+       to not symbolically negate if that may introduce undefined
+       overflow.
+
 2017-05-10  Richard Biener  <rguenther@suse.de>
 
        Backport from mainline
index 5251b684d06486137559632b94a038ed1db1807d..bd8449932be813ae23304f02f5a91f9fa5b26bfd 100644 (file)
@@ -1,3 +1,10 @@
+2017-05-10  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       PR c/79756
+       * c-common.c (c_common_mark_addressable_vec): Look through
+       C_MAYBE_CONST_EXPR.
+
 2017-03-22  Martin Liska  <mliska@suse.cz>
 
        Backport from mainline
index 2914dae4955fa381086452348b109affa644b831..aa81d1944b89cce2f40aaa5793db416b0c7131f1 100644 (file)
@@ -10473,6 +10473,8 @@ complete_array_type (tree *ptype, tree initial_value, bool do_default)
 void 
 c_common_mark_addressable_vec (tree t)
 {   
+  if (TREE_CODE (t) == C_MAYBE_CONST_EXPR)
+    t = C_MAYBE_CONST_EXPR_EXPR (t);
   while (handled_component_p (t))
     t = TREE_OPERAND (t, 0);
   if (!VAR_P (t)
index b3f4403ba9c2e2697ea644ea543cf378f46407dd..f4424d49aec62611dcbe710c7c29ef2072a617f9 100644 (file)
@@ -1,3 +1,11 @@
+2017-05-10  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2017-03-06  Richard Biener  <rguenther@suse.de>
+
+       PR fortran/79894
+       * trans.c (gfc_add_modify_loc): Weaken assert.
+
 2017-05-01  Janus Weil  <janus@gcc.gnu.org>
 
        Backport from trunk
index d52e0623e657abc597be29ba86287d88cb6b58d6..8bbbeec64f4a4f69b39e5dec691b750fefb021b3 100644 (file)
@@ -163,11 +163,11 @@ gfc_add_modify_loc (location_t loc, stmtblock_t * pblock, tree lhs, tree rhs)
   tree t1, t2;
   t1 = TREE_TYPE (rhs);
   t2 = TREE_TYPE (lhs);
-  /* Make sure that the types of the rhs and the lhs are the same
+  /* Make sure that the types of the rhs and the lhs are compatible
      for scalar assignments.  We should probably have something
      similar for aggregates, but right now removing that check just
      breaks everything.  */
-  gcc_assert (t1 == t2
+  gcc_assert (TYPE_MAIN_VARIANT (t1) == TYPE_MAIN_VARIANT (t2)
              || AGGREGATE_TYPE_P (TREE_TYPE (lhs)));
 #endif
 
index d2b6972e15779862d98314425284094a9dfe9f94..cb54cdcd45fffb1a58b4c6b46559c4747aa5a9d6 100644 (file)
@@ -1,3 +1,21 @@
+2017-05-10  Richard Biener  <rguenther@suse.de>
+
+       Backport from mainline
+       2017-03-02  Richard Biener  <rguenther@suse.de>
+
+       PR c/79756
+       * gcc.dg/vector-1.c: New testcase.
+
+       2017-02-28  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/79732
+       * gcc.dg/torture/pr79732.c: New testcase.
+
+       2017-02-22  Richard Biener  <rguenther@suse.de>
+
+       PR tree-optimization/79666
+       * gcc.dg/torture/pr79666.c: New testcase.
+
 2017-05-10  Richard Biener  <rguenther@suse.de>
 
        Backport from mainline
diff --git a/gcc/testsuite/gcc.dg/torture/pr79666.c b/gcc/testsuite/gcc.dg/torture/pr79666.c
new file mode 100644 (file)
index 0000000..3d83229
--- /dev/null
@@ -0,0 +1,30 @@
+/* { dg-do run } */
+
+struct
+{
+  unsigned a:6;
+} b;
+
+int c, e, g = 7;
+signed char d, f = 6, h = -10;
+
+void fn1 ()
+{
+  for (; c < 9; c++)
+    {
+      if (f)
+       g = ~(~0 / (g ^ e));
+      b.a = ~0;
+      d = ~((h ^ b.a) & 132 & (~(f && g) | (d && 1)));
+      e = ~0;
+      if (d < 127 || f < 1)
+       continue;
+      g = 0;
+    }
+}
+
+int main ()
+{
+  fn1 ();
+  return 0; 
+}
diff --git a/gcc/testsuite/gcc.dg/torture/pr79732.c b/gcc/testsuite/gcc.dg/torture/pr79732.c
new file mode 100644 (file)
index 0000000..7231ba4
--- /dev/null
@@ -0,0 +1,5 @@
+/* { dg-do link } */
+
+int bar () __attribute__ ((alias ("foo")));
+void foo () { }
+int main () { return bar(); }
diff --git a/gcc/testsuite/gcc.dg/vector-1.c b/gcc/testsuite/gcc.dg/vector-1.c
new file mode 100644 (file)
index 0000000..a5eaa2a
--- /dev/null
@@ -0,0 +1,8 @@
+/* { dg-do compile } */
+/* { dg-options "-std=gnu90" } */
+
+typedef int V __attribute__ ((vector_size(4)));
+void fn1 ()
+{
+  (V){(1,0)}[0] = 0;
+}
index 71d9d239535a05a5c4922fe54cae833fd75e555f..e8c066015f5fe44b13d9a83e1e9514d72402cac8 100644 (file)
@@ -4757,7 +4757,7 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id)
        {
          tree name = gimple_call_lhs (stmt);
          tree var = SSA_NAME_VAR (name);
-         tree def = ssa_default_def (cfun, var);
+         tree def = var ? ssa_default_def (cfun, var) : NULL;
 
          if (def)
            {
@@ -4768,6 +4768,11 @@ expand_call_inline (basic_block bb, gimple stmt, copy_body_data *id)
            }
          else
            {
+             if (!var)
+               {
+                 var = create_tmp_reg_fn (cfun, TREE_TYPE (name), NULL);
+                 SET_SSA_NAME_VAR_OR_IDENTIFIER (name, var);
+               }
              /* Otherwise make this variable undefined.  */
              gsi_remove (&stmt_gsi, true);
              set_ssa_default_def (cfun, var, name);
index b25783830c8372a27f75602e591876d6be9b290f..5f14ee9028597dbe85c5709b2ded794585b02934 100644 (file)
@@ -2797,8 +2797,17 @@ extract_range_from_binary_expr_1 (value_range_t *vr,
            min = build_symbolic_expr (expr_type, sym_min_op0,
                                       neg_min_op0, min);
          else if (sym_min_op1)
-           min = build_symbolic_expr (expr_type, sym_min_op1,
-                                      neg_min_op1 ^ minus_p, min);
+           {
+             /* We may not negate if that might introduce
+                undefined overflow.  */
+             if (! minus_p
+                 || neg_min_op1
+                 || TYPE_OVERFLOW_WRAPS (expr_type))
+               min = build_symbolic_expr (expr_type, sym_min_op1,
+                                          neg_min_op1 ^ minus_p, min);
+             else
+               min = NULL_TREE;
+           }
 
          /* Likewise for the upper bound.  */
          if (sym_max_op0 == sym_max_op1)
@@ -2807,8 +2816,17 @@ extract_range_from_binary_expr_1 (value_range_t *vr,
            max = build_symbolic_expr (expr_type, sym_max_op0,
                                       neg_max_op0, max);
          else if (sym_max_op1)
-           max = build_symbolic_expr (expr_type, sym_max_op1,
-                                      neg_max_op1 ^ minus_p, max);
+           {
+             /* We may not negate if that might introduce
+                undefined overflow.  */
+             if (! minus_p
+                 || neg_max_op1
+                 || TYPE_OVERFLOW_WRAPS (expr_type))
+               max = build_symbolic_expr (expr_type, sym_max_op1,
+                                          neg_max_op1 ^ minus_p, max);
+             else
+               max = NULL_TREE;
+           }
        }
       else
        {