Commit d9c259ef by Bin Cheng Committed by Bin Cheng

tree-predcom.c: Revise general description of the pass.

	* tree-predcom.c: Revise general description of the pass.
	(enum chain_type): New enum type for store elimination.
	(struct chain): New field supporting store elimination.
	(struct component): Ditto.
	(dump_chain): Dump store-stores chain.
	(release_chain): Release resources.
	(split_data_refs_to_components): Compute and create component
	contains only stores for elimination.
	(get_chain_last_ref_at): New function.
	(make_invariant_chain): Initialization.
	(make_rooted_chain): Specify chain type in parameter and record it.
	(add_looparound_copies): Skip for store-stores chain.
	(determine_roots_comp): Compute type of chain and pass it to
	make_rooted_chain.
	(initialize_root_vars_store_elim_2): New function.
	(finalize_eliminated_stores): New function.
	(remove_stmt): Handle store for elimination.
	(execute_pred_commoning_chain): Execute predictive commoning on
	store-store chains.
	(determine_unroll_factor): Skip unroll for store-stores chain.
	(prepare_initializers_chain_store_elim): New function.
	(prepare_initializers_chain): Hanlde store-store chain.
	(prepare_finalizers_chain, prepare_finalizers): New function.
	(tree_predictive_commoning_loop): Return integer value indicating
	if loop is unrolled or lcssa form is corrupted.
	(tree_predictive_commoning): Rewrite for lcssa form if necessary.

	gcc/testsuite
	* gcc.dg/tree-ssa/predcom-dse-1.c: New test.
	* gcc.dg/tree-ssa/predcom-dse-2.c: New test.
	* gcc.dg/tree-ssa/predcom-dse-3.c: New test.
	* gcc.dg/tree-ssa/predcom-dse-4.c: New test.
	* gcc.dg/tree-ssa/predcom-dse-5.c: New test.
	* gcc.dg/tree-ssa/predcom-dse-6.c: New test.
	* gcc.dg/tree-ssa/predcom-dse-7.c: New test.
	* gcc.dg/tree-ssa/predcom-dse-8.c: New test.
	* gcc.dg/tree-ssa/predcom-dse-9.c: New test.
	* gcc.dg/tree-ssa/predcom-dse-10.c: New test.
	* gcc.dg/tree-ssa/predcom-dse-11.c: New test.

From-SVN: r250669
parent 10dfaf9a
2017-07-28 Bin Cheng <bin.cheng@arm.com>
* tree-predcom.c: Revise general description of the pass.
(enum chain_type): New enum type for store elimination.
(struct chain): New field supporting store elimination.
(struct component): Ditto.
(dump_chain): Dump store-stores chain.
(release_chain): Release resources.
(split_data_refs_to_components): Compute and create component
contains only stores for elimination.
(get_chain_last_ref_at): New function.
(make_invariant_chain): Initialization.
(make_rooted_chain): Specify chain type in parameter and record it.
(add_looparound_copies): Skip for store-stores chain.
(determine_roots_comp): Compute type of chain and pass it to
make_rooted_chain.
(initialize_root_vars_store_elim_2): New function.
(finalize_eliminated_stores): New function.
(remove_stmt): Handle store for elimination.
(execute_pred_commoning_chain): Execute predictive commoning on
store-store chains.
(determine_unroll_factor): Skip unroll for store-stores chain.
(prepare_initializers_chain_store_elim): New function.
(prepare_initializers_chain): Hanlde store-store chain.
(prepare_finalizers_chain, prepare_finalizers): New function.
(tree_predictive_commoning_loop): Return integer value indicating
if loop is unrolled or lcssa form is corrupted.
(tree_predictive_commoning): Rewrite for lcssa form if necessary.
2017-07-28 Bin Cheng <bin.cheng@arm.com>
* tree-predcom.c (initialize_root): Delete.
(execute_pred_commoning_chain): Initialize root vars and replace
reference of non-combined chain directly, rather than call above
......
2017-07-28 Bin Cheng <bin.cheng@arm.com>
* gcc.dg/tree-ssa/predcom-dse-1.c: New test.
* gcc.dg/tree-ssa/predcom-dse-2.c: New test.
* gcc.dg/tree-ssa/predcom-dse-3.c: New test.
* gcc.dg/tree-ssa/predcom-dse-4.c: New test.
* gcc.dg/tree-ssa/predcom-dse-5.c: New test.
* gcc.dg/tree-ssa/predcom-dse-6.c: New test.
* gcc.dg/tree-ssa/predcom-dse-7.c: New test.
* gcc.dg/tree-ssa/predcom-dse-8.c: New test.
* gcc.dg/tree-ssa/predcom-dse-9.c: New test.
* gcc.dg/tree-ssa/predcom-dse-10.c: New test.
* gcc.dg/tree-ssa/predcom-dse-11.c: New test.
2017-07-28 Martin Liska <mliska@suse.cz>
PR sanitizer/81340
......
/* { dg-do run } */
/* { dg-options "-O2 -fno-inline -fpredictive-commoning -fdump-tree-pcom-details" } */
int arr[105] = {2, 3, 5, 7, 11};
int result0[10] = {2, 3, 5, 7, 11};
int result1[10] = {0, -1, 5, -2, 11, 0};
int result2[10] = {0, 0, -1, -2, -2, 0};
int result3[10] = {0, 0, 0, -1, -2, -2, 0};
int result4[10] = {0, 0, 0, 0, -1, -2, -2, 0};
int result100[105] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -2, -2, 0};
extern void abort (void);
void __attribute__((noinline)) foo (int *a, int len)
{
int i;
for (i = 0; i < len; i++)
{
a[i] = 0;
a[i + 1] = -1;
a[i + 3] = -2;
}
}
void check (int *a, int *res, int len)
{
int i;
for (i = 0; i < len; i++)
if (a[i] != res[i])
abort ();
}
int main (void)
{
foo (arr, 0);
check (arr, result0, 10);
foo (arr, 1);
check (arr, result1, 10);
foo (arr, 2);
check (arr, result2, 10);
foo (arr, 3);
check (arr, result3, 10);
foo (arr, 4);
check (arr, result4, 10);
foo (arr, 100);
check (arr, result100, 105);
return 0;
}
/* { dg-final { scan-tree-dump "Store-stores chain" "pcom"} } */
/* { dg-do run } */
/* { dg-options "-O2 -fno-inline -fpredictive-commoning -fdump-tree-pcom-details" } */
int arr[105] = {2, 3, 5, 7, 11};
int result0[10] = {2, 3, 5, 7, 11};
int result1[10] = {0, 3, 5, -2, 11, 0};
extern void abort (void);
void __attribute__((noinline)) foo (int *a, int len, int flag)
{
int i;
for (i = 0; i < len; i++)
{
a[i] = 0;
if (flag)
a[i + 1] = -1;
a[i + 3] = -2;
}
}
void check (int *a, int *res, int len)
{
int i;
for (i = 0; i < len; i++)
if (a[i] != res[i])
abort ();
}
int main (void)
{
int i;
foo (arr, 0, 0);
check (arr, result0, 10);
foo (arr, 1, 0);
check (arr, result1, 10);
return 0;
}
/* { dg-final { scan-tree-dump-not "Store-stores chain" "pcom"} } */
/* { dg-do run } */
/* { dg-options "-O2 -fno-inline -fpredictive-commoning -fdump-tree-pcom-details" } */
int arr[105] = {2, 3, 5, 7, 11};
int x[105] = {2, 3, 5, 7, 11};
int result0[10] = {2, 3, 5, 7, 11};
int result1[10] = {0, 0, 0, 0, 0, 0, -1, -2, -2};
extern void abort (void);
int __attribute__((noinline)) foo (int * __restrict__ a, int * __restrict__ b, int len, int flag)
{
int i, sum = 0;
for (i = 0; i < len; i++)
{
a[i] = 0;
b[i + 2] = i;
a[i + 1] = -1;
sum += b[i];
a[i + 3] = -2;
}
return sum;
}
void check (int *a, int *res, int len, int sum, int val)
{
int i;
if (sum != val)
abort ();
for (i = 0; i < len; i++)
if (a[i] != res[i])
abort ();
}
int main (void)
{
int i, sum;
sum = foo (arr, x, 0, 0);
check (arr, result0, 10, sum, 0);
sum = foo (arr, x, 6, 0);
check (arr, result1, 10, sum, 11);
return 0;
}
/* { dg-final { scan-tree-dump "Store-stores chain" "pcom"} } */
/* { dg-final { scan-tree-dump "Store-loads chain" "pcom"} } */
/* { dg-do run } */
/* { dg-options "-O2 -fno-inline -fpredictive-commoning -fdump-tree-pcom-details" } */
int arr[105] = {2, 3, 5, 7, 11};
int result0[10] = {2, 3, 5, 7, 11};
int result1[10] = {0, 3, -1, -2, 11, 0};
int result2[10] = {0, 0, -1, -1, -2, 0};
int result3[10] = {0, 0, 0, -1, -1, -2, 0};
int result4[10] = {0, 0, 0, 0, -1, -1, -2, 0};
int result100[105] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -2, 0};
extern void abort (void);
void __attribute__((noinline)) foo (int *a, int len)
{
int i;
for (i = 0; i < len; i++)
{
a[i] = 0;
a[i + 2] = -1;
a[i + 3] = -2;
}
}
void check (int *a, int *res, int len)
{
int i;
for (i = 0; i < len; i++)
if (a[i] != res[i])
abort ();
}
int main (void)
{
foo (arr, 0);
check (arr, result0, 10);
foo (arr, 1);
check (arr, result1, 10);
foo (arr, 2);
check (arr, result2, 10);
foo (arr, 3);
check (arr, result3, 10);
foo (arr, 4);
check (arr, result4, 10);
foo (arr, 100);
check (arr, result100, 105);
return 0;
}
/* { dg-final { scan-tree-dump "Store-stores chain" "pcom"} } */
/* { dg-do run } */
/* { dg-options "-O2 -fno-inline -fpredictive-commoning -fdump-tree-pcom-details" } */
int arr1[105] = {2, 3, 5, 7, 11, 13, 0};
int arr2[105] = {2, 3, 5, 7, 11, 13, 0};
int arr3[105] = {2, 3, 5, 7, 11, 13, 0};
int arr4[105] = {2, 3, 5, 7, 11, 13, 0};
int result1[105] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -2, -3, 0};
int result2[105] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -2, 0};
int result3[105] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -2, -2, 0};
int result4[105] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, 0};
extern void abort (void);
void check (int *a, int *res, int len)
{
int i;
for (i = 0; i < len; i++)
if (a[i] != res[i])
abort ();
}
void __attribute__((noinline)) foo1 (int *a)
{
int i;
for (i = 0; i < 100; i++)
{
a[i] = 0;
a[i + 1] = -1;
a[i + 2] = -2;
a[i + 3] = -3;
}
}
void __attribute__((noinline)) foo2 (int *a)
{
int i;
for (i = 0; i < 100; i++)
{
a[i] = 0;
a[i + 2] = -1;
a[i + 3] = -2;
}
}
void __attribute__((noinline)) foo3 (int *a)
{
int i;
for (i = 0; i < 100; i++)
{
a[i] = 0;
a[i + 1] = -1;
a[i + 3] = -2;
}
}
void __attribute__((noinline)) foo4 (int *a)
{
int i;
for (i = 0; i < 100; i++)
{
a[i] = 0;
a[i + 3] = -1;
}
}
int main (void)
{
foo1 (arr1);
check (arr1, result1, 105);
foo2 (arr2);
check (arr2, result2, 105);
foo3 (arr3);
check (arr3, result3, 105);
foo4 (arr4);
check (arr4, result4, 105);
return 0;
}
/* { dg-final { scan-tree-dump-times "Store-stores chain" 4 "pcom"} } */
/* { dg-do run } */
/* { dg-options "-O2 -fno-inline -fpredictive-commoning -fdump-tree-pcom-details" } */
int arr[105] = {2, 3, 5, 7, 11};
int result0[10] = {2, 3, 5, 7, 11};
int result1[10] = {0, 3, 5, -1, 11, 0};
int result2[10] = {0, 0, 5, -1, -1, 0};
int result3[10] = {0, 0, 0, -1, -1, -1, 0};
int result4[10] = {0, 0, 0, 0, -1, -1, -1, 0};
int result100[105] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -1, -1, 0};
extern void abort (void);
void __attribute__((noinline)) foo (int *a, int len)
{
int i;
for (i = 0; i < len; i++)
{
a[i] = 0;
a[i + 3] = -1;
}
}
void check (int *a, int *res, int len)
{
int i;
for (i = 0; i < len; i++)
if (a[i] != res[i])
abort ();
}
int main (void)
{
foo (arr, 0);
check (arr, result0, 10);
foo (arr, 1);
check (arr, result1, 10);
foo (arr, 2);
check (arr, result2, 10);
foo (arr, 3);
check (arr, result3, 10);
foo (arr, 4);
check (arr, result4, 10);
foo (arr, 100);
check (arr, result100, 105);
return 0;
}
/* { dg-final { scan-tree-dump "Store-stores chain" "pcom"} } */
/* { dg-do run } */
/* { dg-options "-O2 -fno-inline -fpredictive-commoning -fdump-tree-pcom-details" } */
int arr[105] = {2, 3, 5, 7, 11};
int result0[10] = {2, 3, 5, 7, 11};
int result1[10] = {0, -1, -2, -3, 11, 0};
int result2[10] = {0, 0, -1, -2, -3, 0};
int result3[10] = {0, 0, 0, -1, -2, -3, 0};
int result4[10] = {0, 0, 0, 0, -1, -2, -3, 0};
int result100[105] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -2, -3, 0};
extern void abort (void);
void __attribute__((noinline)) foo (int *a, int len)
{
int i;
for (i = 0; i < len; i++)
{
a[i] = 0;
a[i + 1] = -1;
a[i + 2] = -2;
a[i + 3] = -3;
}
}
void check (int *a, int *res, int len)
{
int i;
for (i = 0; i < len; i++)
if (a[i] != res[i])
abort ();
}
int main (void)
{
foo (arr, 0);
check (arr, result0, 10);
foo (arr, 1);
check (arr, result1, 10);
foo (arr, 2);
check (arr, result2, 10);
foo (arr, 3);
check (arr, result3, 10);
foo (arr, 4);
check (arr, result4, 10);
foo (arr, 100);
check (arr, result100, 105);
return 0;
}
/* { dg-final { scan-tree-dump "Store-stores chain" "pcom"} } */
/* { dg-do run } */
/* { dg-options "-O2 -fno-inline -fpredictive-commoning -fdump-tree-pcom-details" } */
int arr[105] = {2, 3, 5, 7, 11, 13, 17, 19};
int result0[10] = {2, 3, 5, 7, 11, 13, 17, 19};
int result1[10] = {0, -1, -2, -3, -4, -5, 17, 19};
int result2[10] = {0, 0, -1, -2, -3, -4, -5, 19};
int result3[10] = {0, 0, 0, -1, -2, -3, -4, -5};
int result4[10] = {0, 0, 0, 0, -1, -2, -3, -4, -5};
int result100[105] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -2, -3, -4, -5};
extern void abort (void);
void __attribute__((noinline)) foo (int *a, int len)
{
int i;
for (i = 0; i < len; i++)
{
a[i] = 0;
a[i + 1] = -1;
a[i + 2] = -2;
a[i + 3] = -3;
a[i + 4] = -4;
a[i + 5] = -5;
}
}
void check (int *a, int *res, int len)
{
int i;
for (i = 0; i < len; i++)
if (a[i] != res[i])
abort ();
}
int main (void)
{
foo (arr, 0);
check (arr, result0, 10);
foo (arr, 1);
check (arr, result1, 10);
foo (arr, 2);
check (arr, result2, 10);
foo (arr, 3);
check (arr, result3, 10);
foo (arr, 4);
check (arr, result4, 10);
foo (arr, 100);
check (arr, result100, 105);
return 0;
}
/* { dg-final { scan-tree-dump "Store-stores chain" "pcom"} } */
/* { dg-do run } */
/* { dg-options "-O2 -fno-inline -fpredictive-commoning -fdump-tree-pcom-details" } */
int arr[105] = {2, 3, 5, 7, 11, 13, 17, 19};
int result0[10] = {2, 3, 5, 7, 11, 13, 17, 19};
int result1[10] = {0, -1, 5, -3, 11, -5, 17, 19};
int result2[10] = {0, 0, -1, -3, -3, -5, -5, 19};
int result3[10] = {0, 0, 0, -1, -3, -3, -5, -5};
int result4[10] = {0, 0, 0, 0, -1, -3, -3, -5, -5};
int result100[105] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -3, -3, -5, -5};
extern void abort (void);
void __attribute__((noinline)) foo (int *a, int len)
{
int i;
for (i = 0; i < len; i++)
{
a[i] = 0;
a[i + 1] = -1;
a[i + 3] = -3;
a[i + 5] = -5;
}
}
void check (int *a, int *res, int len)
{
int i;
for (i = 0; i < len; i++)
if (a[i] != res[i])
abort ();
}
int main (void)
{
foo (arr, 0);
check (arr, result0, 10);
foo (arr, 1);
check (arr, result1, 10);
foo (arr, 2);
check (arr, result2, 10);
foo (arr, 3);
check (arr, result3, 10);
foo (arr, 4);
check (arr, result4, 10);
foo (arr, 100);
check (arr, result100, 105);
return 0;
}
/* { dg-final { scan-tree-dump "Store-stores chain" "pcom"} } */
/* { dg-do run } */
/* { dg-options "-O2 -fno-inline -fpredictive-commoning -fdump-tree-pcom-details" } */
int arr[105] = {2, 3, 5, 7, 11, 13, 17, 19};
int result0[10] = {2, 3, 5, 7, 11, 13, 17, 19};
int result1[10] = {0, 3, 5, 7, 11, -5, 17, 19};
int result2[10] = {0, 0, 5, 7, 11, -5, -5, 19};
int result3[10] = {0, 0, 0, 7, 11, -5, -5, -5};
int result4[10] = {0, 0, 0, 0, 11, -5, -5, -5, -5};
int result100[105] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -5, -5, -5, -5, -5};
extern void abort (void);
void __attribute__((noinline)) foo (int *a, int len)
{
int i;
for (i = 0; i < len; i++)
{
a[i] = 0;
a[i + 5] = -5;
}
}
void check (int *a, int *res, int len)
{
int i;
for (i = 0; i < len; i++)
if (a[i] != res[i])
abort ();
}
int main (void)
{
foo (arr, 0);
check (arr, result0, 10);
foo (arr, 1);
check (arr, result1, 10);
foo (arr, 2);
check (arr, result2, 10);
foo (arr, 3);
check (arr, result3, 10);
foo (arr, 4);
check (arr, result4, 10);
foo (arr, 100);
check (arr, result100, 105);
return 0;
}
/* { dg-do run } */
/* { dg-options "-O2 -fno-inline -fpredictive-commoning -fdump-tree-pcom-details" } */
int arr1[105] = {2, 3, 5, 7, 11, 13, 17, 19};
int arr2[105] = {2, 3, 5, 7, 11, 13, 17, 19};
int arr3[105] = {2, 3, 5, 7, 11, 13, 17, 19};
int result1[105] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -2, -3, -4, -5};
int result2[105] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -1, -3, -3, -5, -5};
int result3[105] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, -5, -5, -5, -5, -5};
extern void abort (void);
void __attribute__((noinline)) foo1 (int *a)
{
int i;
for (i = 0; i < 100; i++)
{
a[i] = 0;
a[i + 1] = -1;
a[i + 2] = -2;
a[i + 3] = -3;
a[i + 4] = -4;
a[i + 5] = -5;
}
}
void __attribute__((noinline)) foo2 (int *a)
{
int i;
for (i = 0; i < 100; i++)
{
a[i] = 0;
a[i + 1] = -1;
a[i + 3] = -3;
a[i + 5] = -5;
}
}
void __attribute__((noinline)) foo3 (int *a)
{
int i;
for (i = 0; i < 100; i++)
{
a[i] = 0;
a[i + 5] = -5;
}
}
void check (int *a, int *res, int len)
{
int i;
for (i = 0; i < len; i++)
if (a[i] != res[i])
abort ();
}
int main (void)
{
foo1 (arr1);
check (arr1, result1, 10);
foo2 (arr2);
check (arr2, result2, 10);
foo3 (arr3);
check (arr3, result3, 10);
return 0;
}
/* { dg-final { scan-tree-dump "Store-stores chain" "pcom"} } */
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