diff mbox series

[05/77] Small tweak to array_value_type

Message ID 87k23cn31w.fsf@linaro.org
State New
Headers show
Series Add wrapper classes for machine_modes | expand

Commit Message

Richard Sandiford July 13, 2017, 8:39 a.m. UTC
Store the type mode in a variable so that a later,
more mechanical patch can change its type.

2017-07-13  Richard Sandiford  <richard.sandiford@linaro.org>
	    Alan Hayward  <alan.hayward@arm.com>
	    David Sherwood  <david.sherwood@arm.com>

gcc/
	* tree-switch-conversion.c (array_value_type): Only read TYPE_MODE
	once.  Use get_narrowest_mode instead of GET_CLASS_NARROWEST_MODE.

Comments

Jeff Law Aug. 11, 2017, 5:02 p.m. UTC | #1
On 07/13/2017 02:39 AM, Richard Sandiford wrote:
> Store the type mode in a variable so that a later,

> more mechanical patch can change its type.

> 

> 2017-07-13  Richard Sandiford  <richard.sandiford@linaro.org>

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

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

> 

> gcc/

> 	* tree-switch-conversion.c (array_value_type): Only read TYPE_MODE

> 	once.  Use get_narrowest_mode instead of GET_CLASS_NARROWEST_MODE.

OK.

jeff
diff mbox series

Patch

Index: gcc/tree-switch-conversion.c
===================================================================
--- gcc/tree-switch-conversion.c	2017-06-30 12:50:38.647644058 +0100
+++ gcc/tree-switch-conversion.c	2017-07-13 09:18:22.307345334 +0100
@@ -1034,7 +1034,6 @@  array_value_type (gswitch *swtch, tree t
 {
   unsigned int i, len = vec_safe_length (info->constructors[num]);
   constructor_elt *elt;
-  machine_mode mode;
   int sign = 0;
   tree smaller_type;
 
@@ -1048,8 +1047,9 @@  array_value_type (gswitch *swtch, tree t
   if (!INTEGRAL_TYPE_P (type))
     return type;
 
-  mode = GET_CLASS_NARROWEST_MODE (GET_MODE_CLASS (TYPE_MODE (type)));
-  if (GET_MODE_SIZE (TYPE_MODE (type)) <= GET_MODE_SIZE (mode))
+  machine_mode type_mode = TYPE_MODE (type);
+  machine_mode mode = get_narrowest_mode (type_mode);
+  if (GET_MODE_SIZE (type_mode) <= GET_MODE_SIZE (mode))
     return type;
 
   if (len < (optimize_bb_for_size_p (gimple_bb (swtch)) ? 2 : 32))
@@ -1087,7 +1087,7 @@  array_value_type (gswitch *swtch, tree t
 
 	  mode = GET_MODE_WIDER_MODE (mode);
 	  if (mode == VOIDmode
-	      || GET_MODE_SIZE (mode) >= GET_MODE_SIZE (TYPE_MODE (type)))
+	      || GET_MODE_SIZE (mode) >= GET_MODE_SIZE (type_mode))
 	    return type;
 	}
     }