gimplify.h (generic_expr_could_trap_p): Set as global function.
authorKugan Vivekanandarajah <kuganv@linaro.org>
Fri, 6 Jul 2018 22:10:20 +0000 (22:10 +0000)
committerKugan Vivekanandarajah <kugan@gcc.gnu.org>
Fri, 6 Jul 2018 22:10:20 +0000 (22:10 +0000)
gcc/ChangeLog:

2018-07-06  Kugan Vivekanandarajah  <kuganv@linaro.org>

* 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  <kuganv@linaro.org>

* 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
gcc/gimplify.c
gcc/gimplify.h
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/tree-ssa/pr64183.c
gcc/testsuite/gcc.target/i386/pr85073.c
gcc/tree-scalar-evolution.c

index 7a9789710660bbbc03908c8cb412254d7d454d4b..acaea119eaf40dbf90d2b7173926056c7a74add4 100644 (file)
@@ -1,3 +1,9 @@
+2018-07-06  Kugan Vivekanandarajah  <kuganv@linaro.org>
+
+       * 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  <jakub@redhat.com>
 
        PR tree-optimization/86401
index 48ac92e2b16dabda6d2dd93a870111b021369aa5..c86ad1ad96279ab7e99839090ac3fea341026071 100644 (file)
@@ -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;
index dd0e4c01752bc919cd6b8d3eaf35e8c874409d72..62ca869083a447597a23d07e69a37ac7eba2f548 100644 (file)
@@ -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 */
index 4242c23396161da909c4f1ff95609381e356b7f0..541fafb99601da49deaea5b74410a01b7f3a0903 100644 (file)
@@ -1,3 +1,9 @@
+2018-07-06  Kugan Vivekanandarajah  <kuganv@linaro.org>
+
+       * 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  <jakub@redhat.com>
 
        PR tree-optimization/86401
index 7a854fc7f3ffc7519b55f19a624ca7d85679ba7f..50d0c5a1c5a98b766450482c202c49a06369907b 100644 (file)
@@ -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;
index 187102d2f86f11202572decb09c0f338dc916a44..71a5d2353d82ef1e3baa242673def95ab42fd3e6 100644 (file)
@@ -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)
index 4b0ec02b4de5e397ae57c442896e65d156fd38ab..8e2900547e093598a64b97c00278341194ac4320 100644 (file)
@@ -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: