From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 2063) id A2A56385455A; Mon, 5 Dec 2022 05:28:10 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A2A56385455A DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1670218090; bh=AUHGj/ZuBg6C72UlhwuHQ3sy3I6ay8T5MhSNriRrySM=; h=From:To:Subject:Date:From; b=jfCuAKKVY7sfd0p4GG7UBNzqo3MFRaVX3+DVthxJznVgVq7r93s3QnZKpTSWoQW+v RU6TRHrm3A4A7E6iS4ou+vKnh6owNlE1uZGQWfCoSKS0XPk/KXUowU3t0y9F660hW3 +YN+coGn/G1xWvQ/NQmIZC09q8RyBjeA0JhcIkFA= MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="utf-8" From: Kewen Lin To: gcc-cvs@gcc.gnu.org Subject: [gcc r13-4488] gimple-fold: Refine gimple_fold_partial_load_store_mem_ref [PR107412] X-Act-Checkin: gcc X-Git-Author: Kewen Lin X-Git-Refname: refs/heads/master X-Git-Oldrev: 102f3cef568e685d5f65a712f75e0628e3c1733c X-Git-Newrev: 380d62c14c99d8df13b7a86660e7ee67d01ad827 Message-Id: <20221205052810.A2A56385455A@sourceware.org> Date: Mon, 5 Dec 2022 05:28:10 +0000 (GMT) List-Id: https://gcc.gnu.org/g:380d62c14c99d8df13b7a86660e7ee67d01ad827 commit r13-4488-g380d62c14c99d8df13b7a86660e7ee67d01ad827 Author: Kewen Lin Date: Sun Dec 4 23:27:08 2022 -0600 gimple-fold: Refine gimple_fold_partial_load_store_mem_ref [PR107412] Following Richard's review comments, this patch is to use untruncated type for the length used for IFN_LEN_{LOAD,STORE} instead of "unsigned int" for better robustness. It also avoid to use to_constant and tree arithmetic for subtraction. Co-authored-by: Richard Sandiford PR tree-optimization/107412 gcc/ChangeLog: * gimple-fold.cc (gimple_fold_partial_load_store_mem_ref): Use untruncated type for the length, and avoid to_constant and tree arithmetic for subtraction. Diff: --- gcc/gimple-fold.cc | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc index c2d9c806aee..88d14c7adcc 100644 --- a/gcc/gimple-fold.cc +++ b/gcc/gimple-fold.cc @@ -5387,18 +5387,17 @@ gimple_fold_partial_load_store_mem_ref (gcall *call, tree vectype, bool mask_p) tree mask = gimple_call_arg (call, 2); if (!integer_all_onesp (mask)) return NULL_TREE; - } else { + } + else + { tree basic_len = gimple_call_arg (call, 2); - if (!tree_fits_uhwi_p (basic_len)) + if (!poly_int_tree_p (basic_len)) return NULL_TREE; unsigned int nargs = gimple_call_num_args (call); tree bias = gimple_call_arg (call, nargs - 1); - gcc_assert (tree_fits_shwi_p (bias)); - tree biased_len = int_const_binop (MINUS_EXPR, basic_len, bias); - unsigned int len = tree_to_uhwi (biased_len); - unsigned int vect_len - = GET_MODE_SIZE (TYPE_MODE (vectype)).to_constant (); - if (vect_len != len) + gcc_assert (TREE_CODE (bias) == INTEGER_CST); + if (maybe_ne (wi::to_poly_widest (basic_len) - wi::to_widest (bias), + GET_MODE_SIZE (TYPE_MODE (vectype)))) return NULL_TREE; }