[68/77] Use scalar_mode for is_int_mode/is_float_mode pairs
authorRichard Sandiford <richard.sandiford@linaro.org>
Wed, 30 Aug 2017 11:19:54 +0000 (11:19 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Wed, 30 Aug 2017 11:19:54 +0000 (11:19 +0000)
This patch uses scalar_mode for code that operates only on MODE_INT
and MODE_FLOAT.

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

gcc/
* omp-expand.c (expand_omp_atomic): Use is_int_mode, is_float_mode
and scalar_mode.
* tree-vect-stmts.c (get_vectype_for_scalar_type_and_size): Likewise.

Co-Authored-By: Alan Hayward <alan.hayward@arm.com>
Co-Authored-By: David Sherwood <david.sherwood@arm.com>
From-SVN: r251519

gcc/ChangeLog
gcc/omp-expand.c
gcc/tree-vect-stmts.c

index 88ed52e..14f379c 100644 (file)
@@ -2,6 +2,14 @@
            Alan Hayward  <alan.hayward@arm.com>
            David Sherwood  <david.sherwood@arm.com>
 
+       * omp-expand.c (expand_omp_atomic): Use is_int_mode, is_float_mode
+       and scalar_mode.
+       * tree-vect-stmts.c (get_vectype_for_scalar_type_and_size): Likewise.
+
+2017-08-30  Richard Sandiford  <richard.sandiford@linaro.org>
+           Alan Hayward  <alan.hayward@arm.com>
+           David Sherwood  <david.sherwood@arm.com>
+
        * fixed-value.h (fixed_from_double_int): Take a scalar_mode
        rather than a machine_mode.
        (fixed_from_string): Likewise.
index ac83ba1..7e27ae0 100644 (file)
@@ -6739,17 +6739,18 @@ expand_omp_atomic (struct omp_region *region)
       if (exact_log2 (align) >= index)
        {
          /* Atomic load.  */
+         scalar_mode smode;
          if (loaded_val == stored_val
-             && (GET_MODE_CLASS (TYPE_MODE (type)) == MODE_INT
-                 || GET_MODE_CLASS (TYPE_MODE (type)) == MODE_FLOAT)
-             && GET_MODE_BITSIZE (TYPE_MODE (type)) <= BITS_PER_WORD
+             && (is_int_mode (TYPE_MODE (type), &smode)
+                 || is_float_mode (TYPE_MODE (type), &smode))
+             && GET_MODE_BITSIZE (smode) <= BITS_PER_WORD
              && expand_omp_atomic_load (load_bb, addr, loaded_val, index))
            return;
 
          /* Atomic store.  */
-         if ((GET_MODE_CLASS (TYPE_MODE (type)) == MODE_INT
-              || GET_MODE_CLASS (TYPE_MODE (type)) == MODE_FLOAT)
-             && GET_MODE_BITSIZE (TYPE_MODE (type)) <= BITS_PER_WORD
+         if ((is_int_mode (TYPE_MODE (type), &smode)
+              || is_float_mode (TYPE_MODE (type), &smode))
+             && GET_MODE_BITSIZE (smode) <= BITS_PER_WORD
              && store_bb == single_succ (load_bb)
              && first_stmt (store_bb) == store
              && expand_omp_atomic_store (load_bb, addr, loaded_val,
index e17918a..b8bf5d2 100644 (file)
@@ -9046,18 +9046,16 @@ static tree
 get_vectype_for_scalar_type_and_size (tree scalar_type, unsigned size)
 {
   tree orig_scalar_type = scalar_type;
-  machine_mode inner_mode = TYPE_MODE (scalar_type);
+  scalar_mode inner_mode;
   machine_mode simd_mode;
-  unsigned int nbytes = GET_MODE_SIZE (inner_mode);
   int nunits;
   tree vectype;
 
-  if (nbytes == 0)
+  if (!is_int_mode (TYPE_MODE (scalar_type), &inner_mode)
+      && !is_float_mode (TYPE_MODE (scalar_type), &inner_mode))
     return NULL_TREE;
 
-  if (GET_MODE_CLASS (inner_mode) != MODE_INT
-      && GET_MODE_CLASS (inner_mode) != MODE_FLOAT)
-    return NULL_TREE;
+  unsigned int nbytes = GET_MODE_SIZE (inner_mode);
 
   /* For vector types of elements whose mode precision doesn't
      match their types precision we use a element type of mode