diff options
author | Kewen Lin <linkw@linux.ibm.com> | 2022-12-04 23:27:08 -0600 |
---|---|---|
committer | Kewen Lin <linkw@linux.ibm.com> | 2022-12-04 23:27:08 -0600 |
commit | 380d62c14c99d8df13b7a86660e7ee67d01ad827 (patch) | |
tree | 306f2a941297b5561bf14eaff06a8f06a9a55285 | |
parent | 102f3cef568e685d5f65a712f75e0628e3c1733c (diff) | |
download | gcc-380d62c14c99d8df13b7a86660e7ee67d01ad827.zip gcc-380d62c14c99d8df13b7a86660e7ee67d01ad827.tar.gz gcc-380d62c14c99d8df13b7a86660e7ee67d01ad827.tar.bz2 |
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 <richard.sandiford@arm.com>
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.
-rw-r--r-- | gcc/gimple-fold.cc | 15 |
1 files changed, 7 insertions, 8 deletions
diff --git a/gcc/gimple-fold.cc b/gcc/gimple-fold.cc index c2d9c80..88d14c7 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; } |