diff options
author | law <law@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-01-18 19:47:16 +0000 |
---|---|---|
committer | law <law@138bc75d-0d04-0410-961f-82ee72b054a4> | 2006-01-18 19:47:16 +0000 |
commit | 4f87bd68d2e70bb06e350c16b9ada67c24075380 (patch) | |
tree | d39d6d56ed7796b26c42b4c0d68518a4491b59a3 /gcc | |
parent | 1e8e992020adfba209ef30b3c369e2ca6282d837 (diff) | |
download | gcc-4f87bd68d2e70bb06e350c16b9ada67c24075380.tar.gz |
* 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.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@109904 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 9 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 10 | ||||
-rw-r--r-- | gcc/testsuite/gcc.c-torture/execute/930529-1.x | 1 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/pr23109.c | 1 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/vrp23.c | 45 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/vrp24.c | 89 | ||||
-rw-r--r-- | gcc/tree-ssa-propagate.c | 21 | ||||
-rw-r--r-- | gcc/tree-vrp.c | 12 |
8 files changed, 173 insertions, 15 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b57d517e789..d6c62f61536 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,12 @@ +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> diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 15e47619f17..f7973945267 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,13 @@ +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> diff --git a/gcc/testsuite/gcc.c-torture/execute/930529-1.x b/gcc/testsuite/gcc.c-torture/execute/930529-1.x index fb86979f7c1..25225f4f4d6 100644 --- a/gcc/testsuite/gcc.c-torture/execute/930529-1.x +++ b/gcc/testsuite/gcc.c-torture/execute/930529-1.x @@ -20,4 +20,5 @@ # } # } +set additional_flags "-fwrapv" return 0 diff --git a/gcc/testsuite/gcc.dg/tree-ssa/pr23109.c b/gcc/testsuite/gcc.dg/tree-ssa/pr23109.c index e121a553833..b620fa4b824 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/pr23109.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/pr23109.c @@ -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" } } */ diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp23.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp23.c new file mode 100644 index 00000000000..c394d4aa084 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp23.c @@ -0,0 +1,45 @@ +/* { 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" } } */ + diff --git a/gcc/testsuite/gcc.dg/tree-ssa/vrp24.c b/gcc/testsuite/gcc.dg/tree-ssa/vrp24.c new file mode 100644 index 00000000000..3be7efa4707 --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/vrp24.c @@ -0,0 +1,89 @@ +/* { 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" } } */ + diff --git a/gcc/tree-ssa-propagate.c b/gcc/tree-ssa-propagate.c index d8ba253b9d5..dcdc6add4dd 100644 --- a/gcc/tree-ssa-propagate.c +++ b/gcc/tree-ssa-propagate.c @@ -1,5 +1,5 @@ /* 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); + } } diff --git a/gcc/tree-vrp.c b/gcc/tree-vrp.c index 7fcd62d0fb9..a5028b4d8f5 100644 --- a/gcc/tree-vrp.c +++ b/gcc/tree-vrp.c @@ -1,5 +1,5 @@ /* 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; |