From: Richard Sandiford Date: Wed, 1 Nov 2017 13:33:18 +0000 (+0000) Subject: More is_a X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=6645d84173dfc7a7bfa389db1e2359cd78fe7182;p=gcc.git More is_a alias.c:find_base_term and find_base_value checked: if (GET_MODE_SIZE (GET_MODE (src)) < GET_MODE_SIZE (Pmode)) but (a) comparing the precision seems more correct, since it's possible for modes to have the same memory size as Pmode but fewer bits and (b) the functions are called on arbitrary rtl, so there's no guarantee that we're handling an integer truncation. Since there's no point processing truncations of anything other than an integer, this patch checks that first. 2017-11-01 Richard Sandiford Alan Hayward David Sherwood gcc/ * alias.c (find_base_value, find_base_term): Only process integer truncations. Check the precision rather than the size. Co-Authored-By: Alan Hayward Co-Authored-By: David Sherwood From-SVN: r254306 --- diff --git a/gcc/ChangeLog b/gcc/ChangeLog index b9b5ddd75b3..209219cc8f6 100644 --- a/gcc/ChangeLog +++ b/gcc/ChangeLog @@ -1,3 +1,10 @@ +2017-11-01 Richard Sandiford + Alan Hayward + David Sherwood + + * alias.c (find_base_value, find_base_term): Only process integer + truncations. Check the precision rather than the size. + 2017-11-01 Richard Sandiford Alan Hayward David Sherwood diff --git a/gcc/alias.c b/gcc/alias.c index cb57c6a10ff..a02eadcaea8 100644 --- a/gcc/alias.c +++ b/gcc/alias.c @@ -1349,6 +1349,7 @@ static rtx find_base_value (rtx src) { unsigned int regno; + scalar_int_mode int_mode; #if defined (FIND_BASE_TERM) /* Try machine-dependent ways to find the base term. */ @@ -1475,7 +1476,8 @@ find_base_value (rtx src) address modes depending on the address space. */ if (!target_default_pointer_address_modes_p ()) break; - if (GET_MODE_SIZE (GET_MODE (src)) < GET_MODE_SIZE (Pmode)) + if (!is_a (GET_MODE (src), &int_mode) + || GET_MODE_PRECISION (int_mode) < GET_MODE_PRECISION (Pmode)) break; /* Fall through. */ case HIGH: @@ -1876,6 +1878,7 @@ find_base_term (rtx x) cselib_val *val; struct elt_loc_list *l, *f; rtx ret; + scalar_int_mode int_mode; #if defined (FIND_BASE_TERM) /* Try machine-dependent ways to find the base term. */ @@ -1893,7 +1896,8 @@ find_base_term (rtx x) address modes depending on the address space. */ if (!target_default_pointer_address_modes_p ()) return 0; - if (GET_MODE_SIZE (GET_MODE (x)) < GET_MODE_SIZE (Pmode)) + if (!is_a (GET_MODE (x), &int_mode) + || GET_MODE_PRECISION (int_mode) < GET_MODE_PRECISION (Pmode)) return 0; /* Fall through. */ case HIGH: