+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
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:
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)
{
+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.
/* { 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;
/* 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,
/* { 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)
{
/* 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" } } */
/* 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))
/* 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" } } */
/* 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))
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-vrp1" } */
+/* { dg-options "-O2 -fdump-tree-evrp" } */
extern void abort (void) __attribute__ ((__noreturn__));
union tree_node;
abort ();
}
-/* { dg-final { scan-tree-dump-times "Simplified relational" 1 "vrp1" } } */
+/* { dg-final { scan-tree-dump-times "Simplified relational" 1 "evrp" } } */
/* { dg-do compile } */
-/* { dg-options "-O2 -fdump-tree-vrp1" } */
+/* { dg-options "-O2 -fdump-tree-evrp" } */
static int blocksize = 4096;
eof_reached = 1;
}
-/* { dg-final { scan-tree-dump-times "Simplified relational" 1 "vrp1" } } */
+/* { dg-final { scan-tree-dump-times "Simplified relational" 1 "evrp" } } */
/* { 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);
/* 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" } } */
/* { 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;
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" } } */
/* { 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)
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 } } } */
/* { 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);
--- /dev/null
+/* { 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" } } */