diff options
author | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-03-28 10:11:14 +0000 |
---|---|---|
committer | rguenth <rguenth@138bc75d-0d04-0410-961f-82ee72b054a4> | 2009-03-28 10:11:14 +0000 |
commit | 63295314fa8a77acd60ed88cc59e2eeea152ad12 (patch) | |
tree | aeb29cda7c04bca0cd95e139b6a68576a97d704f /gcc | |
parent | d360ad90ffe01aa874398d1c65048db9fe9234cf (diff) | |
download | gcc-63295314fa8a77acd60ed88cc59e2eeea152ad12.tar.gz |
2009-03-28 Richard Guenther <rguenther@suse.de>
PR tree-optimization/38513
* tree-ssa-pre.c (eliminate): Remove redundant stores.
* tree-ssa-sccvn.c (copy_reference_ops_from_ref): Handle
EXC_PTR_EXPR and FILTER_EXPR.
(get_ref_from_reference_ops): Likewise.
* gcc.dg/tree-ssa/ssa-fre-21.c: New testcase.
* gcc.dg/tree-ssa/ssa-dse-11.c: Adjust.
* gcc.dg/vect/vect-reduc-dot-u8a.c: Likewise.
* gcc.dg/vect/vect-reduc-dot-u8b.c: Likewise.
* gcc.dg/vect/slp-widen-mult-u8.c: Likewise.
* gcc.dg/vect/vect-multitypes-16.c: Likewise.
* gcc.dg/vect/vect-35.c: Likewise.
* gcc.dg/vect/wrapv-vect-reduc-dot-s8b.c: Likewise.
* gcc.dg/vect/vect-multitypes-17.c: Likewise.
* gcc.dg/vect/slp-widen-mult-s16.c: Likewise.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@145172 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'gcc')
-rw-r--r-- | gcc/ChangeLog | 8 | ||||
-rw-r--r-- | gcc/testsuite/ChangeLog | 14 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-11.c | 4 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-21.c | 26 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/vect/slp-widen-mult-s16.c | 10 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/vect/slp-widen-mult-u8.c | 12 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/vect/vect-35.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/vect/vect-multitypes-16.c | 8 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/vect/vect-multitypes-17.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/vect/vect-reduc-dot-u8a.c | 11 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/vect/vect-reduc-dot-u8b.c | 12 | ||||
-rw-r--r-- | gcc/testsuite/gcc.dg/vect/wrapv-vect-reduc-dot-s8b.c | 11 | ||||
-rw-r--r-- | gcc/tree-ssa-pre.c | 57 | ||||
-rw-r--r-- | gcc/tree-ssa-sccvn.c | 4 |
14 files changed, 128 insertions, 68 deletions
diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 48715d3178d..d9c59b8b33d 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,5 +1,13 @@ 2009-03-28 Richard Guenther <rguenther@suse.de> + PR tree-optimization/38513 + * tree-ssa-pre.c (eliminate): Remove redundant stores. + * tree-ssa-sccvn.c (copy_reference_ops_from_ref): Handle + EXC_PTR_EXPR and FILTER_EXPR. + (get_ref_from_reference_ops): Likewise. + +2009-03-28 Richard Guenther <rguenther@suse.de> + PR tree-optimization/38968 * tree-vect-analyze.c (vect_compute_data_ref_alignment): Use FLOOR_MOD_EXPR to compute misalignment. diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index e0f7df77cf4..1cc8e4f43d2 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,5 +1,19 @@ 2009-03-28 Richard Guenther <rguenther@suse.de> + PR tree-optimization/38513 + * gcc.dg/tree-ssa/ssa-fre-21.c: New testcase. + * gcc.dg/tree-ssa/ssa-dse-11.c: Adjust. + * gcc.dg/vect/vect-reduc-dot-u8a.c: Likewise. + * gcc.dg/vect/vect-reduc-dot-u8b.c: Likewise. + * gcc.dg/vect/slp-widen-mult-u8.c: Likewise. + * gcc.dg/vect/vect-multitypes-16.c: Likewise. + * gcc.dg/vect/vect-35.c: Likewise. + * gcc.dg/vect/wrapv-vect-reduc-dot-s8b.c: Likewise. + * gcc.dg/vect/vect-multitypes-17.c: Likewise. + * gcc.dg/vect/slp-widen-mult-s16.c: Likewise. + +2009-03-28 Richard Guenther <rguenther@suse.de> + PR tree-optimization/38968 * gfortran.dg/vect/fast-math-pr38968.f90: New testcase. diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-11.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-11.c index bd66bc2a78e..6e13e187501 100644 --- a/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-11.c +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-dse-11.c @@ -6,13 +6,13 @@ void foo(int *p) { while (1) { - *p = 0; + *p = 1; *p = 0; } } void bar(int *p) { - *p = 0; + *p = 1; *p = 0; abort (); } diff --git a/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-21.c b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-21.c new file mode 100644 index 00000000000..aadf32e21bd --- /dev/null +++ b/gcc/testsuite/gcc.dg/tree-ssa/ssa-fre-21.c @@ -0,0 +1,26 @@ +/* { dg-do compile } */ +/* { dg-options "-O -fdump-tree-fre" } */ + +struct f { + float a; + float b; + float c; + float d; +}; + +struct f a; + +void h(float, float, float, float); + +void g(void) +{ + float a1 = a.a, b = a.b, c = a.c, d = a.d; + a.a = a1; + a.b = b; + a.c = c; + a.d = d; + h(a1, b, c, d); +} + +/* { dg-final { scan-tree-dump-not "a\\\.? = " "fre" } } */ +/* { dg-final { cleanup-tree-dump "fre" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/slp-widen-mult-s16.c b/gcc/testsuite/gcc.dg/vect/slp-widen-mult-s16.c index b4ed282d0aa..32853d73a15 100644 --- a/gcc/testsuite/gcc.dg/vect/slp-widen-mult-s16.c +++ b/gcc/testsuite/gcc.dg/vect/slp-widen-mult-s16.c @@ -5,8 +5,9 @@ #define N 64 -short X[N] __attribute__ ((__aligned__(16))); -short Y[N] __attribute__ ((__aligned__(16))); +short X[N] __attribute__ ((__aligned__(16))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; +short Y[N] __attribute__ ((__aligned__(16))) = {64,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1}; + int result[N]; /* short->int widening-mult */ @@ -26,11 +27,6 @@ int main (void) check_vect (); - for (i=0; i<N; i++) { - X[i] = i; - Y[i] = 64-i; - } - foo1 (N); for (i=0; i<N; i++) { diff --git a/gcc/testsuite/gcc.dg/vect/slp-widen-mult-u8.c b/gcc/testsuite/gcc.dg/vect/slp-widen-mult-u8.c index 16bf5781684..2f80ea085b6 100644 --- a/gcc/testsuite/gcc.dg/vect/slp-widen-mult-u8.c +++ b/gcc/testsuite/gcc.dg/vect/slp-widen-mult-u8.c @@ -5,8 +5,9 @@ #define N 64 -unsigned char X[N] __attribute__ ((__aligned__(16))); -unsigned char Y[N] __attribute__ ((__aligned__(16))); +unsigned char X[N] __attribute__ ((__aligned__(16))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; +unsigned char Y[N] __attribute__ ((__aligned__(16))) = {64,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1}; + unsigned short result[N]; /* char->short widening-mult */ @@ -26,13 +27,6 @@ int main (void) check_vect (); - for (i=0; i<N; i++) { - X[i] = i; - Y[i] = 64-i; - if (i % 5) - X[i] = i; - } - foo1 (N); for (i=0; i<N; i++) { diff --git a/gcc/testsuite/gcc.dg/vect/vect-35.c b/gcc/testsuite/gcc.dg/vect/vect-35.c index d75308f22fe..c6c3bf33860 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-35.c +++ b/gcc/testsuite/gcc.dg/vect/vect-35.c @@ -17,9 +17,7 @@ int main1 () /* Initialization. */ for (i = 0; i < N; i++) { - s.b[i] = 3*i; - if (i%3 == 0) - s.b[i] = 3*i; + s.b[i] = i; } /* Dependence analysis fails cause s.a and s.b may overlap. @@ -32,7 +30,7 @@ int main1 () /* check results: */ for (i = 0; i < N; i++) { - if (s.a[i] != 3*i + 1) + if (s.a[i] != i + 1) abort (); } @@ -47,6 +45,6 @@ int main (void) } -/* { dg-final { scan-tree-dump-times "vectorized 1 loops" 1 "vect" } } */ +/* { dg-final { scan-tree-dump-times "vectorized 2 loops" 1 "vect" } } */ /* { dg-final { scan-tree-dump-times "can't determine dependence between" 1 "vect" } } */ /* { dg-final { cleanup-tree-dump "vect" } } */ diff --git a/gcc/testsuite/gcc.dg/vect/vect-multitypes-16.c b/gcc/testsuite/gcc.dg/vect/vect-multitypes-16.c index b5347ebecc3..4192e3d19ec 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-multitypes-16.c +++ b/gcc/testsuite/gcc.dg/vect/vect-multitypes-16.c @@ -5,7 +5,7 @@ #define N 64 -char x[N] __attribute__ ((__aligned__(16))); +char x[N] __attribute__ ((__aligned__(16))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; __attribute__ ((noinline)) int foo (int len, long long *z) { @@ -24,12 +24,6 @@ int main (void) check_vect (); - for (i=0; i<N; i++) { - x[i] = i; - if (i % 5) - x[i] = i; - } - foo (N,z+2); for (i=0; i<N; i++) { diff --git a/gcc/testsuite/gcc.dg/vect/vect-multitypes-17.c b/gcc/testsuite/gcc.dg/vect/vect-multitypes-17.c index 61670e6995e..9084fc82a12 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-multitypes-17.c +++ b/gcc/testsuite/gcc.dg/vect/vect-multitypes-17.c @@ -5,9 +5,9 @@ #define N 64 -unsigned char uX[N] __attribute__ ((__aligned__(16))); +unsigned char uX[N] __attribute__ ((__aligned__(16))) = {16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1}; unsigned char uresultX[N]; -unsigned long long uY[N] __attribute__ ((__aligned__(16))); +unsigned long long uY[N] __attribute__ ((__aligned__(16))) = {16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1}; unsigned char uresultY[N]; /* Unsigned type demotion (si->qi) */ @@ -28,13 +28,6 @@ int main (void) check_vect (); - for (i=0; i<N; i++) { - uX[i] = 16-i; - uY[i] = 16-i; - if (i%5 == 0) - uX[i] = 16-i; - } - foo1 (N); for (i=0; i<N; i++) { diff --git a/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-u8a.c b/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-u8a.c index d8aefdad1a6..1934deb40d1 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-u8a.c +++ b/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-u8a.c @@ -7,8 +7,8 @@ #define DOT 43680 -unsigned char X[N] __attribute__ ((__aligned__(16))); -unsigned char Y[N] __attribute__ ((__aligned__(16))); +unsigned char X[N] __attribute__ ((__aligned__(16))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; +unsigned char Y[N] __attribute__ ((__aligned__(16))) = {64,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1}; /* char->short->int dot product. Detected as a dot-product pattern. @@ -41,13 +41,6 @@ int main (void) check_vect (); - for (i=0; i<N; i++) { - X[i] = i; - Y[i] = 64-i; - if (i%5 == 0) - X[i] = i; - } - dot = foo (N); if (dot != DOT) abort (); diff --git a/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-u8b.c b/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-u8b.c index 5496f6af920..3266d1ca0b5 100644 --- a/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-u8b.c +++ b/gcc/testsuite/gcc.dg/vect/vect-reduc-dot-u8b.c @@ -7,8 +7,8 @@ #define DOT 43680 -unsigned char X[N] __attribute__ ((__aligned__(16))); -unsigned char Y[N] __attribute__ ((__aligned__(16))); +unsigned char X[N] __attribute__ ((__aligned__(16))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; +unsigned char Y[N] __attribute__ ((__aligned__(16))) = {64,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1}; /* char->short->short dot product. Detected as a dot-product pattern. @@ -36,14 +36,6 @@ int main (void) check_vect (); - for (i=0; i<N; i++) { - X[i] = i; - Y[i] = 64-i; - /* Avoid vectorization. */ - if (i%100 == 0) - X[i] = i; - } - dot = foo (N); if (dot != DOT) abort (); diff --git a/gcc/testsuite/gcc.dg/vect/wrapv-vect-reduc-dot-s8b.c b/gcc/testsuite/gcc.dg/vect/wrapv-vect-reduc-dot-s8b.c index 31eb3f62054..7fc00e21a79 100644 --- a/gcc/testsuite/gcc.dg/vect/wrapv-vect-reduc-dot-s8b.c +++ b/gcc/testsuite/gcc.dg/vect/wrapv-vect-reduc-dot-s8b.c @@ -7,8 +7,8 @@ #define DOT -21856 -signed char X[N] __attribute__ ((__aligned__(16))); -signed char Y[N] __attribute__ ((__aligned__(16))); +signed char X[N] __attribute__ ((__aligned__(16))) = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58,59,60,61,62,63}; +signed char Y[N] __attribute__ ((__aligned__(16))) = {64,63,62,61,60,59,58,57,56,55,54,53,52,51,50,49,48,47,46,45,44,43,42,41,40,39,38,37,36,35,34,33,32,31,30,29,28,27,26,25,24,23,22,21,20,19,18,17,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1}; /* char->short->short dot product. The dot-product pattern should be detected. @@ -37,13 +37,6 @@ int main (void) check_vect (); - for (i=0; i<N; i++) { - X[i] = i; - Y[i] = 64-i; - if (i%5 == 0) - X[i] = i; - } - dot = foo (N); if (dot != DOT) abort (); diff --git a/gcc/tree-ssa-pre.c b/gcc/tree-ssa-pre.c index 9d931c496e8..18c442e6371 100644 --- a/gcc/tree-ssa-pre.c +++ b/gcc/tree-ssa-pre.c @@ -3857,7 +3857,7 @@ eliminate (void) { gimple_stmt_iterator i; - for (i = gsi_start_bb (b); !gsi_end_p (i); gsi_next (&i)) + for (i = gsi_start_bb (b); !gsi_end_p (i);) { gimple stmt = gsi_stmt (i); @@ -3915,6 +3915,7 @@ eliminate (void) propagate_tree_value_into_stmt (&i, sprime); stmt = gsi_stmt (i); update_stmt (stmt); + gsi_next (&i); continue; } @@ -3975,6 +3976,58 @@ eliminate (void) } } } + /* If the statement is a scalar store, see if the expression + has the same value number as its rhs. If so, the store is + dead. */ + else if (gimple_assign_single_p (stmt) + && !is_gimple_reg (gimple_assign_lhs (stmt)) + && (TREE_CODE (gimple_assign_rhs1 (stmt)) == SSA_NAME + || is_gimple_min_invariant (gimple_assign_rhs1 (stmt)))) + { + tree rhs = gimple_assign_rhs1 (stmt); + tree val; + val = vn_reference_lookup (gimple_assign_lhs (stmt), + shared_vuses_from_stmt (stmt), + true, NULL); + if (TREE_CODE (rhs) == SSA_NAME) + rhs = VN_INFO (rhs)->valnum; + if (val + && operand_equal_p (val, rhs, 0)) + { + def_operand_p def; + use_operand_p use; + vuse_vec_p usevec; + ssa_op_iter oi; + imm_use_iterator ui; + gimple use_stmt; + + if (dump_file && (dump_flags & TDF_DETAILS)) + { + fprintf (dump_file, "Deleted dead store "); + print_gimple_stmt (dump_file, stmt, 0, 0); + } + + /* Propagate all may-uses to the uses of their defs. */ + FOR_EACH_SSA_VDEF_OPERAND (def, usevec, stmt, oi) + { + tree vuse = VUSE_ELEMENT_VAR (*usevec, 0); + tree vdef = DEF_FROM_PTR (def); + + /* If the vdef is used in an abnormal PHI node we + have to propagate that flag to the vuse as well. */ + if (SSA_NAME_OCCURS_IN_ABNORMAL_PHI (vdef)) + SSA_NAME_OCCURS_IN_ABNORMAL_PHI (vuse) = 1; + + FOR_EACH_IMM_USE_STMT (use_stmt, ui, vdef) + FOR_EACH_IMM_USE_ON_STMT (use, ui) + SET_USE (use, vuse); + } + + gsi_remove (&i, true); + release_defs (stmt); + continue; + } + } /* Visit COND_EXPRs and fold the comparison with the available value-numbers. */ else if (gimple_code (stmt) == GIMPLE_COND) @@ -3999,6 +4052,8 @@ eliminate (void) todo = TODO_cleanup_cfg; } } + + gsi_next (&i); } } diff --git a/gcc/tree-ssa-sccvn.c b/gcc/tree-ssa-sccvn.c index dc55676c4a3..fb903921656 100644 --- a/gcc/tree-ssa-sccvn.c +++ b/gcc/tree-ssa-sccvn.c @@ -658,6 +658,8 @@ copy_reference_ops_from_ref (tree ref, VEC(vn_reference_op_s, heap) **result) case CONST_DECL: case RESULT_DECL: case SSA_NAME: + case EXC_PTR_EXPR: + case FILTER_EXPR: temp.op0 = ref; break; case ADDR_EXPR: @@ -750,6 +752,8 @@ get_ref_from_reference_ops (VEC(vn_reference_op_s, heap) *ops) case CONST_DECL: case RESULT_DECL: case SSA_NAME: + case FILTER_EXPR: + case EXC_PTR_EXPR: *op0_p = op->op0; break; |