re PR target/77478 (Incorrect code generated with -O3, m32, -msse2 and -ffast-math)

2016-09-27  Richard Biener  <rguenther@suse.de>

	PR tree-optimization/77478
	* tree-vect-loop-manip.c (vect_gen_niters_for_prolog_loop):
	Fix alignment of SSA var used before the alignment prologue.

	* gcc.dg/torture/pr77478.c: New testcase.

From-SVN: r240532
This commit is contained in:
Richard Biener 2016-09-27 12:44:42 +00:00 committed by Richard Biener
parent 5cec3f42a3
commit 4cbf07a7c6
4 changed files with 34 additions and 1 deletions

View File

@ -1,3 +1,9 @@
2016-09-27 Richard Biener <rguenther@suse.de>
PR tree-optimization/77478
* tree-vect-loop-manip.c (vect_gen_niters_for_prolog_loop):
Fix alignment of SSA var used before the alignment prologue.
2016-09-27 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>
Backport from trunk r227496

View File

@ -1,3 +1,8 @@
2016-09-27 Richard Biener <rguenther@suse.de>
PR tree-optimization/77478
* gcc.dg/torture/pr77478.c: New testcase.
2016-09-27 Senthil Kumar Selvaraj <senthil_kumar.selvaraj@atmel.com>
Backport from trunk r227496

View File

@ -0,0 +1,22 @@
/* { dg-do run } */
/* { dg-additional-options "-ffast-math" } */
static const float A[10] = {1};
float
foo(float *f, int n)
{
int i, j;
float a = 0, b = 0;
for (i = n/2; i < n; i++)
a += f[i]*.1f;
for (i = n/2, j = 0; i < n; i++, j++)
b += f[i]*A[j]+a*A[j];
return b;
}
int main()
{
float a[21] = {0};
return foo(a+1, 20) + foo(a, 20);
}

View File

@ -1886,7 +1886,7 @@ vect_gen_niters_for_prolog_loop (loop_vec_info loop_vinfo, tree loop_niters, int
gimple_seq new_stmts = NULL;
bool negative = tree_int_cst_compare (DR_STEP (dr), size_zero_node) < 0;
tree offset = negative
? size_int (-TYPE_VECTOR_SUBPARTS (vectype) + 1) : NULL_TREE;
? size_int (-TYPE_VECTOR_SUBPARTS (vectype) + 1) : size_zero_node;
tree start_addr = vect_create_addr_base_for_vector_ref (dr_stmt,
&new_stmts, offset, loop);
tree type = unsigned_type_for (TREE_TYPE (start_addr));