+2019-03-26 Richard Biener <rguenther@suse.de>
+
+ Backport from mainline
+ 2019-01-08 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/86554
+ * tree-ssa-sccvn.c (visit_nary_op): When value-numbering to
+ expressions with different overflow behavior make sure there's an
+ available expression on the path.
+
+ 2018-11-20 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/88105
+ * tree-ssa-dom.c (pass_dominator::execute): Do not walk
+ backedges.
+
+ 2018-03-08 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/84552
+ * tree-scalar-evolution.c: Include tree-into-ssa.h.
+ (follow_copies_to_constant): Do not follow SSA names registered
+ for update.
+
2019-03-21 Bill Schmidt <wschmidt@linux.ibm.com>
* config/rs6000/rs6000.c (rs6000_analyze_swaps): Rebuild
+2019-03-26 Richard Biener <rguenther@suse.de>
+
+ Backport from mainline
+ 2019-01-08 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/86554
+ * gcc.dg/torture/pr86554-1.c: New testcase.
+ * gcc.dg/torture/pr86554-2.c: Likewise.
+
+ 2018-11-20 Richard Biener <rguenther@suse.de>
+
+ PR tree-optimization/88105
+ * gcc.dg/gomp/pr88105.c: New testcase.
+
+ 2018-03-08 Richard Biener <rguenther@suse.de>
+
+ PR middle-end/84552
+ * gcc.dg/graphite/pr84552.c: New testcase.
+
2019-03-25 Janus Weil <janus@gcc.gnu.org>
PR fortran/71861
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-fopenmp -O -fexceptions -fnon-call-exceptions -fno-tree-fre" } */
+
+int
+s0 (void)
+{
+ int g6, oh = 0;
+ int *a6 = &g6;
+
+ (void) a6;
+
+#pragma omp parallel for
+ for (g6 = 0; g6 < 1; ++g6)
+ {
+ int zk;
+
+ for (zk = 0; zk < 1; ++zk)
+ {
+ oh += zk / (zk + 1);
+
+ for (;;)
+ {
+ }
+ }
+
+ a6 = &zk;
+ }
+
+ return oh;
+}
--- /dev/null
+/* { dg-do compile } */
+/* { dg-options "-O2 -floop-nest-optimize -fno-tree-copy-prop -fno-tree-fre -fno-tree-loop-ivcanon" } */
+
+int cx;
+
+int
+e6 (int pj, int xe)
+{
+ for (cx = 0; cx < 2; ++cx)
+ while (xe < 1)
+ {
+ for (cx = 0; cx < 2; ++cx)
+ pj *= 2;
+
+ if (cx != 0)
+ goto o3;
+
+ ++xe;
+ }
+
+o3:
+ return pj;
+}
--- /dev/null
+/* { dg-do run } */
+
+struct foo
+{
+ unsigned x;
+};
+typedef struct foo foo;
+
+static inline int zot(foo *f)
+{
+ int ret;
+
+ if (f->x > 0x7FFFFFFF)
+ ret = (int)(f->x - 0x7FFFFFFF);
+ else
+ ret = (int)f->x - 0x7FFFFFFF;
+ return ret;
+}
+
+void __attribute__((noinline,noclone)) bar(foo *f)
+{
+ int ret = zot(f);
+ volatile int x = ret;
+ if (ret < 1)
+ __builtin_abort ();
+}
+
+int main()
+{
+ foo f;
+ f.x = 0x800003f8;
+
+ bar(&f);
+ return 0;
+}
--- /dev/null
+/* { dg-do run } */
+/* { dg-require-effective-target int32plus } */
+
+struct s { __INT64_TYPE__ e; };
+
+static void f (struct s *ps)
+{
+ volatile __INT64_TYPE__ m = 9223372036854775807;
+ const char *str = "11E";
+ int r;
+ __INT64_TYPE__ sum;
+
+ ps->e = 0;
+
+ for (;;)
+ {
+ if (*str++ != '1')
+ break;
+ ps->e ++;
+ }
+
+ r = 1;
+ sum = m;
+
+ if (sum >= 0 && ps->e >= 0)
+ {
+ __UINT64_TYPE__ uc;
+ uc = (__UINT64_TYPE__) sum + (__UINT64_TYPE__) ps->e;
+ if (uc > 9223372036854775807)
+ r = 2;
+ else
+ sum = 17;
+ }
+ else
+ sum = sum + ps->e;
+
+ if (sum != 9223372036854775807)
+ __builtin_abort ();
+ if (r != 2)
+ __builtin_abort ();
+ ps->e = sum;
+}
+
+int main (void)
+{
+ struct s s;
+ f (&s);
+ return 0;
+}
#include "params.h"
#include "tree-ssa-propagate.h"
#include "gimple-fold.h"
+#include "tree-into-ssa.h"
static tree analyze_scalar_evolution_1 (struct loop *, tree, tree);
static tree analyze_scalar_evolution_for_address_of (struct loop *loop,
follow_copies_to_constant (tree var)
{
tree res = var;
- while (TREE_CODE (res) == SSA_NAME)
+ while (TREE_CODE (res) == SSA_NAME
+ /* We face not updated SSA form in multiple places and this walk
+ may end up in sibling loops so we have to guard it. */
+ && !name_registered_for_update_p (res))
{
gimple *def = SSA_NAME_DEF_STMT (res);
if (gphi *phi = dyn_cast <gphi *> (def))
if (bb == NULL)
continue;
while (single_succ_p (bb)
- && (single_succ_edge (bb)->flags & EDGE_EH) == 0)
+ && (single_succ_edge (bb)->flags
+ & (EDGE_EH|EDGE_DFS_BACK)) == 0)
bb = single_succ (bb);
if (bb == EXIT_BLOCK_PTR_FOR_FN (fun))
continue;
ops[0] = vn_nary_op_lookup_pieces
(2, gimple_assign_rhs_code (def), type, ops, NULL);
/* We have wider operation available. */
- if (ops[0])
+ if (ops[0]
+ /* If the leader is a wrapping operation we can
+ insert it for code hoisting w/o introducing
+ undefined overflow. If it is not it has to
+ be available. See PR86554. */
+ && (TYPE_OVERFLOW_WRAPS (TREE_TYPE (ops[0]))
+ || TREE_CODE (ops[0]) != SSA_NAME
+ || SSA_NAME_IS_DEFAULT_DEF (ops[0])
+ || dominated_by_p_w_unex
+ (gimple_bb (stmt),
+ gimple_bb (SSA_NAME_DEF_STMT (ops[0])))))
{
unsigned lhs_prec = TYPE_PRECISION (type);
unsigned rhs_prec = TYPE_PRECISION (TREE_TYPE (rhs1));