From: Jakub Jelinek Date: Fri, 21 Jun 2019 21:38:35 +0000 (+0200) Subject: tree-vect-data-refs.c (vect_find_stmt_data_reference): Handle even zero DR_OFFSET... X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c13c129f8f49b41184f5b1c4b64d76d67db90dae;p=gcc.git 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 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index 06abb6b6c87..5cab32825d1 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,11 @@ +2019-06-21 Jakub Jelinek + + * 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 PR tree-optimization/90930 diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index 14ef07cd1a9..5e94d9a8338 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,9 @@ +2019-06-21 Jakub Jelinek + + * 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 PR c++/90909 diff --git a/gcc/testsuite/g++.dg/vect/simd-2.cc b/gcc/testsuite/g++.dg/vect/simd-2.cc index 3160495761c..6f5737b7e40 100644 --- a/gcc/testsuite/g++.dg/vect/simd-2.cc +++ b/gcc/testsuite/g++.dg/vect/simd-2.cc @@ -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" diff --git a/gcc/testsuite/g++.dg/vect/simd-5.cc b/gcc/testsuite/g++.dg/vect/simd-5.cc index e9755957559..dd817b8888b 100644 --- a/gcc/testsuite/g++.dg/vect/simd-5.cc +++ b/gcc/testsuite/g++.dg/vect/simd-5.cc @@ -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" diff --git a/gcc/tree-vect-data-refs.c b/gcc/tree-vect-data-refs.c index 1a72cffc8d4..20c8815ee93 100644 --- a/gcc/tree-vect-data-refs.c +++ b/gcc/tree-vect-data-refs.c @@ -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))) + { + 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)) { - gimple *def = SSA_NAME_DEF_STMT (off); + 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 (); } } }