From 4bb16e7d01674461a47e6b6488b04fb1907234ea Mon Sep 17 00:00:00 2001
From: Kugan Vivekanandarajah <kugan.vivekanandarajah@linaro.org>
Date: Mon, 3 Oct 2016 06:12:05 +1100
Subject: [PATCH 1/5] Fold stmts using vrp_fold in evrp
---
gcc/testsuite/gcc.dg/pr68217.c | 4 ++--
gcc/testsuite/gcc.dg/predict-1.c | 2 +-
gcc/testsuite/gcc.dg/predict-9.c | 2 +-
gcc/testsuite/gcc.dg/tree-ssa/pr20318.c | 4 ++--
gcc/testsuite/gcc.dg/tree-ssa/pr21001.c | 2 +-
gcc/testsuite/gcc.dg/tree-ssa/pr21090.c | 4 ++--
gcc/testsuite/gcc.dg/tree-ssa/pr21294.c | 4 ++--
gcc/testsuite/gcc.dg/tree-ssa/pr21559.c | 2 +-
gcc/testsuite/gcc.dg/tree-ssa/pr21563.c | 2 +-
gcc/testsuite/gcc.dg/tree-ssa/pr23744.c | 4 ++--
gcc/testsuite/gcc.dg/tree-ssa/pr25382.c | 4 ++--
gcc/testsuite/gcc.dg/tree-ssa/pr61839_1.c | 6 +++---
gcc/testsuite/gcc.dg/tree-ssa/pr68431.c | 2 +-
gcc/testsuite/gcc.dg/tree-ssa/vrp03.c | 4 ++--
gcc/testsuite/gcc.dg/tree-ssa/vrp07.c | 2 +-
gcc/testsuite/gcc.dg/tree-ssa/vrp09.c | 4 ++--
gcc/testsuite/gcc.dg/tree-ssa/vrp17.c | 4 ++--
gcc/testsuite/gcc.dg/tree-ssa/vrp18.c | 4 ++--
gcc/testsuite/gcc.dg/tree-ssa/vrp19.c | 6 +++---
gcc/testsuite/gcc.dg/tree-ssa/vrp20.c | 6 +++---
gcc/testsuite/gcc.dg/tree-ssa/vrp23.c | 2 +-
gcc/testsuite/gcc.dg/tree-ssa/vrp24.c | 2 +-
gcc/testsuite/gcc.dg/tree-ssa/vrp58.c | 2 +-
gcc/testsuite/gcc.dg/tree-ssa/vrp92.c | 2 +-
gcc/testsuite/gcc.dg/tree-ssa/vrp98.c | 2 +-
gcc/testsuite/gcc.dg/vrp-min-max-1.c | 2 +-
gcc/tree-vrp.c | 27 ++++++++++++++++++++-------
27 files changed, 62 insertions(+), 49 deletions(-)
@@ -1,6 +1,6 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-vrp1" } */
+/* { dg-options "-O2 -fdump-tree-evrp" } */
int foo (void)
{
@@ -11,4 +11,4 @@ int foo (void)
return 0;
}
-/* { dg-final { scan-tree-dump "\\\[-INF, 0\\\]" "vrp1" } } */
+/* { dg-final { scan-tree-dump "\\\[-INF, 0\\\]" "evrp" } } */
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-profile_estimate" } */
+/* { dg-options "-O2 -fno-tree-vrp -fdump-tree-profile_estimate" } */
extern int global;
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-profile_estimate" } */
+/* { dg-options "-O2 -fno-tree-vrp -fdump-tree-profile_estimate" } */
extern int global;
extern int global2;
@@ -1,5 +1,5 @@
/* { dg-do compile { target { ! keeps_null_pointer_checks } } } */
-/* { dg-options "-O2 -fdump-tree-original -fdump-tree-vrp1 -fdelete-null-pointer-checks" } */
+/* { dg-options "-O2 -fdump-tree-original -fdump-tree-evrp -fdelete-null-pointer-checks" } */
extern int* f(int) __attribute__((returns_nonnull));
extern void eliminate ();
@@ -14,4 +14,4 @@ void h () {
}
/* { dg-final { scan-tree-dump-times "== 0" 1 "original" } } */
-/* { dg-final { scan-tree-dump-times "Folding predicate\[^\\n\]*to 0" 1 "vrp1" } } */
+/* { dg-final { scan-tree-dump-times "Folding predicate\[^\\n\]*to 0" 1 "evrp" } } */
@@ -5,7 +5,7 @@
range information out of the conditional. */
/* { dg-do compile } */
-/* { dg-options "-O2 -fno-tree-dominator-opts -fno-tree-fre -fdump-tree-vrp1-details" } */
+/* { dg-options "-O2 -fno-tree-dominator-opts -fno-tree-fre -fdisable-tree-evrp -fdump-tree-vrp1-details" } */
int
foo (int a)
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-vrp1 -fdelete-null-pointer-checks" } */
+/* { dg-options "-O2 -fdump-tree-evrp -fdelete-null-pointer-checks" } */
int g, h;
@@ -19,4 +19,4 @@ foo (int a)
return 0;
}
-/* { dg-final { scan-tree-dump-times "Folding predicate.*to 1" 1 "vrp1" { target { ! keeps_null_pointer_checks } } } } */
+/* { dg-final { scan-tree-dump-times "Folding predicate.*to 1" 1 "evrp" { target { ! keeps_null_pointer_checks } } } } */
@@ -4,7 +4,7 @@
allows us to eliminate the second "if" statement. */
/* { dg-do compile } */
-/* { dg-options "-O2 -fno-tree-dominator-opts -fdump-tree-vrp1-details" } */
+/* { dg-options "-O2 -fno-tree-dominator-opts -fdump-tree-evrp" } */
struct f {
int i;
@@ -19,4 +19,4 @@ foo (struct f *p)
return 0;
}
-/* { dg-final { scan-tree-dump-times "Folding predicate" 1 "vrp1"} } */
+/* { dg-final { scan-tree-dump-times "if" 1 "evrp"} } */
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-vrp1-details" } */
+/* { dg-options "-O2 -fdisable-tree-evrp -fdump-tree-vrp1-details" } */
static int blocksize = 4096;
@@ -2,7 +2,7 @@
Make sure VRP folds the second "if" statement. */
/* { dg-do compile } */
-/* { dg-options "-O2 -fno-tree-dominator-opts -fdump-tree-vrp1-details" } */
+/* { dg-options "-O2 -fno-tree-dominator-opts -fdisable-tree-evrp -fdump-tree-vrp1-details" } */
int
foo (int a)
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fno-tree-ccp -fdump-tree-vrp1" } */
+/* { dg-options "-O2 -fno-tree-ccp -fdump-tree-evrp" } */
void h (void);
@@ -17,4 +17,4 @@ int g (int i, int j)
return 1;
}
-/* { dg-final { scan-tree-dump-times "Folding predicate.*to 1" 1 "vrp1" } } */
+/* { dg-final { scan-tree-dump-times "Folding predicate.*to 1" 1 "evrp" } } */
@@ -3,7 +3,7 @@
Check that VRP now gets ranges from BIT_AND_EXPRs. */
/* { dg-do compile } */
-/* { dg-options "-O2 -fno-tree-ccp -fdump-tree-vrp1" } */
+/* { dg-options "-O2 -fno-tree-ccp -fdump-tree-evrp" } */
int
foo (int a)
@@ -15,4 +15,4 @@ foo (int a)
return 1;
}
-/* { dg-final { scan-tree-dump-times "Folding predicate b_.* > 300 to 0" 1 "vrp1" } } */
+/* { dg-final { scan-tree-dump-times "Folding predicate b_.* > 300 to 0" 1 "evrp" } } */
@@ -1,6 +1,6 @@
/* PR tree-optimization/61839. */
/* { dg-do run } */
-/* { dg-options "-O2 -fdump-tree-vrp1 -fdump-tree-optimized" } */
+/* { dg-options "-O2 -fdump-tree-evrp -fdump-tree-optimized" } */
/* { dg-require-effective-target int32plus } */
__attribute__ ((noinline))
@@ -38,7 +38,7 @@ int main ()
}
/* Scan for c = 972195717) >> [0, 1] in function foo. */
-/* { dg-final { scan-tree-dump-times "486097858 : 972195717" 1 "vrp1" } } */
+/* { dg-final { scan-tree-dump-times "486097858 : 972195717" 1 "evrp" } } */
/* Scan for c = 972195717) >> [2, 3] in function bar. */
-/* { dg-final { scan-tree-dump-times "243048929 : 121524464" 2 "vrp1" } } */
+/* { dg-final { scan-tree-dump-times "243048929 : 121524464" 1 "evrp" } } */
/* { dg-final { scan-tree-dump-times "486097858" 0 "optimized" } } */
@@ -1,5 +1,5 @@
/* PR tree-optimization/68431 */
-/* { dg-options "-O2 -fdump-tree-vrp1-details" } */
+/* { dg-options "-O2 -fdisable-tree-evrp -fdump-tree-vrp1-details" } */
unsigned int x = 1;
int
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-vrp1" } */
+/* { dg-options "-O2 -fdump-tree-evrp -fdump-tree-vrp1" } */
struct A
{
@@ -32,4 +32,4 @@ foo (struct A *p, struct A *q)
}
/* { dg-final { scan-tree-dump-times "Folding predicate q_.*to 1" 1 "vrp1" } } */
-/* { dg-final { scan-tree-dump-times "Folding predicate r_.*to 1" 1 "vrp1" } } */
+/* { dg-final { scan-tree-dump-times "Folding predicate r_.*to 1" 1 "evrp" } } */
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fno-tree-fre -fdump-tree-vrp1-details -fdelete-null-pointer-checks" } */
+/* { dg-options "-O2 -fdisable-tree-evrp -fno-tree-fre -fdump-tree-vrp1-details -fdelete-null-pointer-checks" } */
int
foo (int i, int *p)
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fno-tree-fre -fdump-tree-vrp1 -std=gnu89" } */
+/* { dg-options "-O2 -fno-tree-fre -fdump-tree-evrp -std=gnu89" } */
foo (int *p)
{
@@ -27,4 +27,4 @@ L78:
}
}
-/* { dg-final { scan-tree-dump-times "Folding predicate p_.. != 0B to 1" 2 "vrp1" } } */
+/* { dg-final { scan-tree-dump-times "Folding predicate p_..... != 0B to 1" 2 "evrp" } } */
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-vrp1" } */
+/* { dg-options "-O2 -fdump-tree-evrp" } */
extern void abort (void) __attribute__ ((__noreturn__));
union tree_node;
@@ -27,5 +27,5 @@ gimplify_for_stmt (tree stmt)
abort ();
}
-/* { dg-final { scan-tree-dump-times "Simplified relational" 1 "vrp1" } } */
+/* { dg-final { scan-tree-dump-times "Simplified relational" 1 "evrp" } } */
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-vrp1" } */
+/* { dg-options "-O2 -fdump-tree-evrp" } */
static int blocksize = 4096;
@@ -30,4 +30,4 @@ void foo (void)
eof_reached = 1;
}
-/* { dg-final { scan-tree-dump-times "Simplified relational" 1 "vrp1" } } */
+/* { dg-final { scan-tree-dump-times "Simplified relational" 1 "evrp" } } */
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-fwrapv -O1 -ftree-vrp -fdump-tree-vrp1" } */
+/* { dg-options "-fwrapv -O1 -ftree-vrp -fdump-tree-evrp" } */
#include <limits.h>
extern void abort ();
@@ -22,5 +22,5 @@ int g (int b) {
}
return 1;
}
-/* { dg-final { scan-tree-dump "Folding predicate a_. < 0 to 0" "vrp1" } } */
-/* { dg-final { scan-tree-dump "Folding predicate b_. >= 0 to 1" "vrp1" } } */
+/* { dg-final { scan-tree-dump "Folding predicate a_. < 0 to 0" "evrp" } } */
+/* { dg-final { scan-tree-dump "Folding predicate b_. >= 0 to 1" "evrp" } } */
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-fwrapv -O1 -fno-tree-fre -ftree-vrp -fdump-tree-vrp1" } */
+/* { dg-options "-fwrapv -O1 -fno-tree-fre -ftree-vrp -fdump-tree-evrp" } */
extern void abort ();
extern void exit (int);
@@ -23,5 +23,5 @@ int g (int b) {
return 1;
}
-/* { dg-final { scan-tree-dump "Folding predicate a_. == 0 to 0" "vrp1" } } */
-/* { dg-final { scan-tree-dump "Folding predicate b_. != 0 to 1" "vrp1" } } */
+/* { dg-final { scan-tree-dump "Folding predicate a_.... == 0 to 0" "evrp" } } */
+/* { dg-final { scan-tree-dump "Folding predicate b_.... != 0 to 1" "evrp" } } */
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fno-tree-forwprop -fdump-tree-vrp1-details" } */
+/* { dg-options "-O2 -fdisable-tree-evrp -fno-tree-forwprop -fdump-tree-vrp1-details" } */
void aa (void);
void aos (void);
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fno-tree-forwprop -fdump-tree-vrp1-details" } */
+/* { dg-options "-O2 -fdisable-tree-evrp -fno-tree-forwprop -fdump-tree-vrp1-details" } */
struct rtx_def;
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-vrp1-details" } */
+/* { dg-options "-O2 -fdisable-tree-evrp -fdump-tree-vrp1-details" } */
long long
foo (long long a, signed char b, signed char c)
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-vrp1-details -fdisable-tree-ethread" } */
+/* { dg-options "-O2 -fdisable-tree-evrp -fdump-tree-vrp1-details -fdisable-tree-ethread" } */
void bar (void);
int foo (int i, int j)
@@ -1,6 +1,6 @@
/* { dg-do compile } */
/* { dg-require-effective-target int128 } */
-/* { dg-options "-Os -fdump-tree-vrp1-details" } */
+/* { dg-options "-Os -fdump-tree-vrp1-details -fdisable-tree-evrp" } */
#include <stdint.h>
#include <limits.h>
@@ -1,5 +1,5 @@
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-vrp1 -fdump-tree-mergephi2" } */
+/* { dg-options "-O2 -fdisable-tree-evrp -fdump-tree-vrp1 -fdump-tree-mergephi2" } */
int bar (void);
@@ -10666,7 +10666,8 @@ evrp_dom_walker::before_dom_children (basic_block bb)
&& gimple_code (stmt) == GIMPLE_COND
&& (op0 = gimple_cond_lhs (stmt))
&& TREE_CODE (op0) == SSA_NAME
- && INTEGRAL_TYPE_P (TREE_TYPE (gimple_cond_lhs (stmt))))
+ && (INTEGRAL_TYPE_P (TREE_TYPE (gimple_cond_lhs (stmt)))
+ || POINTER_TYPE_P (TREE_TYPE (gimple_cond_lhs (stmt)))))
{
/* Entering a new scope. Try to see if we can find a VR
here. */
@@ -10749,12 +10750,23 @@ evrp_dom_walker::before_dom_children (basic_block bb)
set_defs_to_varying (stmt);
/* Try folding stmts with the VR discovered. */
- bool did_replace
- = replace_uses_in (stmt,
- op_with_constant_singleton_value_range);
- if (fold_stmt (&gsi, follow_single_use_edges)
- || did_replace)
- update_stmt (gsi_stmt (gsi));
+ bool did_replace = false;
+ if (vrp_fold_stmt (&gsi))
+ {
+ did_replace = true;
+ stmt = gsi_stmt (gsi);
+ update_stmt (stmt);
+ }
+
+ did_replace
+ |= replace_uses_in (stmt,
+ op_with_constant_singleton_value_range);
+
+ if (did_replace)
+ {
+ fold_stmt (&gsi, follow_single_use_edges);
+ stmt = gsi_stmt (gsi);
+ }
if (did_replace)
{
@@ -10776,6 +10788,7 @@ evrp_dom_walker::before_dom_children (basic_block bb)
if (TREE_CODE (rhs) == ADDR_EXPR)
recompute_tree_invariant_for_addr_expr (rhs);
}
+ update_stmt (gsi_stmt (gsi));
}
def_operand_p def_p = SINGLE_SSA_DEF_OPERAND (stmt, SSA_OP_DEF);
--
2.7.4