Commit 6cdb0ee3 by Richard Guenther Committed by Richard Biener

re PR tree-optimization/38513 (Only postreload will remove a no-op store)

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.

From-SVN: r145172
parent 8ca1fd76
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.
......
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.
......
......@@ -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 ();
}
......
/* { 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" } } */
......@@ -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++) {
......
......@@ -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++) {
......
......@@ -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" } } */
......@@ -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++) {
......
......@@ -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++) {
......
......@@ -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 ();
......
......@@ -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 ();
......
......@@ -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 ();
......
......@@ -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);
}
}
......
......@@ -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;
......
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