+2017-04-21 Richard Biener <rguenther@suse.de>
+
+ 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 <rguenther@suse.de>
* tree-ssa-loop-ivcanon.c (constant_after_peeling): Do not require
+2017-04-21 Richard Biener <rguenther@suse.de>
+
+ 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 <rguenther@suse.de>
* gcc.dg/vect/no-scevccp-outer-13.c: Adjust to prevent unrolling
/* { 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)
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" } } */
--- /dev/null
+/* { 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" } } */
}
/* 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;
}
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;
}