Commit 38988cbf by Richard Biener Committed by Richard Biener

re PR tree-optimization/83518 (Missing optimization: useless instructions should be dropped)

2019-07-08  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/83518
	* tree-ssa-sccvn.c: Include splay-tree.h.
	(struct pd_range, struct pd_data): New.
	(struct vn_walk_cb_data): Add data to track partial definitions.
	(vn_walk_cb_data::~vn_walk_cb_data): New.
	(vn_walk_cb_data::push_partial_def): New.
	(pd_tree_alloc, pd_tree_dealloc, pd_range_compare): New.
	(vn_reference_lookup_2): When partial defs are registered give up.
	(vn_reference_lookup_3): Track partial defs for memset and
	constructor zeroing and for defs from constants.

	* gcc.dg/tree-ssa/ssa-fre-73.c: New testcase.
	* gcc.dg/tree-ssa/ssa-fre-74.c: Likewise.
	* gcc.dg/tree-ssa/ssa-fre-75.c: Likewise.
	* gcc.dg/tree-ssa/ssa-fre-76.c: Likewise.
	* g++.dg/tree-ssa/pr83518.C: Likewise.

From-SVN: r273194
parent 8849d503
2019-07-08 Richard Biener <rguenther@suse.de>
PR tree-optimization/83518
* tree-ssa-sccvn.c: Include splay-tree.h.
(struct pd_range, struct pd_data): New.
(struct vn_walk_cb_data): Add data to track partial definitions.
(vn_walk_cb_data::~vn_walk_cb_data): New.
(vn_walk_cb_data::push_partial_def): New.
(pd_tree_alloc, pd_tree_dealloc, pd_range_compare): New.
(vn_reference_lookup_2): When partial defs are registered give up.
(vn_reference_lookup_3): Track partial defs for memset and
constructor zeroing and for defs from constants.
2019-07-08 Richard Sandiford <richard.sandiford@arm.com> 2019-07-08 Richard Sandiford <richard.sandiford@arm.com>
* doc/install.texi (bootstrap-Og): Document. * doc/install.texi (bootstrap-Og): Document.
......
2019-07-08 Richard Biener <rguenther@suse.de>
PR tree-optimization/83518
* gcc.dg/tree-ssa/ssa-fre-73.c: New testcase.
* gcc.dg/tree-ssa/ssa-fre-74.c: Likewise.
* gcc.dg/tree-ssa/ssa-fre-75.c: Likewise.
* gcc.dg/tree-ssa/ssa-fre-76.c: Likewise.
* g++.dg/tree-ssa/pr83518.C: Likewise.
2019-07-08 Richard Sandiford <richard.sandiford@arm.com> 2019-07-08 Richard Sandiford <richard.sandiford@arm.com>
* gcc.dg/guality/guality.h: Include <sys/prctl.h> on Linux targets. * gcc.dg/guality/guality.h: Include <sys/prctl.h> on Linux targets.
......
/* { dg-do compile } */
/* { dg-options "-O3 -fdump-tree-optimized" } */
unsigned test()
{
int arr[] = {5,4,3,2,1};
int sum = 0;
for(int i = 0;i < 5;++i)
{
for(int j = 0; j < 5; ++j)
{
int t = arr[i];
arr[i] = arr[j];
arr[j] = t;
}
}
for(int i = 0; i < 5; ++i)
{
sum += arr[i];
}
return sum;
}
/* { dg-final { scan-tree-dump "return 15;" "optimized" } } */
/* { dg-do compile } */
/* { dg-options "-O -fdump-tree-fre1" } */
typedef int v2si __attribute__((vector_size(__SIZEOF_INT__ * 2)));
int foo (int *a)
{
a[0] = 1;
a[1] = 2;
v2si x = *(v2si *)a;
*(v2si *)&a[2] = x;
return a[3];
}
/* { dg-final { scan-tree-dump "return 2;" "fre1" } } */
/* { dg-do compile } */
/* { dg-options "-O -fdump-tree-fre1" } */
typedef int v4si __attribute__((vector_size(__SIZEOF_INT__ * 4)));
int foo (int *a)
{
a[2] = 2;
a[0] = 0;
a[1] = 1;
a[3] = 4;
v4si x = *(v4si *)a;
*(v4si *)&a[4] = x;
return a[4] + a[7];
}
/* { dg-final { scan-tree-dump "return 4;" "fre1" } } */
/* { dg-do compile } */
/* { dg-require-effective-target int32plus } */
/* { dg-options "-O -fgimple -fdump-tree-fre1" } */
typedef int v4si __attribute__((vector_size(__SIZEOF_INT__ * 4)));
#if __SIZEOF_INT__ == 4
__GIMPLE (ssa) int foo (int *a)
{
v4si _2;
int _3;
int _4;
int _5;
int _6;
int _7;
int _8;
int _9;
__BB(2):
__MEM <unsigned char[3 * __SIZEOF_INT__]> ((char *)a_1(D) + 4) = _Literal (unsigned char[3 * __SIZEOF_INT__]) {};
__MEM <int> (a_1(D) + 8) = 2;
__MEM <int> (a_1(D)) = 1;
_2 = __MEM <v4si> (a_1(D));
_3 = __BIT_FIELD_REF <int> (_2, 32, 0);
_4 = __BIT_FIELD_REF <int> (_2, 32, 32);
_5 = __BIT_FIELD_REF <int> (_2, 32, 64);
_6 = __BIT_FIELD_REF <int> (_2, 32, 96);
_7 = _3 + _4;
_8 = _7 + _5;
_9 = _8 + _6;
return _9;
}
#endif
/* { dg-final { scan-tree-dump "return 3;" "fre1" } } */
/* { dg-do compile } */
/* { dg-options "-O -fdump-tree-fre1" } */
typedef int v4si __attribute__((vector_size(__SIZEOF_INT__ * 4)));
int foo (int *a)
{
__builtin_memset (a, 0, 2 * __SIZEOF_INT__);
a[2] = 2;
a[0] = 1;
a[3] = 3;
v4si x = *(v4si *)a;
*(v4si *)&a[4] = x;
return a[4] + a[5] + a[7];
}
/* { dg-final { scan-tree-dump "return 4;" "fre1" } } */
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