diff mbox series

[13/nn] More is_a <scalar_int_mode>

Message ID 87d15ew1gz.fsf@linaro.org
State New
Headers show
Series [13/nn] More is_a <scalar_int_mode> | expand

Commit Message

Richard Sandiford Oct. 23, 2017, 11:25 a.m. UTC
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-10-23  Richard Sandiford  <richard.sandiford@linaro.org>
	    Alan Hayward  <alan.hayward@arm.com>
	    David Sherwood  <david.sherwood@arm.com>

gcc/
	* alias.c (find_base_value, find_base_term): Only process integer
	truncations.  Check the precision rather than the size.

Comments

Richard Biener Oct. 26, 2017, 11:59 a.m. UTC | #1
On Mon, Oct 23, 2017 at 1:25 PM, Richard Sandiford
<richard.sandiford@linaro.org> wrote:
> 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.


Ok.

Richard.

>

> 2017-10-23  Richard Sandiford  <richard.sandiford@linaro.org>

>             Alan Hayward  <alan.hayward@arm.com>

>             David Sherwood  <david.sherwood@arm.com>

>

> gcc/

>         * alias.c (find_base_value, find_base_term): Only process integer

>         truncations.  Check the precision rather than the size.

>

> Index: gcc/alias.c

> ===================================================================

> --- gcc/alias.c 2017-10-23 11:41:25.511925516 +0100

> +++ gcc/alias.c 2017-10-23 11:44:27.544693078 +0100

> @@ -1349,6 +1349,7 @@ known_base_value_p (rtx x)

>  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 <scalar_int_mode> (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 <scalar_int_mode> (GET_MODE (x), &int_mode)

> +         || GET_MODE_PRECISION (int_mode) < GET_MODE_PRECISION (Pmode))

>         return 0;

>        /* Fall through.  */

>      case HIGH:
diff mbox series

Patch

Index: gcc/alias.c
===================================================================
--- gcc/alias.c	2017-10-23 11:41:25.511925516 +0100
+++ gcc/alias.c	2017-10-23 11:44:27.544693078 +0100
@@ -1349,6 +1349,7 @@  known_base_value_p (rtx x)
 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 <scalar_int_mode> (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 <scalar_int_mode> (GET_MODE (x), &int_mode)
+	  || GET_MODE_PRECISION (int_mode) < GET_MODE_PRECISION (Pmode))
 	return 0;
       /* Fall through.  */
     case HIGH: