gimple-ssa-evrp.c (class evrp_folder): Add simplify_stmt_using_ranges method.

2018-05-18  Richard Biener  <rguenther@suse.de>

	* gimple-ssa-evrp.c (class evrp_folder): Add simplify_stmt_using_ranges
	method.
	(evrp_dom_walker::before_dom_children): Call it.

	* gcc.dg/tree-ssa/pr21559.c: Adjust.
	* gcc.dg/tree-ssa/pr45397.c: Likewise.
	* gcc.dg/tree-ssa/pr61839_1.c: Likewise.
	* gcc.dg/tree-ssa/pr61839_2.c: Likewise.
	* gcc.dg/tree-ssa/pr61839_4.c: Likewise.
	* gcc.dg/tree-ssa/vrp17.c: Likewise.
	* gcc.dg/tree-ssa/vrp18.c: Likewise.
	* gcc.dg/tree-ssa/vrp23.c: Likewise.
	* gcc.dg/tree-ssa/vrp24.c: Likewise.
	* gcc.dg/tree-ssa/vrp58.c: Likewise.
	* gcc.dg/vrp-min-max-1.c: Likewise.
	* gcc.dg/vrp-min-max-3.c: New testcase.

From-SVN: r260357
This commit is contained in:
Richard Biener 2018-05-18 11:54:37 +00:00 committed by Richard Biener
parent 6b9fc1782e
commit b55fbca39e
15 changed files with 75 additions and 18 deletions

View File

@ -1,3 +1,9 @@
2018-05-18 Richard Biener <rguenther@suse.de>
* gimple-ssa-evrp.c (class evrp_folder): Add simplify_stmt_using_ranges
method.
(evrp_dom_walker::before_dom_children): Call it.
2018-05-18 Richard Biener <rguenther@suse.de>
* tree-dfa.c (get_ref_base_and_extent): Use range-info to refine

View File

@ -47,6 +47,8 @@ class evrp_folder : public substitute_and_fold_engine
public:
tree get_value (tree) FINAL OVERRIDE;
evrp_folder (class vr_values *vr_values_) : vr_values (vr_values_) { }
bool simplify_stmt_using_ranges (gimple_stmt_iterator *gsi)
{ return vr_values->simplify_stmt_using_ranges (gsi); }
class vr_values *vr_values;
private:
@ -180,6 +182,12 @@ evrp_dom_walker::before_dom_children (basic_block bb)
update_stmt (stmt);
did_replace = true;
}
if (evrp_folder.simplify_stmt_using_ranges (&gsi))
{
stmt = gsi_stmt (gsi);
update_stmt (stmt);
did_replace = true;
}
if (did_replace)
{

View File

@ -1,3 +1,18 @@
2018-05-18 Richard Biener <rguenther@suse.de>
* gcc.dg/tree-ssa/pr21559.c: Adjust.
* gcc.dg/tree-ssa/pr45397.c: Likewise.
* gcc.dg/tree-ssa/pr61839_1.c: Likewise.
* gcc.dg/tree-ssa/pr61839_2.c: Likewise.
* gcc.dg/tree-ssa/pr61839_4.c: Likewise.
* gcc.dg/tree-ssa/vrp17.c: Likewise.
* gcc.dg/tree-ssa/vrp18.c: Likewise.
* gcc.dg/tree-ssa/vrp23.c: Likewise.
* gcc.dg/tree-ssa/vrp24.c: Likewise.
* gcc.dg/tree-ssa/vrp58.c: Likewise.
* gcc.dg/vrp-min-max-1.c: Likewise.
* gcc.dg/vrp-min-max-3.c: New testcase.
2018-05-18 Richard Biener <rguenther@suse.de>
* gcc.dg/tree-ssa/ssa-dse-35.c: New testcase.

View File

@ -1,5 +1,5 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-vrp1-details" } */
/* { dg-options "-O2 -fdump-tree-evrp-details -fdump-tree-vrp1-details" } */
static int blocksize = 4096;
@ -33,7 +33,7 @@ void foo (void)
/* First, we should simplify the bits < 0 test within the loop. */
/* { dg-final { scan-tree-dump-times "Simplified relational" 1 "vrp1" } } */
/* { dg-final { scan-tree-dump-times "Simplified relational" 1 "evrp" } } */
/* Second, we should thread the edge out of the loop via the break
statement. We also realize that the final bytes == 0 test is useless,

View File

@ -1,5 +1,5 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-phiopt1" } */
/* { dg-options "-O2 -fdump-tree-phiopt1 -fdump-tree-evrp" } */
int foo_add (const unsigned char *tmp, int i, int val)
{
@ -18,6 +18,7 @@ int foo_mul (const unsigned char *tmp, int i, int val)
/* All cases should end up using min/max for the saturated operations and
have no control flow. */
/* { dg-final { scan-tree-dump-not " & 255;" "evrp" } } */
/* { dg-final { scan-tree-dump-times "MAX_EXPR" 3 "phiopt1" } } */
/* { dg-final { scan-tree-dump-times "MIN_EXPR" 3 "phiopt1" } } */
/* { dg-final { scan-tree-dump-not "if " "phiopt1" } } */

View File

@ -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-vrp1 -fdisable-tree-evrp -fdump-tree-optimized" } */
/* { dg-require-effective-target int32plus } */
__attribute__ ((noinline))

View File

@ -51,4 +51,4 @@ int bar2 ()
/* Dont optimize 972195717 % 0 in function bar. */
/* { dg-final { scan-tree-dump-times "972195717 % " 1 "evrp" } } */
/* May optimize in function bar2, but EVRP doesn't perform this yet. */
/* { dg-final { scan-tree-dump-times "972195715 % " 0 "evrp" { xfail *-*-* } } } */
/* { dg-final { scan-tree-dump-times "972195715 % " 0 "evrp" } } */

View File

@ -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-vrp1 -fdisable-tree-evrp -fdump-tree-optimized" } */
/* { dg-require-effective-target int32plus } */
__attribute__ ((noinline))

View File

@ -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" } } */

View File

@ -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" } } */

View File

@ -1,5 +1,5 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fno-tree-forwprop -fdump-tree-vrp1-details" } */
/* { dg-options "-O2 -fno-tree-forwprop -fdump-tree-evrp-details" } */
void aa (void);
void aos (void);
@ -45,5 +45,5 @@ L8:
/* The n_sets > 0 test can be simplified into n_sets == 1 since the
only way to reach the test is when n_sets <= 1, and the only value
which satisfies both conditions is n_sets == 1. */
/* { dg-final { scan-tree-dump-times "Simplified relational" 1 "vrp1" } } */
/* { dg-final { scan-tree-dump-times "Simplified relational" 1 "evrp" } } */

View File

@ -1,5 +1,5 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fno-tree-forwprop -fdump-tree-vrp1-details -fdump-tree-optimized" } */
/* { dg-options "-O2 -fno-tree-forwprop -fdump-tree-evrp-details -fdump-tree-optimized" } */
struct rtx_def;
@ -88,6 +88,6 @@ L7:
n_sets can only have the values [0, 1] as it's the result of a
boolean operation. */
/* { dg-final { scan-tree-dump-times "Simplified relational" 1 "vrp1" } } */
/* { dg-final { scan-tree-dump-times "Simplified relational" 2 "evrp" } } */
/* { dg-final { scan-tree-dump-times "if " 4 "optimized" } } */

View File

@ -1,5 +1,5 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-vrp1-details" } */
/* { dg-options "-O2 -fdump-tree-cddce1" } */
long long
foo (long long a, signed char b, signed char c)
@ -8,5 +8,5 @@ foo (long long a, signed char b, signed char c)
return a + (short)bc;
}
/* { dg-final { scan-tree-dump "Folded into" "vrp1" { target int32plus } } } */
/* { dg-final { scan-tree-dump "Folding statement: _\[0-9\]\* = \\(long long int\\) bc_\[0-9\]\*;" "vrp1" { target int16 } } } */
/* EVRP should remove the truncation to short, keeping (long long)bc. */
/* { dg-final { scan-tree-dump-not "short" "cddce1" { target int32plus } } } */

View File

@ -1,5 +1,5 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-vrp1 -fdump-tree-mergephi2" } */
/* { dg-options "-O2 -fdump-tree-vrp1 -fdisable-tree-evrp -fdump-tree-mergephi2" } */
int bar (void);

View File

@ -0,0 +1,27 @@
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-evrp -fdump-tree-fre1" } */
int bar (void);
int foo1 (int x, int y)
{
if (y < 10) return bar ();
if (x > 9) return bar ();
return x < y ? x : y;
}
int foo2 (int x, int y)
{
if (y < 10) return bar ();
if (x > 9) return bar ();
return x > y ? x : y;
}
/* We expect to optimiz min/max in EVRP */
/* { dg-final { scan-tree-dump-times "MIN_EXPR" 1 "fre1" } } */
/* { dg-final { scan-tree-dump-times "MAX_EXPR" 1 "fre1" } } */
/* { dg-final { scan-tree-dump-not "MIN_EXPR" "evrp" } } */
/* { dg-final { scan-tree-dump-not "MAX_EXPR" "evrp" } } */