re PR tree-optimization/44507 (vectorization ANDs array elements together incorrectly)

PR tree-optimization/44507 
	* tree-vect-loop.c (get_initial_def_for_reduction): Use -1
	to build initial vector for BIT_AND_EXPR.
	* tree-vect-slp.c (vect_get_constant_vectors): Likewise.

From-SVN: r160727
This commit is contained in:
Ira Rosen 2010-06-14 12:22:13 +00:00 committed by Ira Rosen
parent 66919db5ac
commit c1e822d590
5 changed files with 75 additions and 2 deletions

View File

@ -1,3 +1,10 @@
2010-06-14 Ira Rosen <irar@il.ibm.com>
PR tree-optimization/44507
* tree-vect-loop.c (get_initial_def_for_reduction): Use -1
to build initial vector for BIT_AND_EXPR.
* tree-vect-slp.c (vect_get_constant_vectors): Likewise.
2010-06-14 Jakub Jelinek <jakub@redhat.com>
* config/s390/s390.md (*mov<mode>_64 DD_DF, mov<mode>): Properly

View File

@ -1,3 +1,8 @@
2010-06-14 Ira Rosen <irar@il.ibm.com>
PR tree-optimization/44507
* gcc.dg/vect/pr44507.c: New test.
2010-06-13 H.J. Lu <hongjiu.lu@intel.com>
* g++.dg/plugin/header_plugin.c: Add "c-family/" to c-common.h

View File

@ -0,0 +1,55 @@
/* { dg-require-effective-target vect_int } */
#include <stdlib.h>
#include "tree-vect.h"
int seeIf256ByteArrayIsConstant(
unsigned char *pArray)
{
int index;
unsigned int curVal, orVal, andVal;
int bytesAreEqual = 0;
if (pArray != 0)
{
for (index = 0, orVal = 0, andVal = 0xFFFFFFFF;
index < 64;
index += (int)sizeof(unsigned int))
{
curVal = *((unsigned long *)(&pArray[index]));
orVal = orVal | curVal;
andVal = andVal & curVal;
}
if (!((orVal == andVal)
&& ((orVal >> 8) == (andVal & 0x00FFFFFF))))
abort ();
}
return 0;
}
int main(int argc, char** argv)
{
unsigned char array1[64] = {
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF, 0xFF,
};
argv = argv;
argc = argc;
check_vect ();
return seeIf256ByteArrayIsConstant(&array1[0]);
}
/* { dg-final { cleanup-tree-dump "vect" } } */

View File

@ -2871,12 +2871,15 @@ get_initial_def_for_reduction (gimple stmt, tree init_val,
*adjustment_def = init_val;
}
if (code == MULT_EXPR || code == BIT_AND_EXPR)
if (code == MULT_EXPR)
{
real_init_val = dconst1;
int_init_val = 1;
}
if (code == BIT_AND_EXPR)
int_init_val = -1;
if (SCALAR_FLOAT_TYPE_P (scalar_type))
def_for_init = build_real (scalar_type, real_init_val);
else

View File

@ -1662,7 +1662,6 @@ vect_get_constant_vectors (slp_tree slp_node, VEC(tree,heap) **vec_oprnds,
break;
case MULT_EXPR:
case BIT_AND_EXPR:
if (SCALAR_FLOAT_TYPE_P (TREE_TYPE (op)))
neutral_op = build_real (TREE_TYPE (op), dconst1);
else
@ -1670,6 +1669,10 @@ vect_get_constant_vectors (slp_tree slp_node, VEC(tree,heap) **vec_oprnds,
break;
case BIT_AND_EXPR:
neutral_op = build_int_cst (TREE_TYPE (op), -1);
break;
default:
neutral_op = NULL;
}