From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1666) id 3A4823857C69; Mon, 7 Dec 2020 07:15:29 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 3A4823857C69 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Richard Biener To: gcc-cvs@gcc.gnu.org Subject: [gcc r11-5809] tree-optimization/98137 - enhance split_constant_offset range handling X-Act-Checkin: gcc X-Git-Author: Richard Biener X-Git-Refname: refs/heads/master X-Git-Oldrev: 0e49145550fe1284dc56e8e02ba1720c4f737a74 X-Git-Newrev: 7b4ea2827d2003c8ffc76cd478f8974360cbd78f Message-Id: <20201207071529.3A4823857C69@sourceware.org> Date: Mon, 7 Dec 2020 07:15:29 +0000 (GMT) X-BeenThere: gcc-cvs@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 07 Dec 2020 07:15:29 -0000 https://gcc.gnu.org/g:7b4ea2827d2003c8ffc76cd478f8974360cbd78f commit r11-5809-g7b4ea2827d2003c8ffc76cd478f8974360cbd78f Author: Richard Biener Date: Fri Dec 4 11:13:48 2020 +0100 tree-optimization/98137 - enhance split_constant_offset range handling split_constant_offset currently gives up looking at ranges when dealing with possibly wrapping operations for looking through conversions when the downstream analysis does not yield a SSA name. That's overly conservative and we have a nice helper that can deal with arbitrary expresssions. Use that. This helps data reference group analysis so the testcase is fully SLP vectorized, making use of the whole-function "BB" vectorization capabilities we now have. 2020-12-04 Richard Biener PR tree-optimization/98137 * tree-data-ref.c (split_constant_offset_1): Use determine_value_range instead of get_range_info to handle arbitrary expressions. * gcc.dg/vect/bb-slp-pr98137.c: New testcase. Diff: --- gcc/testsuite/gcc.dg/vect/bb-slp-pr98137.c | 27 +++++++++++++++++++++++++++ gcc/tree-data-ref.c | 24 ++++++++++++++---------- 2 files changed, 41 insertions(+), 10 deletions(-) diff --git a/gcc/testsuite/gcc.dg/vect/bb-slp-pr98137.c b/gcc/testsuite/gcc.dg/vect/bb-slp-pr98137.c new file mode 100644 index 00000000000..ecf7df21e6a --- /dev/null +++ b/gcc/testsuite/gcc.dg/vect/bb-slp-pr98137.c @@ -0,0 +1,27 @@ +/* { dg-do compile } */ +/* { dg-additional-options "-O3" } */ +/* { dg-require-effective-target vect_double } */ + +void +gemm (const double* __restrict__ A, const double* __restrict__ B, + double* __restrict__ C) +{ + unsigned int l_m = 0; + unsigned int l_n = 0; + unsigned int l_k = 0; + + for ( l_n = 0; l_n < 9; l_n++ ) { + /* Use -O3 so this loop is unrolled completely early. */ + for ( l_m = 0; l_m < 10; l_m++ ) { C[(l_n*10)+l_m] = 0.0; } + for ( l_k = 0; l_k < 17; l_k++ ) { + /* Use -O3 so this loop is unrolled completely early. */ + for ( l_m = 0; l_m < 10; l_m++ ) { + C[(l_n*10)+l_m] += A[(l_k*20)+l_m] * B[(l_n*20)+l_k]; + } + } + } +} + +/* Exact scanning is difficult but we expect all loads and stores + and computations to be vectorized. */ +/* { dg-final { scan-tree-dump "optimized: basic block" "slp1" } } */ diff --git a/gcc/tree-data-ref.c b/gcc/tree-data-ref.c index 3bf460cccfd..e8308ce8250 100644 --- a/gcc/tree-data-ref.c +++ b/gcc/tree-data-ref.c @@ -763,18 +763,22 @@ split_constant_offset_1 (tree type, tree op0, enum tree_code code, tree op1, tree tmp_var, tmp_off; split_constant_offset (op0, &tmp_var, &tmp_off, cache, limit); - /* See whether we have an SSA_NAME whose range is known - to be [A, B]. */ - if (TREE_CODE (tmp_var) != SSA_NAME) - return false; + /* See whether we have an known range [A, B] for tmp_var. */ wide_int var_min, var_max; - value_range_kind vr_type = get_range_info (tmp_var, &var_min, - &var_max); - wide_int var_nonzero = get_nonzero_bits (tmp_var); signop sgn = TYPE_SIGN (itype); - if (intersect_range_with_nonzero_bits (vr_type, &var_min, - &var_max, var_nonzero, - sgn) != VR_RANGE) + if (TREE_CODE (tmp_var) == SSA_NAME) + { + value_range_kind vr_type + = get_range_info (tmp_var, &var_min, &var_max); + wide_int var_nonzero = get_nonzero_bits (tmp_var); + if (intersect_range_with_nonzero_bits (vr_type, &var_min, + &var_max, + var_nonzero, + sgn) != VR_RANGE) + return false; + } + else if (determine_value_range (tmp_var, &var_min, &var_max) + != VR_RANGE) return false; /* See whether the range of OP0 (i.e. TMP_VAR + TMP_OFF)