tree-vect-data-refs.c (vect_find_stmt_data_reference): Handle even zero DR_OFFSET...

* tree-vect-data-refs.c (vect_find_stmt_data_reference): Handle
	even zero DR_OFFSET, but DR_BASE_ADDRESS of POINTER_PLUS_EXPR
	containing the offset as possible simd lane access.  Look through
	widening conversion.  Move the
	TREE_CODE (DR_INIT (newdr)) == INTEGER_CST test earlier and reindent.

	* g++.dg/vect/simd-2.cc: Don't xfail, instead expect vectorization on
	x86.
	* g++.dg/vect/simd-5.cc: Likewise.

From-SVN: r272575
This commit is contained in:
Jakub Jelinek 2019-06-21 23:38:35 +02:00 committed by Jakub Jelinek
parent 8924e9dd71
commit c13c129f8f
5 changed files with 61 additions and 31 deletions

View File

@ -1,3 +1,11 @@
2019-06-21 Jakub Jelinek <jakub@redhat.com>
* tree-vect-data-refs.c (vect_find_stmt_data_reference): Handle
even zero DR_OFFSET, but DR_BASE_ADDRESS of POINTER_PLUS_EXPR
containing the offset as possible simd lane access. Look through
widening conversion. Move the
TREE_CODE (DR_INIT (newdr)) == INTEGER_CST test earlier and reindent.
2019-06-21 Richard Biener <rguenther@suse.de>
PR tree-optimization/90930

View File

@ -1,3 +1,9 @@
2019-06-21 Jakub Jelinek <jakub@redhat.com>
* g++.dg/vect/simd-2.cc: Don't xfail, instead expect vectorization on
x86.
* g++.dg/vect/simd-5.cc: Likewise.
2019-06-21 Paolo Carlini <paolo.carlini@oracle.com>
PR c++/90909

View File

@ -1,7 +1,7 @@
// { dg-require-effective-target size32plus }
// { dg-additional-options "-fopenmp-simd" }
// { dg-additional-options "-mavx" { target avx_runtime } }
// { dg-final { scan-tree-dump-times "vectorized \[1-3] loops" 2 "vect" { xfail *-*-* } } }
// { dg-final { scan-tree-dump-times "vectorized \[1-3] loops" 2 "vect" { target i?86-*-* x86_64-*-* } } }
#include "../../gcc.dg/vect/tree-vect.h"

View File

@ -1,7 +1,7 @@
// { dg-require-effective-target size32plus }
// { dg-additional-options "-fopenmp-simd" }
// { dg-additional-options "-mavx" { target avx_runtime } }
// { dg-final { scan-tree-dump-times "vectorized \[1-3] loops" 2 "vect" { xfail *-*-* } } }
// { dg-final { scan-tree-dump-times "vectorized \[1-3] loops" 2 "vect" { target i?86-*-* x86_64-*-* } } }
#include "../../gcc.dg/vect/tree-vect.h"

View File

@ -4072,10 +4072,18 @@ vect_find_stmt_data_reference (loop_p loop, gimple *stmt,
&& DR_OFFSET (newdr)
&& DR_INIT (newdr)
&& DR_STEP (newdr)
&& TREE_CODE (DR_INIT (newdr)) == INTEGER_CST
&& integer_zerop (DR_STEP (newdr)))
{
tree base_address = DR_BASE_ADDRESS (newdr);
tree off = DR_OFFSET (newdr);
tree step = ssize_int (1);
if (integer_zerop (off)
&& TREE_CODE (base_address) == POINTER_PLUS_EXPR)
{
off = TREE_OPERAND (base_address, 1);
base_address = TREE_OPERAND (base_address, 0);
}
STRIP_NOPS (off);
if (TREE_CODE (off) == MULT_EXPR
&& tree_fits_uhwi_p (TREE_OPERAND (off, 1)))
@ -4084,39 +4092,47 @@ vect_find_stmt_data_reference (loop_p loop, gimple *stmt,
off = TREE_OPERAND (off, 0);
STRIP_NOPS (off);
}
if (TREE_CODE (DR_INIT (newdr)) == INTEGER_CST)
if (CONVERT_EXPR_P (off)
&& (TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (off, 0)))
< TYPE_PRECISION (TREE_TYPE (off))))
off = TREE_OPERAND (off, 0);
if (TREE_CODE (off) == SSA_NAME)
{
if (CONVERT_EXPR_P (off)
&& (TYPE_PRECISION (TREE_TYPE (TREE_OPERAND (off, 0)))
< TYPE_PRECISION (TREE_TYPE (off))))
off = TREE_OPERAND (off, 0);
if (TREE_CODE (off) == SSA_NAME)
gimple *def = SSA_NAME_DEF_STMT (off);
/* Look through widening conversion. */
if (is_gimple_assign (def)
&& CONVERT_EXPR_CODE_P (gimple_assign_rhs_code (def)))
{
gimple *def = SSA_NAME_DEF_STMT (off);
tree rhs1 = gimple_assign_rhs1 (def);
if (TREE_CODE (rhs1) == SSA_NAME
&& INTEGRAL_TYPE_P (TREE_TYPE (rhs1))
&& (TYPE_PRECISION (TREE_TYPE (off))
> TYPE_PRECISION (TREE_TYPE (rhs1))))
def = SSA_NAME_DEF_STMT (rhs1);
}
if (is_gimple_call (def)
&& gimple_call_internal_p (def)
&& (gimple_call_internal_fn (def) == IFN_GOMP_SIMD_LANE))
{
tree arg = gimple_call_arg (def, 0);
tree reft = TREE_TYPE (DR_REF (newdr));
if (is_gimple_call (def)
&& gimple_call_internal_p (def)
&& (gimple_call_internal_fn (def) == IFN_GOMP_SIMD_LANE))
gcc_assert (TREE_CODE (arg) == SSA_NAME);
arg = SSA_NAME_VAR (arg);
if (arg == loop->simduid
/* For now. */
&& tree_int_cst_equal (TYPE_SIZE_UNIT (reft), step))
{
tree arg = gimple_call_arg (def, 0);
gcc_assert (TREE_CODE (arg) == SSA_NAME);
arg = SSA_NAME_VAR (arg);
if (arg == loop->simduid
/* For now. */
&& tree_int_cst_equal (TYPE_SIZE_UNIT (reft), step))
{
DR_OFFSET (newdr) = ssize_int (0);
DR_STEP (newdr) = step;
DR_OFFSET_ALIGNMENT (newdr) = BIGGEST_ALIGNMENT;
DR_STEP_ALIGNMENT (newdr)
= highest_pow2_factor (step);
/* Mark as simd-lane access. */
tree arg2 = gimple_call_arg (def, 1);
newdr->aux = (void *) (-1 - tree_to_uhwi (arg2));
free_data_ref (dr);
datarefs->safe_push (newdr);
return opt_result::success ();
}
DR_BASE_ADDRESS (newdr) = base_address;
DR_OFFSET (newdr) = ssize_int (0);
DR_STEP (newdr) = step;
DR_OFFSET_ALIGNMENT (newdr) = BIGGEST_ALIGNMENT;
DR_STEP_ALIGNMENT (newdr) = highest_pow2_factor (step);
/* Mark as simd-lane access. */
tree arg2 = gimple_call_arg (def, 1);
newdr->aux = (void *) (-1 - tree_to_uhwi (arg2));
free_data_ref (dr);
datarefs->safe_push (newdr);
return opt_result::success ();
}
}
}