Commit f9fe7aed by Jeff Law Committed by Jeff Law

tree-vrp.c (test_for_singularity): Correct test for new min limit.


	* tree-vrp.c (test_for_singularity): Correct test for new
	min limit.  Use operand_equal_p rather than pointer equality
	for testing if new min/max values are equal.

	* tree-ssa-propagate.c (substitute_and_fold): Delay simplifications
	using range information until after propagation and folding.

	* gcc.c-torture/execute/930529-1.x: Use -fwrapv as test depends
	on wrapping on overflow semantics.

	* gcc.dg/tree-ssa/pr23109.c: Remove the .lim file too.

	* gcc.gc/tree-ssa/vrp23.c: New test.
	* gcc.gc/tree-ssa/vrp24.c: New test.

From-SVN: r109904
parent 953ff289
2006-01-18 Jeff Law <law@redhat.com>
* tree-vrp.c (test_for_singularity): Correct test for new
min limit. Use operand_equal_p rather than pointer equality
for testing if new min/max values are equal.
* tree-ssa-propagate.c (substitute_and_fold): Delay simplifications
using range information until after propagation and folding.
2006-01-18 Richard Henderson <rth@redhat.com>
Aldy Hernandez <aldyh@redhat.com>
Jakub Jelinek <jakub@redhat.com>
......
2006-01-18 Jeff Law <law@redhat.com>
* gcc.c-torture/execute/930529-1.x: Use -fwrapv as test depends
on wrapping on overflow semantics.
* gcc.dg/tree-ssa/pr23109.c: Remove the .lim file too.
* gcc.gc/tree-ssa/vrp23.c: New test.
* gcc.gc/tree-ssa/vrp24.c: New test.
2006-01-18 Richard Henderson <rth@redhat.com>
Aldy Hernandez <aldyh@redhat.com>
Jakub Jelinek <jakub@redhat.com>
......@@ -20,4 +20,5 @@
# }
# }
set additional_flags "-fwrapv"
return 0
......@@ -31,4 +31,5 @@ int main()
/* { dg-final { scan-tree-dump-not "reciptmp" "lim" } } */
/* { dg-final { scan-tree-dump-not "reciptmp" "recip" } } */
/* { dg-final { cleanup-tree-dump "recip" } } */
/* { dg-final { cleanup-tree-dump "lim" } } */
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-vrp-details" } */
blah (int code1, int code2)
{
int i;
int n_sets;
n_sets = (int) (code1 == 32);
if (code2 == 64) goto L2; else goto L3;
L2:
aa ();
L3:
if (n_sets > 1) goto L4; else goto L10;
L4:
aos ();
i = 0;
goto L24;
L10:
if (n_sets > 0) goto L25; else goto L8;
L25:
i = 0;
L24:
aob ();
i = i + 1;
if (i < n_sets) goto L24; else goto L8;
L8:
return;
}
/* 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 "vrp" } } */
/* { dg-final { cleanup-tree-dump "vrp" } } */
/* { dg-do compile } */
/* { dg-options "-O2 -fdump-tree-vrp-details" } */
struct rtx_def;
typedef struct rtx_def *rtx;
union rtunion_def
{
rtx rt_rtx;
};
typedef union rtunion_def rtunion;
struct rtx_def
{
int code;
union u
{
rtunion fld[1];
} u;
};
sss (rtx insn, int code1, int code2, int code3)
{
_Bool D1562;
struct rtx_def * body;
int i;
int n_sets;
int D1544;
body = insn->u.fld[5].rt_rtx;
D1544 = body->code;
n_sets = 1;
if (D1544 == 55) goto L7; else goto L1;
L1:
n_sets = 0;
if (code3 == 99) goto L2; else goto L11;
L2:
D1562 = code1 == 10;
n_sets = (int) D1562;
if (n_sets > 0) goto L7; else goto L11;
L37:
if (code2 == 42) goto L8; else goto L9;
L8:
arf ();
L9:
i = i + 1;
if (i < n_sets) goto L37; else goto L32;
L32:
L11:
if (n_sets > 1) goto L12; else goto L15;
L12:
nit ();
L14:
i = 0;
goto L38;
L15:
if (n_sets > 0) goto L14; else goto L16;
L38:
frob ();
i = i + 1;
if (n_sets > i) goto L38; else goto L16;
L16:
return;
L7:
i = 0;
goto L37;
}
/* 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 "vrp" } } */
/* { dg-final { cleanup-tree-dump "vrp" } } */
/* Generic SSA value propagation engine.
Copyright (C) 2004, 2005 Free Software Foundation, Inc.
Copyright (C) 2004, 2005, 2006 Free Software Foundation, Inc.
Contributed by Diego Novillo <dnovillo@redhat.com>
This file is part of GCC.
......@@ -1124,14 +1124,7 @@ substitute_and_fold (prop_value_t *prop_value, bool use_ranges_p)
/* If we have range information, see if we can fold
predicate expressions. */
if (use_ranges_p)
{
did_replace = fold_predicate_in (stmt);
/* Some statements may be simplified using ranges. For
example, division may be replaced by shifts, modulo
replaced with bitwise and, etc. */
simplify_stmt_using_ranges (stmt);
}
did_replace = fold_predicate_in (stmt);
if (prop_value)
{
......@@ -1178,6 +1171,16 @@ substitute_and_fold (prop_value_t *prop_value, bool use_ranges_p)
fprintf (dump_file, "\n");
}
}
/* Some statements may be simplified using ranges. For
example, division may be replaced by shifts, modulo
replaced with bitwise and, etc. Do this after
substituting constants, folding, etc so that we're
presented with a fully propagated, canonicalized
statement. */
if (use_ranges_p)
simplify_stmt_using_ranges (stmt);
}
}
......
/* Support routines for Value Range Propagation (VRP).
Copyright (C) 2005 Free Software Foundation, Inc.
Copyright (C) 2005, 2006 Free Software Foundation, Inc.
Contributed by Diego Novillo <dnovillo@redhat.com>.
This file is part of GCC.
......@@ -3970,7 +3970,7 @@ test_for_singularity (enum tree_code cond_code, tree op0,
if (cond_code == GT_EXPR)
{
tree one = build_int_cst (TREE_TYPE (op0), 1);
max = fold_build2 (PLUS_EXPR, TREE_TYPE (op0), max, one);
min = fold_build2 (PLUS_EXPR, TREE_TYPE (op0), min, one);
}
}
......@@ -3987,10 +3987,10 @@ test_for_singularity (enum tree_code cond_code, tree op0,
else
max = vr->max;
/* If the new min/max values have converged to a
single value, then there is only one value which
can satisfy the condition, return that value. */
if (min == max && is_gimple_min_invariant (min))
/* If the new min/max values have converged to a single value,
then there is only one value which can satisfy the condition,
return that value. */
if (operand_equal_p (min, max, 0) && is_gimple_min_invariant (min))
return min;
}
return NULL;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment