Commit a01e93f1 by Yuri Rumyantsev Committed by Ilya Enkovich

tree-ssa-loop-unswitch.c: Include "gimple-iterator.h" and "cfghooks.h"...

gcc/

	* tree-ssa-loop-unswitch.c: Include "gimple-iterator.h" and
	"cfghooks.h", add prototypes for introduced new functions.
	(tree_ssa_unswitch_loops): Use from innermost loop iterator, move all
	checks on ability of loop unswitching to tree_unswitch_single_loop;
	invoke tree_unswitch_single_loop or tree_unswitch_outer_loop depending
	on innermost loop check.
	(tree_unswitch_single_loop): Add all required checks on ability of
	loop unswitching under zero recursive level guard.
	(tree_unswitch_outer_loop): New function.
	(find_loop_guard): Likewise.
	(empty_bb_without_guard_p): Likewise.
	(used_outside_loop_p): Likewise.
	(get_vop_from_header): Likewise.
	(hoist_guard): Likewise.
	(check_exit_phi): Likewise.

gcc/testsuite/

	* gcc.dg/loop-unswitch-2.c: New test.
	* gcc.dg/loop-unswitch-3.c: Likewise.
	* gcc.dg/loop-unswitch-4.c: Likewise.

From-SVN: r228599
parent f28ff5b5
2015-10-08 Yuri Rumyantsev <ysrumyan@gmail.com>
* tree-ssa-loop-unswitch.c: Include "gimple-iterator.h" and
"cfghooks.h", add prototypes for introduced new functions.
(tree_ssa_unswitch_loops): Use from innermost loop iterator, move all
checks on ability of loop unswitching to tree_unswitch_single_loop;
invoke tree_unswitch_single_loop or tree_unswitch_outer_loop depending
on innermost loop check.
(tree_unswitch_single_loop): Add all required checks on ability of
loop unswitching under zero recursive level guard.
(tree_unswitch_outer_loop): New function.
(find_loop_guard): Likewise.
(empty_bb_without_guard_p): Likewise.
(used_outside_loop_p): Likewise.
(get_vop_from_header): Likewise.
(hoist_guard): Likewise.
(check_exit_phi): Likewise.
2015-10-08 Marek Polacek <polacek@redhat.com>
* tree-ssa-reassoc.c (dump_ops_vector): Print newline after each
2015-10-08 Yuri Rumyantsev <ysrumyan@gmail.com>
* gcc.dg/loop-unswitch-2.c: New test.
* gcc.dg/loop-unswitch-3.c: Likewise.
* gcc.dg/loop-unswitch-4.c: Likewise.
2015-10-08 Tom de Vries <tom@codesourcery.com>
* gcc.dg/dse.c: Only dump in dse1 pass.
......
/* { dg-do compile } */
/* { dg-options "-O2 -funswitch-loops -fdump-tree-unswitch-details" } */
void foo (float **a, float **b, float *c, int n, int m, int l)
{
int i,j,k;
float s;
for (i=0; i<l; i++)
for (j=0; j<n; j++)
for (k=0; k<m; k++)
c[i] += a[i][k] * b[k][j];
}
/* { dg-final { scan-tree-dump-times "guard hoisted" 2 "unswitch" } } */
/* { dg-do compile } */
/* { dg-options "-O2 -funswitch-loops -fdump-tree-unswitch-details" } */
#include <stdlib.h>
#define N 32
float *foo(int ustride, int size, float *src)
{
float *buffer, *p;
int i, k;
if (!src)
return NULL;
buffer = (float *) malloc(N * size * sizeof(float));
if(buffer)
for(i=0, p=buffer; i<N; i++, src+=ustride)
for(k=0; k<size; k++)
*p++ = src[k];
return buffer;
}
/* { dg-final { scan-tree-dump-times "guard hoisted" 1 "unswitch" } } */
/* { dg-do run } */
/* { dg-options "-O2 -funswitch-loops" } */
#include <stdlib.h>
__attribute__ ((noinline))
void foo (float **a, float **b, float *c, int n, int m, int l)
{
int i,j,k;
float s;
for (i=0; i<l; i++)
for (j=0; j<n; j++)
for (k=0; k<m; k++)
c[i] += a[i][k] * b[k][j];
}
int main()
{
const int N = 32;
float **ar1, **ar2;
float *res;
int i, j;
ar1 = (float **)malloc (N * sizeof (float*));
ar2 = (float **)malloc (N * sizeof (float*));
res = (float *)malloc( N * sizeof (float));
for (i=0; i<N; i++)
{
ar1[i] = (float*)malloc (N * sizeof (float));
ar2[i] = (float*)malloc (N * sizeof (float));
}
for (i=0; i<N; i++)
{
for (j=0; j<N; j++)
{
ar1[i][j] = 2.0f;
ar2[i][j] = 1.5f;
}
res[i] = 0.0f;
}
foo (ar1, ar2, res, N, N, N);
for (i=0; i<N; i++)
if (res[i] != 3072.0f)
abort();
for (i=0; i<N; i++)
res[i] = 0.0f;
foo (ar1, ar2, res, N, 0, N);
for (i=0; i<N; i++)
if (res[i] != 0.0f)
abort();
return 0;
}
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