Fix calculation of ptr_mode for MODE_PARTIAL_INT Pmode

Message ID 87d14a1x5z.fsf@linaro.org
State New
Headers show
Series
  • Fix calculation of ptr_mode for MODE_PARTIAL_INT Pmode
Related show

Commit Message

Richard Sandiford Nov. 22, 2017, 9:26 a.m.
This patch fixes a regression caused by r251469, where I'd incorrectly
converted a call to mode_for_size that sometimes needs MODE_PARTIAL_INTs.

Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64le-linux-gnu.
Also spot-checked on msp430-elf.  OK to install?

Richard


2017-11-22  Richard Sandiford  <richard.sandiford@linaro.org>

gcc/
	* emit-rtl.c (init_derived_machine_modes): Make sure ptr_mode
	has the same mode class as Pmode.

Comments

Richard Biener Nov. 22, 2017, 1:50 p.m. | #1
On Wed, Nov 22, 2017 at 10:26 AM, Richard Sandiford
<richard.sandiford@linaro.org> wrote:
> This patch fixes a regression caused by r251469, where I'd incorrectly

> converted a call to mode_for_size that sometimes needs MODE_PARTIAL_INTs.

>

> Tested on aarch64-linux-gnu, x86_64-linux-gnu and powerpc64le-linux-gnu.

> Also spot-checked on msp430-elf.  OK to install?


Ok.

Richard.

> Richard

>

>

> 2017-11-22  Richard Sandiford  <richard.sandiford@linaro.org>

>

> gcc/

>         * emit-rtl.c (init_derived_machine_modes): Make sure ptr_mode

>         has the same mode class as Pmode.

>

> Index: gcc/emit-rtl.c

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

> --- gcc/emit-rtl.c      2017-11-22 09:21:12.560954668 +0000

> +++ gcc/emit-rtl.c      2017-11-22 09:25:24.200002574 +0000

> @@ -6003,7 +6003,8 @@ init_derived_machine_modes (void)

>

>    byte_mode = opt_byte_mode.require ();

>    word_mode = opt_word_mode.require ();

> -  ptr_mode = int_mode_for_size (POINTER_SIZE, 0).require ();

> +  ptr_mode = as_a <scalar_int_mode>

> +    (mode_for_size (POINTER_SIZE, GET_MODE_CLASS (Pmode), 0).require ());

>  }

>

>  /* Create some permanent unique rtl objects shared between all functions.  */

Patch

Index: gcc/emit-rtl.c
===================================================================
--- gcc/emit-rtl.c	2017-11-22 09:21:12.560954668 +0000
+++ gcc/emit-rtl.c	2017-11-22 09:25:24.200002574 +0000
@@ -6003,7 +6003,8 @@  init_derived_machine_modes (void)
 
   byte_mode = opt_byte_mode.require ();
   word_mode = opt_word_mode.require ();
-  ptr_mode = int_mode_for_size (POINTER_SIZE, 0).require ();
+  ptr_mode = as_a <scalar_int_mode>
+    (mode_for_size (POINTER_SIZE, GET_MODE_CLASS (Pmode), 0).require ());
 }
 
 /* Create some permanent unique rtl objects shared between all functions.  */