public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* RFA: Replace LAST_INSN_CODE with NUM_INSN_CODES
       [not found]     ` <55D60EA3.6040708@redhat.com>
@ 2015-08-21 11:27       ` Richard Sandiford
  2015-08-21 13:37         ` Claudiu Zissulescu
  2015-08-21 14:41         ` RFA: " Richard Sandiford
  0 siblings, 2 replies; 4+ messages in thread
From: Richard Sandiford @ 2015-08-21 11:27 UTC (permalink / raw)
  To: gcc-patches
  Cc: Claudiu Zissulescu, Claudiu Zissulescu, Francois Bedard, Jeff Law

Claudiu reported that I'd botched the definition of LAST_INSN_CODE
in my recent patches to reduce the size of insn_data.  I'd defined
it as the last valid insn code, whereas it's supposed to be the
last valid code +1.

This patch replaces LAST_INSN_CODE with a separate NUM_INSN_CODES
count, outside the enum.

Tested on x86_64-linux-gnu and aarch64-linux-gnu.  OK to install?

Thanks,
Richard

gcc/
	* gencodes.c (main): Replace LAST_INSN_CODE with NUM_INSN_CODES.
	* lra.c (insn_code_data): Update accordingly.
	(finish_insn_code_data_once, get_static_insn_data): Likewise.
	* recog.h (target_recog): Likewise.
	(preprocess_insn_constraints): Change parameter to unsigned int.
	* recog.c (preprocess_insn_constraints): Likewise.
	(recog_init): Replace LAST_INSN_CODE with NUM_INSN_CODES.
	* tree-vect-stmts.c (vectorizable_operation): Simplify.

diff --git a/gcc/gencodes.c b/gcc/gencodes.c
index c747891..0635507 100644
--- a/gcc/gencodes.c
+++ b/gcc/gencodes.c
@@ -83,10 +83,10 @@ enum insn_code {\n\
 	break;
     }
 
-  printf ("  LAST_INSN_CODE = %d\n\
-};\n\
+  printf ("};\n\
 \n\
-#endif /* GCC_INSN_CODES_H */\n", get_num_insn_codes () - 1);
+const unsigned int NUM_INSN_CODES = %d;\n\
+#endif /* GCC_INSN_CODES_H */\n", get_num_insn_codes ());
 
   if (ferror (stdout) || fflush (stdout) || fclose (stdout))
     return FATAL_EXIT_CODE;
diff --git a/gcc/lra.c b/gcc/lra.c
index 8ced164..a836cab 100644
--- a/gcc/lra.c
+++ b/gcc/lra.c
@@ -585,7 +585,7 @@ finish_insn_regs (void)
 
 /* Map INSN_CODE -> the static insn data.  This info is valid during
    all translation unit.  */
-struct lra_static_insn_data *insn_code_data[LAST_INSN_CODE];
+struct lra_static_insn_data *insn_code_data[NUM_INSN_CODES];
 
 /* Debug insns are represented as a special insn with one input
    operand which is RTL expression in var_location.  */
@@ -631,9 +631,7 @@ init_insn_code_data_once (void)
 static void
 finish_insn_code_data_once (void)
 {
-  int i;
-
-  for (i = 0; i < LAST_INSN_CODE; i++)
+  for (unsigned int i = 0; i < NUM_INSN_CODES; i++)
     {
       if (insn_code_data[i] != NULL)
 	free (insn_code_data[i]);
@@ -650,7 +648,7 @@ get_static_insn_data (int icode, int nop, int ndup, int nalt)
   struct lra_static_insn_data *data;
   size_t n_bytes;
 
-  lra_assert (icode < LAST_INSN_CODE);
+  lra_assert (icode < (int) NUM_INSN_CODES);
   if (icode >= 0 && (data = insn_code_data[icode]) != NULL)
     return data;
   lra_assert (nop >= 0 && ndup >= 0 && nalt >= 0);
diff --git a/gcc/recog.c b/gcc/recog.c
index 352aec2..c032424 100644
--- a/gcc/recog.c
+++ b/gcc/recog.c
@@ -2441,9 +2441,9 @@ preprocess_constraints (int n_operands, int n_alternatives,
    instruction ICODE.  */
 
 const operand_alternative *
-preprocess_insn_constraints (int icode)
+preprocess_insn_constraints (unsigned int icode)
 {
-  gcc_checking_assert (IN_RANGE (icode, 0, LAST_INSN_CODE));
+  gcc_checking_assert (IN_RANGE (icode, 0, NUM_INSN_CODES - 1));
   if (this_target_recog->x_op_alt[icode])
     return this_target_recog->x_op_alt[icode];
 
@@ -4118,7 +4118,7 @@ recog_init ()
     }
   memset (this_target_recog->x_bool_attr_masks, 0,
 	  sizeof (this_target_recog->x_bool_attr_masks));
-  for (int i = 0; i < LAST_INSN_CODE; ++i)
+  for (unsigned int i = 0; i < NUM_INSN_CODES; ++i)
     if (this_target_recog->x_op_alt[i])
       {
 	free (this_target_recog->x_op_alt[i]);
diff --git a/gcc/recog.h b/gcc/recog.h
index ce931eb..327d6c0 100644
--- a/gcc/recog.h
+++ b/gcc/recog.h
@@ -137,7 +137,7 @@ extern void extract_constrain_insn_cached (rtx_insn *);
 extern void extract_insn_cached (rtx_insn *);
 extern void preprocess_constraints (int, int, const char **,
 				    operand_alternative *);
-extern const operand_alternative *preprocess_insn_constraints (int);
+extern const operand_alternative *preprocess_insn_constraints (unsigned int);
 extern void preprocess_constraints (rtx_insn *);
 extern rtx_insn *peep2_next_insn (int);
 extern int peep2_regno_dead_p (int, int);
@@ -393,8 +393,8 @@ enum bool_attr {
 /* Target-dependent globals.  */
 struct target_recog {
   bool x_initialized;
-  alternative_mask x_bool_attr_masks[LAST_INSN_CODE][BA_LAST + 1];
-  operand_alternative *x_op_alt[LAST_INSN_CODE];
+  alternative_mask x_bool_attr_masks[NUM_INSN_CODES][BA_LAST + 1];
+  operand_alternative *x_op_alt[NUM_INSN_CODES];
 };
 
 extern struct target_recog default_target_recog;
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 2ddd434..f87c066 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -4719,7 +4719,7 @@ vectorizable_operation (gimple stmt, gimple_stmt_iterator *gsi,
   tree new_temp;
   int op_type;
   optab optab;
-  int icode;
+  bool target_support_p;
   tree def;
   gimple def_stmt;
   enum vect_def_type dt[3]
@@ -4870,12 +4870,7 @@ vectorizable_operation (gimple stmt, gimple_stmt_iterator *gsi,
 
   vec_mode = TYPE_MODE (vectype);
   if (code == MULT_HIGHPART_EXPR)
-    {
-      if (can_mult_highpart_p (vec_mode, TYPE_UNSIGNED (vectype)))
-	icode = LAST_INSN_CODE;
-      else
-	icode = CODE_FOR_nothing;
-    }
+    target_support_p = can_mult_highpart_p (vec_mode, TYPE_UNSIGNED (vectype));
   else
     {
       optab = optab_for_tree_code (code, vectype, optab_default);
@@ -4886,10 +4881,11 @@ vectorizable_operation (gimple stmt, gimple_stmt_iterator *gsi,
                              "no optab.\n");
 	  return false;
 	}
-      icode = (int) optab_handler (optab, vec_mode);
+      target_support_p = (optab_handler (optab, vec_mode)
+			  != CODE_FOR_nothing);
     }
 
-  if (icode == CODE_FOR_nothing)
+  if (!target_support_p)
     {
       if (dump_enabled_p ())
 	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: Replace LAST_INSN_CODE with NUM_INSN_CODES
  2015-08-21 11:27       ` RFA: Replace LAST_INSN_CODE with NUM_INSN_CODES Richard Sandiford
@ 2015-08-21 13:37         ` Claudiu Zissulescu
  2015-08-21 14:41         ` RFA: " Richard Sandiford
  1 sibling, 0 replies; 4+ messages in thread
From: Claudiu Zissulescu @ 2015-08-21 13:37 UTC (permalink / raw)
  To: Richard Sandiford, gcc-patches; +Cc: Francois Bedard, Jeff Law

> -----Original Message-----
> From: Richard Sandiford [mailto:richard.sandiford@arm.com]
> Sent: Friday, August 21, 2015 1:15 PM
> To: gcc-patches@gcc.gnu.org
> Cc: Claudiu Zissulescu; Claudiu Zissulescu; Francois Bedard; Jeff Law
> Subject: RFA: Replace LAST_INSN_CODE with NUM_INSN_CODES
> 
> Claudiu reported that I'd botched the definition of LAST_INSN_CODE in my
> recent patches to reduce the size of insn_data.  I'd defined it as the last valid
> insn code, whereas it's supposed to be the last valid code +1.
> 
> This patch replaces LAST_INSN_CODE with a separate NUM_INSN_CODES
> count, outside the enum.
> 
> Tested on x86_64-linux-gnu and aarch64-linux-gnu.  OK to install?
> 
> Thanks,
> Richard
> 
> gcc/
> 	* gencodes.c (main): Replace LAST_INSN_CODE with
> NUM_INSN_CODES.
> 	* lra.c (insn_code_data): Update accordingly.
> 	(finish_insn_code_data_once, get_static_insn_data): Likewise.
> 	* recog.h (target_recog): Likewise.
> 	(preprocess_insn_constraints): Change parameter to unsigned int.
> 	* recog.c (preprocess_insn_constraints): Likewise.
> 	(recog_init): Replace LAST_INSN_CODE with NUM_INSN_CODES.
> 	* tree-vect-stmts.c (vectorizable_operation): Simplify.
> 
> diff --git a/gcc/gencodes.c b/gcc/gencodes.c index c747891..0635507 100644
> --- a/gcc/gencodes.c
> +++ b/gcc/gencodes.c
> @@ -83,10 +83,10 @@ enum insn_code {\n\
>  	break;
>      }
> 
> -  printf ("  LAST_INSN_CODE = %d\n\
> -};\n\
> +  printf ("};\n\
>  \n\
> -#endif /* GCC_INSN_CODES_H */\n", get_num_insn_codes () - 1);
> +const unsigned int NUM_INSN_CODES = %d;\n\ #endif /*
> GCC_INSN_CODES_H
> +*/\n", get_num_insn_codes ());
> 
>    if (ferror (stdout) || fflush (stdout) || fclose (stdout))
>      return FATAL_EXIT_CODE;
> diff --git a/gcc/lra.c b/gcc/lra.c
> index 8ced164..a836cab 100644
> --- a/gcc/lra.c
> +++ b/gcc/lra.c
> @@ -585,7 +585,7 @@ finish_insn_regs (void)
> 
>  /* Map INSN_CODE -> the static insn data.  This info is valid during
>     all translation unit.  */
> -struct lra_static_insn_data *insn_code_data[LAST_INSN_CODE];
> +struct lra_static_insn_data *insn_code_data[NUM_INSN_CODES];
> 
>  /* Debug insns are represented as a special insn with one input
>     operand which is RTL expression in var_location.  */ @@ -631,9 +631,7 @@
> init_insn_code_data_once (void)  static void  finish_insn_code_data_once
> (void)  {
> -  int i;
> -
> -  for (i = 0; i < LAST_INSN_CODE; i++)
> +  for (unsigned int i = 0; i < NUM_INSN_CODES; i++)
>      {
>        if (insn_code_data[i] != NULL)
>  	free (insn_code_data[i]);
> @@ -650,7 +648,7 @@ get_static_insn_data (int icode, int nop, int ndup, int
> nalt)
>    struct lra_static_insn_data *data;
>    size_t n_bytes;
> 
> -  lra_assert (icode < LAST_INSN_CODE);
> +  lra_assert (icode < (int) NUM_INSN_CODES);
>    if (icode >= 0 && (data = insn_code_data[icode]) != NULL)
>      return data;
>    lra_assert (nop >= 0 && ndup >= 0 && nalt >= 0); diff --git a/gcc/recog.c
> b/gcc/recog.c index 352aec2..c032424 100644
> --- a/gcc/recog.c
> +++ b/gcc/recog.c
> @@ -2441,9 +2441,9 @@ preprocess_constraints (int n_operands, int
> n_alternatives,
>     instruction ICODE.  */
> 
>  const operand_alternative *
> -preprocess_insn_constraints (int icode)
> +preprocess_insn_constraints (unsigned int icode)
>  {
> -  gcc_checking_assert (IN_RANGE (icode, 0, LAST_INSN_CODE));
> +  gcc_checking_assert (IN_RANGE (icode, 0, NUM_INSN_CODES - 1));
>    if (this_target_recog->x_op_alt[icode])
>      return this_target_recog->x_op_alt[icode];
> 
> @@ -4118,7 +4118,7 @@ recog_init ()
>      }
>    memset (this_target_recog->x_bool_attr_masks, 0,
>  	  sizeof (this_target_recog->x_bool_attr_masks));
> -  for (int i = 0; i < LAST_INSN_CODE; ++i)
> +  for (unsigned int i = 0; i < NUM_INSN_CODES; ++i)
>      if (this_target_recog->x_op_alt[i])
>        {
>  	free (this_target_recog->x_op_alt[i]); diff --git a/gcc/recog.h
> b/gcc/recog.h index ce931eb..327d6c0 100644
> --- a/gcc/recog.h
> +++ b/gcc/recog.h
> @@ -137,7 +137,7 @@ extern void extract_constrain_insn_cached (rtx_insn
> *);  extern void extract_insn_cached (rtx_insn *);  extern void
> preprocess_constraints (int, int, const char **,
>  				    operand_alternative *);
> -extern const operand_alternative *preprocess_insn_constraints (int);
> +extern const operand_alternative *preprocess_insn_constraints (unsigned
> +int);
>  extern void preprocess_constraints (rtx_insn *);  extern rtx_insn
> *peep2_next_insn (int);  extern int peep2_regno_dead_p (int, int); @@ -
> 393,8 +393,8 @@ enum bool_attr {
>  /* Target-dependent globals.  */
>  struct target_recog {
>    bool x_initialized;
> -  alternative_mask x_bool_attr_masks[LAST_INSN_CODE][BA_LAST + 1];
> -  operand_alternative *x_op_alt[LAST_INSN_CODE];
> +  alternative_mask x_bool_attr_masks[NUM_INSN_CODES][BA_LAST + 1];
> + operand_alternative *x_op_alt[NUM_INSN_CODES];
>  };
> 
>  extern struct target_recog default_target_recog; diff --git a/gcc/tree-vect-
> stmts.c b/gcc/tree-vect-stmts.c index 2ddd434..f87c066 100644
> --- a/gcc/tree-vect-stmts.c
> +++ b/gcc/tree-vect-stmts.c
> @@ -4719,7 +4719,7 @@ vectorizable_operation (gimple stmt,
> gimple_stmt_iterator *gsi,
>    tree new_temp;
>    int op_type;
>    optab optab;
> -  int icode;
> +  bool target_support_p;
>    tree def;
>    gimple def_stmt;
>    enum vect_def_type dt[3]
> @@ -4870,12 +4870,7 @@ vectorizable_operation (gimple stmt,
> gimple_stmt_iterator *gsi,
> 
>    vec_mode = TYPE_MODE (vectype);
>    if (code == MULT_HIGHPART_EXPR)
> -    {
> -      if (can_mult_highpart_p (vec_mode, TYPE_UNSIGNED (vectype)))
> -	icode = LAST_INSN_CODE;
> -      else
> -	icode = CODE_FOR_nothing;
> -    }
> +    target_support_p = can_mult_highpart_p (vec_mode, TYPE_UNSIGNED
> + (vectype));
>    else
>      {
>        optab = optab_for_tree_code (code, vectype, optab_default); @@ -
> 4886,10 +4881,11 @@ vectorizable_operation (gimple stmt,
> gimple_stmt_iterator *gsi,
>                               "no optab.\n");
>  	  return false;
>  	}
> -      icode = (int) optab_handler (optab, vec_mode);
> +      target_support_p = (optab_handler (optab, vec_mode)
> +			  != CODE_FOR_nothing);
>      }
> 
> -  if (icode == CODE_FOR_nothing)
> +  if (!target_support_p)
>      {
>        if (dump_enabled_p ())
>  	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,

Thank you for the quick patch. It fixed the issue observed within ARC backend.

Thanks,
Claudiu

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: RFA: Replace LAST_INSN_CODE with NUM_INSN_CODES
  2015-08-21 11:27       ` RFA: Replace LAST_INSN_CODE with NUM_INSN_CODES Richard Sandiford
  2015-08-21 13:37         ` Claudiu Zissulescu
@ 2015-08-21 14:41         ` Richard Sandiford
  2015-08-21 16:21           ` Jeff Law
  1 sibling, 1 reply; 4+ messages in thread
From: Richard Sandiford @ 2015-08-21 14:41 UTC (permalink / raw)
  To: gcc-patches
  Cc: Claudiu Zissulescu, Claudiu Zissulescu, Francois Bedard, Jeff Law

Richard Sandiford <richard.sandiford@arm.com> writes:
> Claudiu reported that I'd botched the definition of LAST_INSN_CODE
> in my recent patches to reduce the size of insn_data.  I'd defined
> it as the last valid insn code, whereas it's supposed to be the
> last valid code +1.
>
> This patch replaces LAST_INSN_CODE with a separate NUM_INSN_CODES
> count, outside the enum.
>
> Tested on x86_64-linux-gnu and aarch64-linux-gnu.  OK to install?

Sorry, I realised later that this patch triggers a warning with older
host compilers about a trailing "," on the last enum value.  This patch
updates the gencodes.c part to fix that.  The other parts are unchanged.

I think the #defines for removed codes are a hold-over from the days
when CODE_FOR_nothing was the final enum value rather than the first,
amd so was only defined later in the file.  These days we can make them
proper enum aliases instead.

Tested on x86_64-linux-gnu and aarch64-linux-gnu.  OK to install?

Thanks,
Richard

gcc/
	* gencodes.c (gencodes): Print the comma for the preceding
	enum value rather than the current one.  Use aliased enum values
	rather than #defines for compiled-out patterns.
	(main): Update accordingly.  Replace LAST_INSN_CODE with
	NUM_INSN_CODES.
	* lra.c (insn_code_data): Update accordingly.
	(finish_insn_code_data_once, get_static_insn_data): Likewise.
	* recog.h (target_recog): Likewise.
	(preprocess_insn_constraints): Change parameter to unsigned int.
	* recog.c (preprocess_insn_constraints): Likewise.
	(recog_init): Replace LAST_INSN_CODE with NUM_INSN_CODES.
	* tree-vect-stmts.c (vectorizable_operation): Simplify.

diff --git a/gcc/gencodes.c b/gcc/gencodes.c
index c747891..d4560b4 100644
--- a/gcc/gencodes.c
+++ b/gcc/gencodes.c
@@ -40,9 +40,9 @@ gen_insn (md_rtx_info *info)
   if (name[0] != 0 && name[0] != '*')
     {
       if (truth == 0)
-	printf ("#define CODE_FOR_%s CODE_FOR_nothing\n", name);
+	printf (",\n   CODE_FOR_%s = CODE_FOR_nothing", name);
       else
-	printf ("  CODE_FOR_%s = %d,\n", name, info->index);
+	printf (",\n  CODE_FOR_%s = %d", name, info->index);
     }
 }
 
@@ -58,7 +58,7 @@ main (int argc, char **argv)
   if (!init_rtx_reader_args (argc, argv))
     return (FATAL_EXIT_CODE);
 
-  puts ("\
+  printf ("\
 /* Generated automatically by the program `gencodes'\n\
    from the machine description file `md'.  */\n\
 \n\
@@ -66,7 +66,7 @@ main (int argc, char **argv)
 #define GCC_INSN_CODES_H\n\
 \n\
 enum insn_code {\n\
-  CODE_FOR_nothing = 0,\n");
+  CODE_FOR_nothing = 0");
 
   /* Read the machine description.  */
 
@@ -83,10 +83,10 @@ enum insn_code {\n\
 	break;
     }
 
-  printf ("  LAST_INSN_CODE = %d\n\
-};\n\
+  printf ("\n};\n\
 \n\
-#endif /* GCC_INSN_CODES_H */\n", get_num_insn_codes () - 1);
+const unsigned int NUM_INSN_CODES = %d;\n\
+#endif /* GCC_INSN_CODES_H */\n", get_num_insn_codes ());
 
   if (ferror (stdout) || fflush (stdout) || fclose (stdout))
     return FATAL_EXIT_CODE;
diff --git a/gcc/lra.c b/gcc/lra.c
index 8ced164..a836cab 100644
--- a/gcc/lra.c
+++ b/gcc/lra.c
@@ -585,7 +585,7 @@ finish_insn_regs (void)
 
 /* Map INSN_CODE -> the static insn data.  This info is valid during
    all translation unit.  */
-struct lra_static_insn_data *insn_code_data[LAST_INSN_CODE];
+struct lra_static_insn_data *insn_code_data[NUM_INSN_CODES];
 
 /* Debug insns are represented as a special insn with one input
    operand which is RTL expression in var_location.  */
@@ -631,9 +631,7 @@ init_insn_code_data_once (void)
 static void
 finish_insn_code_data_once (void)
 {
-  int i;
-
-  for (i = 0; i < LAST_INSN_CODE; i++)
+  for (unsigned int i = 0; i < NUM_INSN_CODES; i++)
     {
       if (insn_code_data[i] != NULL)
 	free (insn_code_data[i]);
@@ -650,7 +648,7 @@ get_static_insn_data (int icode, int nop, int ndup, int nalt)
   struct lra_static_insn_data *data;
   size_t n_bytes;
 
-  lra_assert (icode < LAST_INSN_CODE);
+  lra_assert (icode < (int) NUM_INSN_CODES);
   if (icode >= 0 && (data = insn_code_data[icode]) != NULL)
     return data;
   lra_assert (nop >= 0 && ndup >= 0 && nalt >= 0);
diff --git a/gcc/recog.c b/gcc/recog.c
index 352aec2..c032424 100644
--- a/gcc/recog.c
+++ b/gcc/recog.c
@@ -2441,9 +2441,9 @@ preprocess_constraints (int n_operands, int n_alternatives,
    instruction ICODE.  */
 
 const operand_alternative *
-preprocess_insn_constraints (int icode)
+preprocess_insn_constraints (unsigned int icode)
 {
-  gcc_checking_assert (IN_RANGE (icode, 0, LAST_INSN_CODE));
+  gcc_checking_assert (IN_RANGE (icode, 0, NUM_INSN_CODES - 1));
   if (this_target_recog->x_op_alt[icode])
     return this_target_recog->x_op_alt[icode];
 
@@ -4118,7 +4118,7 @@ recog_init ()
     }
   memset (this_target_recog->x_bool_attr_masks, 0,
 	  sizeof (this_target_recog->x_bool_attr_masks));
-  for (int i = 0; i < LAST_INSN_CODE; ++i)
+  for (unsigned int i = 0; i < NUM_INSN_CODES; ++i)
     if (this_target_recog->x_op_alt[i])
       {
 	free (this_target_recog->x_op_alt[i]);
diff --git a/gcc/recog.h b/gcc/recog.h
index ce931eb..327d6c0 100644
--- a/gcc/recog.h
+++ b/gcc/recog.h
@@ -137,7 +137,7 @@ extern void extract_constrain_insn_cached (rtx_insn *);
 extern void extract_insn_cached (rtx_insn *);
 extern void preprocess_constraints (int, int, const char **,
 				    operand_alternative *);
-extern const operand_alternative *preprocess_insn_constraints (int);
+extern const operand_alternative *preprocess_insn_constraints (unsigned int);
 extern void preprocess_constraints (rtx_insn *);
 extern rtx_insn *peep2_next_insn (int);
 extern int peep2_regno_dead_p (int, int);
@@ -393,8 +393,8 @@ enum bool_attr {
 /* Target-dependent globals.  */
 struct target_recog {
   bool x_initialized;
-  alternative_mask x_bool_attr_masks[LAST_INSN_CODE][BA_LAST + 1];
-  operand_alternative *x_op_alt[LAST_INSN_CODE];
+  alternative_mask x_bool_attr_masks[NUM_INSN_CODES][BA_LAST + 1];
+  operand_alternative *x_op_alt[NUM_INSN_CODES];
 };
 
 extern struct target_recog default_target_recog;
diff --git a/gcc/tree-vect-stmts.c b/gcc/tree-vect-stmts.c
index 2ddd434..f87c066 100644
--- a/gcc/tree-vect-stmts.c
+++ b/gcc/tree-vect-stmts.c
@@ -4719,7 +4719,7 @@ vectorizable_operation (gimple stmt, gimple_stmt_iterator *gsi,
   tree new_temp;
   int op_type;
   optab optab;
-  int icode;
+  bool target_support_p;
   tree def;
   gimple def_stmt;
   enum vect_def_type dt[3]
@@ -4870,12 +4870,7 @@ vectorizable_operation (gimple stmt, gimple_stmt_iterator *gsi,
 
   vec_mode = TYPE_MODE (vectype);
   if (code == MULT_HIGHPART_EXPR)
-    {
-      if (can_mult_highpart_p (vec_mode, TYPE_UNSIGNED (vectype)))
-	icode = LAST_INSN_CODE;
-      else
-	icode = CODE_FOR_nothing;
-    }
+    target_support_p = can_mult_highpart_p (vec_mode, TYPE_UNSIGNED (vectype));
   else
     {
       optab = optab_for_tree_code (code, vectype, optab_default);
@@ -4886,10 +4881,11 @@ vectorizable_operation (gimple stmt, gimple_stmt_iterator *gsi,
                              "no optab.\n");
 	  return false;
 	}
-      icode = (int) optab_handler (optab, vec_mode);
+      target_support_p = (optab_handler (optab, vec_mode)
+			  != CODE_FOR_nothing);
     }
 
-  if (icode == CODE_FOR_nothing)
+  if (!target_support_p)
     {
       if (dump_enabled_p ())
 	dump_printf_loc (MSG_MISSED_OPTIMIZATION, vect_location,

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: RFA: Replace LAST_INSN_CODE with NUM_INSN_CODES
  2015-08-21 14:41         ` RFA: " Richard Sandiford
@ 2015-08-21 16:21           ` Jeff Law
  0 siblings, 0 replies; 4+ messages in thread
From: Jeff Law @ 2015-08-21 16:21 UTC (permalink / raw)
  To: gcc-patches, Claudiu Zissulescu, Claudiu Zissulescu,
	Francois Bedard, richard.sandiford

On 08/21/2015 08:36 AM, Richard Sandiford wrote:
> Richard Sandiford <richard.sandiford@arm.com> writes:
>> Claudiu reported that I'd botched the definition of LAST_INSN_CODE
>> in my recent patches to reduce the size of insn_data.  I'd defined
>> it as the last valid insn code, whereas it's supposed to be the
>> last valid code +1.
>>
>> This patch replaces LAST_INSN_CODE with a separate NUM_INSN_CODES
>> count, outside the enum.
>>
>> Tested on x86_64-linux-gnu and aarch64-linux-gnu.  OK to install?
>
> Sorry, I realised later that this patch triggers a warning with older
> host compilers about a trailing "," on the last enum value.  This patch
> updates the gencodes.c part to fix that.  The other parts are unchanged.
>
> I think the #defines for removed codes are a hold-over from the days
> when CODE_FOR_nothing was the final enum value rather than the first,
> amd so was only defined later in the file.  These days we can make them
> proper enum aliases instead.
>
> Tested on x86_64-linux-gnu and aarch64-linux-gnu.  OK to install?
>
> Thanks,
> Richard
>
> gcc/
> 	* gencodes.c (gencodes): Print the comma for the preceding
> 	enum value rather than the current one.  Use aliased enum values
> 	rather than #defines for compiled-out patterns.
> 	(main): Update accordingly.  Replace LAST_INSN_CODE with
> 	NUM_INSN_CODES.
> 	* lra.c (insn_code_data): Update accordingly.
> 	(finish_insn_code_data_once, get_static_insn_data): Likewise.
> 	* recog.h (target_recog): Likewise.
> 	(preprocess_insn_constraints): Change parameter to unsigned int.
> 	* recog.c (preprocess_insn_constraints): Likewise.
> 	(recog_init): Replace LAST_INSN_CODE with NUM_INSN_CODES.
> 	* tree-vect-stmts.c (vectorizable_operation): Simplify.
OK.  Thanks for taking care of this.

Jeff

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2015-08-21 16:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <098ECE41A0A6114BB2A07F1EC238DE8965C6756D@de02wembxa.internal.synopsys.com>
     [not found] ` <55D6064F.40505@redhat.com>
     [not found]   ` <CAL0iMy3Sp=AVybZqCJCBTXnvWjX4+SNBCnzWhFNwHeUc0D_bYQ@mail.gmail.com>
     [not found]     ` <55D60EA3.6040708@redhat.com>
2015-08-21 11:27       ` RFA: Replace LAST_INSN_CODE with NUM_INSN_CODES Richard Sandiford
2015-08-21 13:37         ` Claudiu Zissulescu
2015-08-21 14:41         ` RFA: " Richard Sandiford
2015-08-21 16:21           ` Jeff Law

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).