From 3f6f33195bc0ede860ecbf55fe92712f3f503f50 Mon Sep 17 00:00:00 2001 From: Kugan Vivekanandarajah Date: Fri, 6 Jul 2018 22:10:20 +0000 Subject: [PATCH] gimplify.h (generic_expr_could_trap_p): Set as global function. gcc/ChangeLog: 2018-07-06 Kugan Vivekanandarajah * gimplify.h (generic_expr_could_trap_p): Set as global function. * gimplify.h (generic_expr_could_trap_p): Likwise. * tree-scalar-evolution.c (expression_expensive_p): Handle COND_EXPR. gcc/testsuite/ChangeLog: 2018-07-06 Kugan Vivekanandarajah * gcc.dg/tree-ssa/pr64183.c: Disable final value replacement to preserve the test. * gcc.target/i386/pr85073.c: Likewise. From-SVN: r262486 --- gcc/ChangeLog | 6 ++++++ gcc/gimplify.c | 2 +- gcc/gimplify.h | 1 + gcc/testsuite/ChangeLog | 6 ++++++ gcc/testsuite/gcc.dg/tree-ssa/pr64183.c | 2 +- gcc/testsuite/gcc.target/i386/pr85073.c | 2 +- gcc/tree-scalar-evolution.c | 12 ++++++++++++ 7 files changed, 28 insertions(+), 3 deletions(-) diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 7a978971066..acaea119eaf 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,9 @@ +2018-07-06 Kugan Vivekanandarajah + + * gimplify.h (generic_expr_could_trap_p): Set as global function. + * gimplify.h (generic_expr_could_trap_p): Likwise. + * tree-scalar-evolution.c (expression_expensive_p): Handle COND_EXPR. + 2018-07-06 Jakub Jelinek PR tree-optimization/86401 diff --git a/gcc/gimplify.c b/gcc/gimplify.c index 48ac92e2b16..c86ad1ad962 100644 --- a/gcc/gimplify.c +++ b/gcc/gimplify.c @@ -3878,7 +3878,7 @@ gimplify_pure_cond_expr (tree *expr_p, gimple_seq *pre_p) EXPR is GENERIC, while tree_could_trap_p can be called only on GIMPLE. */ -static bool +bool generic_expr_could_trap_p (tree expr) { unsigned i, n; diff --git a/gcc/gimplify.h b/gcc/gimplify.h index dd0e4c01752..62ca869083a 100644 --- a/gcc/gimplify.h +++ b/gcc/gimplify.h @@ -83,6 +83,7 @@ extern enum gimplify_status gimplify_arg (tree *, gimple_seq *, location_t, extern void gimplify_function_tree (tree); extern enum gimplify_status gimplify_va_arg_expr (tree *, gimple_seq *, gimple_seq *); +extern bool generic_expr_could_trap_p (tree expr); gimple *gimplify_assign (tree, tree, gimple_seq *); #endif /* GCC_GIMPLIFY_H */ diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 4242c233961..541fafb9960 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2018-07-06 Kugan Vivekanandarajah + + * gcc.dg/tree-ssa/pr64183.c: Disable final value replacement + to preserve the test. + * gcc.target/i386/pr85073.c: Likewise. + 2018-07-06 Jakub Jelinek PR tree-optimization/86401 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr64183.c b/gcc/testsuite/gcc.dg/tree-ssa/pr64183.c index 7a854fc7f3f..50d0c5a1c5a 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr64183.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr64183.c @@ -1,5 +1,5 @@ /* { dg-do compile } */ -/* { dg-options "-O3 -fno-tree-vectorize -fdump-tree-cunroll-details" } */ +/* { dg-options "-O3 -fno-tree-vectorize -fdisable-tree-sccp -fdump-tree-cunroll-details" } */ int bits; unsigned int size; diff --git a/gcc/testsuite/gcc.target/i386/pr85073.c b/gcc/testsuite/gcc.target/i386/pr85073.c index 187102d2f86..71a5d2353d8 100644 --- a/gcc/testsuite/gcc.target/i386/pr85073.c +++ b/gcc/testsuite/gcc.target/i386/pr85073.c @@ -1,6 +1,6 @@ /* PR target/85073 */ /* { dg-do compile } */ -/* { dg-options "-O2 -mbmi" } */ +/* { dg-options "-O2 -mbmi -fdisable-tree-sccp" } */ int foo (unsigned x) diff --git a/gcc/tree-scalar-evolution.c b/gcc/tree-scalar-evolution.c index 4b0ec02b4de..8e2900547e0 100644 --- a/gcc/tree-scalar-evolution.c +++ b/gcc/tree-scalar-evolution.c @@ -3508,6 +3508,18 @@ expression_expensive_p (tree expr) return false; } + if (code == COND_EXPR) + return (expression_expensive_p (TREE_OPERAND (expr, 0)) + || (EXPR_P (TREE_OPERAND (expr, 1)) + && EXPR_P (TREE_OPERAND (expr, 2))) + /* If either branch has side effects or could trap. */ + || TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 1)) + || generic_expr_could_trap_p (TREE_OPERAND (expr, 1)) + || TREE_SIDE_EFFECTS (TREE_OPERAND (expr, 0)) + || generic_expr_could_trap_p (TREE_OPERAND (expr, 0)) + || expression_expensive_p (TREE_OPERAND (expr, 1)) + || expression_expensive_p (TREE_OPERAND (expr, 2))); + switch (TREE_CODE_CLASS (code)) { case tcc_binary: -- 2.30.2