From: Richard Biener Date: Fri, 21 Apr 2017 08:17:23 +0000 (+0000) Subject: re PR tree-optimization/80237 (float to double conversion is not optimized away) X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6d553e9bc9739ac67f96f31b6108c25e7a74f3a3;p=gcc.git re PR tree-optimization/80237 (float to double conversion is not optimized away) 2017-04-21 Richard Biener PR tree-optimization/80237 * tree-ssa-pre.c (find_leader_in_sets): Add third set argument, defaulted to NULL. (phi_translate_1): Also allow a leader in AVAIL_OUT of pred for a simplified result. * gcc.dg/tree-ssa/tailcall-9.c: New testcase. * gcc.dg/tree-ssa/ldist-pr45948.c: Remove undefined behavior, adjust expected optimizations. From-SVN: r247049 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index d2bd25abd15..c30b09b1061 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2017-04-21 Richard Biener + + PR tree-optimization/80237 + * tree-ssa-pre.c (find_leader_in_sets): Add third set argument, + defaulted to NULL. + (phi_translate_1): Also allow a leader in AVAIL_OUT of pred + for a simplified result. + 2016-04-21 Richard Biener * tree-ssa-loop-ivcanon.c (constant_after_peeling): Do not require diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index ffb00ec4799..ddee40285f3 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,10 @@ +2017-04-21 Richard Biener + + PR tree-optimization/80237 + * gcc.dg/tree-ssa/tailcall-9.c: New testcase. + * gcc.dg/tree-ssa/ldist-pr45948.c: Remove undefined behavior, + adjust expected optimizations. + 2016-04-21 Richard Biener * gcc.dg/vect/no-scevccp-outer-13.c: Adjust to prevent unrolling diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ldist-pr45948.c b/gcc/testsuite/gcc.dg/tree-ssa/ldist-pr45948.c index ee2f2832ab4..136eca8c0a5 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ldist-pr45948.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ldist-pr45948.c @@ -1,14 +1,16 @@ /* { dg-do compile } */ -/* { dg-options "-O2 -ftree-loop-distribution -ftree-loop-distribute-patterns -fdump-tree-ldist-details" } */ +/* { dg-options "-O2 -ftree-loop-distribution -ftree-loop-distribute-patterns -fdump-tree-ldist-details -fdump-tree-optimized" } */ extern void bar(int); void -foo (int i, int n) +foo (unsigned i, unsigned n) { int a[30]; int b[30]; - for (; i < n; i++) + if (n == 0) + return; + for (i=0; i < n; i++) a[i] = b[i] = 0; while (1) @@ -16,7 +18,9 @@ foo (int i, int n) bar (a[i - 1]); } -/* We should apply loop distribution and generate 2 memset (0). */ +/* We should apply loop distribution and generate 1 memset (0). PRE optimizes + away a[] completely. */ -/* { dg-final { scan-tree-dump "distributed: split to 0 loops and 2 library calls" "ldist" } } */ -/* { dg-final { scan-tree-dump-times "generated memset zero" 2 "ldist" } } */ +/* { dg-final { scan-tree-dump "distributed: split to 0 loops and 1 library calls" "ldist" } } */ +/* { dg-final { scan-tree-dump-times "generated memset zero" 1 "ldist" } } */ +/* { dg-final { scan-tree-dump-times "int a" 0 "optimized" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/tailcall-9.c b/gcc/testsuite/gcc.dg/tree-ssa/tailcall-9.c new file mode 100644 index 00000000000..c67120fe773 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/tailcall-9.c @@ -0,0 +1,20 @@ +/* { dg-do compile } */ +/* { dg-options "-O2 -fdump-tree-tailc-details" } */ + +__attribute__((noinline)) +static float f(float x) +{ + return x*x; +} + +static double g(float x) +{ + return x>0 ? f(x) : x+1.0; +} + +float foo(float x) +{ + return g(x); +} + +/* { dg-final { scan-tree-dump "Found tail call" "tailc" } } */ diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index c6aa5879739..2c6405aa7a8 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -1313,17 +1313,20 @@ translate_vuse_through_block (vec operands, } /* Like bitmap_find_leader, but checks for the value existing in SET1 *or* - SET2. This is used to avoid making a set consisting of the union - of PA_IN and ANTIC_IN during insert. */ + SET2 *or* SET3. This is used to avoid making a set consisting of the union + of PA_IN and ANTIC_IN during insert and phi-translation. */ static inline pre_expr -find_leader_in_sets (unsigned int val, bitmap_set_t set1, bitmap_set_t set2) +find_leader_in_sets (unsigned int val, bitmap_set_t set1, bitmap_set_t set2, + bitmap_set_t set3 = NULL) { pre_expr result; result = bitmap_find_leader (set1, val); if (!result && set2) result = bitmap_find_leader (set2, val); + if (!result && set3) + result = bitmap_find_leader (set3, val); return result; } @@ -1478,7 +1481,8 @@ phi_translate_1 (pre_expr expr, bitmap_set_t set1, bitmap_set_t set2, else { unsigned value_id = get_expr_value_id (constant); - constant = find_leader_in_sets (value_id, set1, set2); + constant = find_leader_in_sets (value_id, set1, set2, + AVAIL_OUT (pred)); if (constant) return constant; }