[FORTRAN,11/29] Do pointer comparison instead of strcmp
diff mbox series

Message ID 20180905145732.404-12-rep.dot.nop@gmail.com
State New
Headers show
Series
  • [FORTRAN,01/29] gdbinit: break on gfc_internal_error
Related show

Commit Message

Bernhard Reutner-Fischer Sept. 5, 2018, 2:57 p.m. UTC
From: Bernhard Reutner-Fischer <aldot@gcc.gnu.org>

This gets rid of some of the str[n]*cmp in favour of (faster) pointer
equality checks.

gcc/fortran/ChangeLog:

2017-11-02  Bernhard Reutner-Fischer  <aldot@gcc.gnu.org>

	* check.c (gfc_check_move_alloc): Use pointer comparison instead
	of strcmp.
	* class.c (find_intrinsic_vtab): Likewise.
	* decl.c (find_special, check_function_name, variable_decl,
	insert_parameter_exprs, gfc_get_pdt_instance,
	gfc_match_formal_arglist, match_result, add_hidden_procptr_result,
	add_global_entry, gfc_match_end): Likewise.
	* interface.c (gfc_match_end_interface, compare_components,
	gfc_compare_derived_types, find_keyword_arg, count_types_test,
	generic_correspondence, compare_actual_formal,
	gfc_check_typebound_override): Likewise.
	* match.c (gfc_match_else, gfc_match_elseif, match_case_eos,
	gfc_match_elsewhere): Likewise.
	* openmp.c (gfc_match_oacc_routine, match_udr_expr,
	gfc_omp_udr_find): Likewise.
	* parse.c (match_deferred_characteristics,
	parse_omp_structured_block, add_global_procedure): Likewise.
	* resolve.c (check_proc_interface, resolve_formal_arglist,
	resolve_contained_fntype, resolve_common_blocks,
	count_specific_procs, not_entry_self_reference,
	resolve_global_procedure, resolve_select_type,
	gfc_verify_binding_labels, build_init_assign, compare_fsyms,
	resolve_typebound_procedure, resolve_component): Likewise.
	* symbol.c (gfc_add_component, gfc_find_component): Likewise.
	* trans-array.c (structure_alloc_comps): Likewise.
	* trans-decl.c (gfc_get_extern_function_decl, build_entry_thunks,
	gfc_get_fake_result_decl, struct module_hasher,
	module_decl_hasher::equal, gfc_trans_use_stmts,
	generate_local_decl): Likewise.
	* trans-expr.c (conv_parent_component_references,
	gfc_conv_procedure_call): Likewise.
	* module.c (mio_namelist, find_symbol, load_omp_udrs,
	read_module): Likewise.
---
 gcc/fortran/check.c       |  2 +-
 gcc/fortran/class.c       |  2 +-
 gcc/fortran/decl.c        | 31 +++++++++++++++---------------
 gcc/fortran/interface.c   | 34 ++++++++++++++++-----------------
 gcc/fortran/match.c       |  8 ++++----
 gcc/fortran/module.c      | 17 ++++++++---------
 gcc/fortran/openmp.c      |  7 +++----
 gcc/fortran/parse.c       | 10 ++++------
 gcc/fortran/resolve.c     | 40 +++++++++++++++++++--------------------
 gcc/fortran/symbol.c      |  6 +++---
 gcc/fortran/trans-array.c |  4 ++--
 gcc/fortran/trans-decl.c  | 24 +++++++++++------------
 gcc/fortran/trans-expr.c  |  7 +++----
 13 files changed, 91 insertions(+), 101 deletions(-)

Patch
diff mbox series

diff --git a/gcc/fortran/check.c b/gcc/fortran/check.c
index 30214fef4c7..cb18a3af519 100644
--- a/gcc/fortran/check.c
+++ b/gcc/fortran/check.c
@@ -3566,7 +3566,7 @@  gfc_check_move_alloc (gfc_expr *from, gfc_expr *to)
       of reflection reveals that this can only occur for derived types
       with recursive allocatable components.  */
   if (to->expr_type == EXPR_VARIABLE && from->expr_type == EXPR_VARIABLE
-      && !strcmp (to->symtree->n.sym->name, from->symtree->n.sym->name))
+      && to->symtree->n.sym->name == from->symtree->n.sym->name)
     {
       gfc_ref *to_ref, *from_ref;
       to_ref = to->ref;
diff --git a/gcc/fortran/class.c b/gcc/fortran/class.c
index 2eae7f0f351..8e637689fae 100644
--- a/gcc/fortran/class.c
+++ b/gcc/fortran/class.c
@@ -2736,7 +2736,7 @@  find_intrinsic_vtab (gfc_typespec *ts)
 		  contained = ns->contained;
 		  for (; contained; contained = contained->sibling)
 		    if (contained->proc_name
-			&& strcmp (name, contained->proc_name->name) == 0)
+			&& name == contained->proc_name->name)
 		      {
 			copy = contained->proc_name;
 			goto got_char_copy;
diff --git a/gcc/fortran/decl.c b/gcc/fortran/decl.c
index b0c45b88505..2baa1783434 100644
--- a/gcc/fortran/decl.c
+++ b/gcc/fortran/decl.c
@@ -1118,7 +1118,7 @@  find_special (const char *name, gfc_symbol **result, bool allow_subroutine)
   if (s->sym == NULL)
     goto end;		  /* Nameless interface.  */
 
-  if (strcmp (name, s->sym->name) == 0)
+  if (name == s->sym->name)
     {
       *result = s->sym;
       return 0;
@@ -2273,7 +2273,7 @@  check_function_name (const char *name)
       gfc_symbol *block = gfc_current_block ();
       if (block && block->result && block->result != block
 	  && strcmp (block->result->name, "ppr@") != 0
-	  && strcmp (block->name, name) == 0)
+	  && block->name == name)
 	{
 	  gfc_error ("RESULT variable %qs at %L prohibits FUNCTION name %qs at %C "
 		     "from appearing in a specification statement",
@@ -2583,11 +2583,11 @@  variable_decl (int elem)
   /* Procedure pointer as function result.  */
   if (gfc_current_state () == COMP_FUNCTION
       && strcmp ("ppr@", gfc_current_block ()->name) == 0
-      && strcmp (name, gfc_current_block ()->ns->proc_name->name) == 0)
+      && name == gfc_current_block ()->ns->proc_name->name)
     name = gfc_get_string ("%s", "ppr@");
 
   if (gfc_current_state () == COMP_FUNCTION
-      && strcmp (name, gfc_current_block ()->name) == 0
+      && name == gfc_current_block ()->name
       && gfc_current_block ()->result
       && strcmp ("ppr@", gfc_current_block ()->result->name) == 0)
     name = gfc_get_string ("%s", "ppr@");
@@ -3359,7 +3359,7 @@  insert_parameter_exprs (gfc_expr* e, gfc_symbol* sym ATTRIBUTE_UNUSED,
       || (*f != 0 && e->symtree->n.sym->attr.pdt_len))
     {
       for (param = type_param_spec_list; param; param = param->next)
-	if (strcmp (e->symtree->n.sym->name, param->name) == 0)
+	if (e->symtree->n.sym->name == param->name)
 	  break;
 
       if (param)
@@ -3483,7 +3483,7 @@  gfc_get_pdt_instance (gfc_actual_arglist *param_list, gfc_symbol **sym,
 	  actual_param = param_list;
 	  for (;actual_param; actual_param = actual_param->next)
 	    if (actual_param->name
-	        && strcmp (actual_param->name, param->name) == 0)
+	        && actual_param->name == param->name)
 	      break;
 	  if (actual_param && actual_param->spec_type == SPEC_EXPLICIT)
 	    kind_expr = gfc_copy_expr (actual_param->expr);
@@ -6215,7 +6215,7 @@  gfc_match_formal_arglist (gfc_symbol *progname, int st_flag,
 	 so check for it explicitly.  After the statement is accepted,
 	 the name is checked for especially in gfc_get_symbol().  */
       if (gfc_new_block != NULL && sym != NULL && !typeparam
-	  && strcmp (sym->name, gfc_new_block->name) == 0)
+	  && sym->name == gfc_new_block->name)
 	{
 	  gfc_error ("Name %qs at %C is the name of the procedure",
 		     sym->name);
@@ -6290,7 +6290,7 @@  ok:
 	      || (p->next == NULL && q->next != NULL))
 	    arg_count_mismatch = true;
 	  else if ((p->sym == NULL && q->sym == NULL)
-		    || strcmp (p->sym->name, q->sym->name) == 0)
+		    || p->sym->name == q->sym->name)
 	    continue;
 	  else
 	    gfc_error_now ("Mismatch in MODULE PROCEDURE formal "
@@ -6336,7 +6336,7 @@  match_result (gfc_symbol *function, gfc_symbol **result)
       return MATCH_ERROR;
     }
 
-  if (strcmp (function->name, name) == 0)
+  if (function->name == name)
     {
       gfc_error ("RESULT variable at %C must be different than function name");
       return MATCH_ERROR;
@@ -6451,12 +6451,12 @@  add_hidden_procptr_result (gfc_symbol *sym)
 
   /* First usage case: PROCEDURE and EXTERNAL statements.  */
   case1 = gfc_current_state () == COMP_FUNCTION && gfc_current_block ()
-	  && strcmp (gfc_current_block ()->name, sym->name) == 0
+	  && gfc_current_block ()->name == sym->name
 	  && sym->attr.external;
   /* Second usage case: INTERFACE statements.  */
   case2 = gfc_current_state () == COMP_INTERFACE && gfc_state_stack->previous
 	  && gfc_state_stack->previous->state == COMP_FUNCTION
-	  && strcmp (gfc_state_stack->previous->sym->name, sym->name) == 0;
+	  && gfc_state_stack->previous->sym->name == sym->name;
 
   if (case1 || case2)
     {
@@ -7148,7 +7148,7 @@  add_global_entry (const char *name, const char *binding_label, bool sub,
   /* Don't add the symbol multiple times.  */
   if (binding_label
       && (!gfc_notification_std (GFC_STD_F2008)
-	  || strcmp (name, binding_label) != 0))
+	  || name != binding_label))
     {
       s = gfc_get_gsymbol (binding_label);
 
@@ -8044,9 +8044,8 @@  gfc_match_end (gfc_statement *st)
   /* We have to pick out the declared submodule name from the composite
      required by F2008:11.2.3 para 2, which ends in the declared name.  */
   if (state == COMP_SUBMODULE)
-    block_name = strchr (block_name, '.') + 1;
-
-  if (strcmp (name, block_name) != 0 && strcmp (block_name, "ppr@") != 0)
+    block_name = gfc_get_string ("%s", strchr (block_name, '.') + 1);
+  if (name != block_name && strcmp (block_name, "ppr@") != 0)
     {
       gfc_error ("Expected label %qs for %s statement at %C", block_name,
 		 gfc_ascii_statement (*st));
@@ -8054,7 +8053,7 @@  gfc_match_end (gfc_statement *st)
     }
   /* Procedure pointer as function result.  */
   else if (strcmp (block_name, "ppr@") == 0
-	   && strcmp (name, gfc_current_block ()->ns->proc_name->name) != 0)
+	   && name != gfc_current_block ()->ns->proc_name->name)
     {
       gfc_error ("Expected label %qs for %s statement at %C",
 		 gfc_current_block ()->ns->proc_name->name,
diff --git a/gcc/fortran/interface.c b/gcc/fortran/interface.c
index 8716813b7b2..d18590da331 100644
--- a/gcc/fortran/interface.c
+++ b/gcc/fortran/interface.c
@@ -411,7 +411,7 @@  gfc_match_end_interface (void)
       /* Comparing the symbol node names is OK because only use-associated
 	 symbols can be renamed.  */
       if (type != current_interface.type
-	  || strcmp (current_interface.uop->name, name) != 0)
+	  || current_interface.uop->name != name)
 	{
 	  gfc_error ("Expecting %<END INTERFACE OPERATOR (.%s.)%> at %C",
 		     current_interface.uop->name);
@@ -423,7 +423,7 @@  gfc_match_end_interface (void)
     case INTERFACE_DTIO:
     case INTERFACE_GENERIC:
       if (type != current_interface.type
-	  || strcmp (current_interface.sym->name, name) != 0)
+	  || current_interface.sym->name != name)
 	{
 	  gfc_error ("Expecting %<END INTERFACE %s%> at %C",
 		     current_interface.sym->name);
@@ -476,7 +476,7 @@  compare_components (gfc_component *cmp1, gfc_component *cmp2,
 {
   /* Compare names, but not for anonymous components such as UNION or MAP.  */
   if (!is_anonymous_component (cmp1) && !is_anonymous_component (cmp2)
-      && strcmp (cmp1->name, cmp2->name) != 0)
+      && cmp1->name != cmp2->name)
     return false;
 
   if (cmp1->attr.access != cmp2->attr.access)
@@ -624,9 +624,9 @@  gfc_compare_derived_types (gfc_symbol *derived1, gfc_symbol *derived2)
   /* Special case for comparing derived types across namespaces.  If the
      true names and module names are the same and the module name is
      nonnull, then they are equal.  */
-  if (strcmp (derived1->name, derived2->name) == 0
+  if (derived1->name == derived2->name
       && derived1->module != NULL && derived2->module != NULL
-      && strcmp (derived1->module, derived2->module) == 0)
+      && derived1->module == derived2->module)
     return true;
 
   /* Compare type via the rules of the standard.  Both types must have
@@ -636,7 +636,7 @@  gfc_compare_derived_types (gfc_symbol *derived1, gfc_symbol *derived2)
 
   /* Compare names, but not for anonymous types such as UNION or MAP.  */
   if (!is_anonymous_dt (derived1) && !is_anonymous_dt (derived2)
-      && strcmp (derived1->name, derived2->name) != 0)
+      && derived1->name != derived2->name)
     return false;
 
   if (derived1->component_access == ACCESS_PRIVATE
@@ -839,7 +839,7 @@  static gfc_symbol *
 find_keyword_arg (const char *name, gfc_formal_arglist *f)
 {
   for (; f; f = f->next)
-    if (strcmp (f->sym->name, name) == 0)
+    if (f->sym->name == name)
       return f->sym;
 
   return NULL;
@@ -1140,7 +1140,7 @@  count_types_test (gfc_formal_arglist *f1, gfc_formal_arglist *f2,
 	continue;
 
       if (arg[i].sym && (arg[i].sym->attr.optional
-			 || (p1 && strcmp (arg[i].sym->name, p1) == 0)))
+			 || (p1 && arg[i].sym->name == p1)))
 	continue;		/* Skip OPTIONAL and PASS arguments.  */
 
       arg[i].flag = k;
@@ -1149,7 +1149,7 @@  count_types_test (gfc_formal_arglist *f1, gfc_formal_arglist *f2,
       for (j = i + 1; j < n1; j++)
 	if ((arg[j].sym == NULL
 	     || !(arg[j].sym->attr.optional
-		  || (p1 && strcmp (arg[j].sym->name, p1) == 0)))
+		  || (p1 && arg[j].sym->name == p1)))
 	    && (compare_type_rank_if (arg[i].sym, arg[j].sym)
 	        || compare_type_rank_if (arg[j].sym, arg[i].sym)))
 	  arg[j].flag = k;
@@ -1176,7 +1176,7 @@  count_types_test (gfc_formal_arglist *f1, gfc_formal_arglist *f2,
       ac2 = 0;
 
       for (f = f2; f; f = f->next)
-	if ((!p2 || strcmp (f->sym->name, p2) != 0)
+	if ((!p2 || f->sym->name != p2)
 	    && (compare_type_rank_if (arg[i].sym, f->sym)
 		|| compare_type_rank_if (f->sym, arg[i].sym)))
 	  ac2++;
@@ -1249,9 +1249,9 @@  generic_correspondence (gfc_formal_arglist *f1, gfc_formal_arglist *f2,
       if (f1->sym->attr.optional)
 	goto next;
 
-      if (p1 && strcmp (f1->sym->name, p1) == 0)
+      if (p1 && f1->sym->name == p1)
 	f1 = f1->next;
-      if (f2 && p2 && strcmp (f2->sym->name, p2) == 0)
+      if (f2 && p2 && f2->sym->name == p2)
 	f2 = f2->next;
 
       if (f2 != NULL && (compare_type_rank (f1->sym, f2->sym)
@@ -1265,7 +1265,7 @@  generic_correspondence (gfc_formal_arglist *f1, gfc_formal_arglist *f2,
 	 the current non-match.  */
       for (g = f1; g; g = g->next)
 	{
-	  if (g->sym->attr.optional || (p1 && strcmp (g->sym->name, p1) == 0))
+	  if (g->sym->attr.optional || (p1 && g->sym->name == p1))
 	    continue;
 
 	  sym = find_keyword_arg (g->sym->name, f2_save);
@@ -2914,7 +2914,7 @@  compare_actual_formal (gfc_actual_arglist **ap, gfc_formal_arglist *formal,
 	    {
 	      if (f->sym == NULL)
 		continue;
-	      if (strcmp (f->sym->name, a->name) == 0)
+	      if (f->sym->name == a->name)
 		break;
 	    }
 
@@ -4644,14 +4644,14 @@  gfc_check_typebound_override (gfc_symtree* proc, gfc_symtree* old)
        proc_formal = proc_formal->next, old_formal = old_formal->next)
     {
       if (proc->n.tb->pass_arg
-	  && !strcmp (proc->n.tb->pass_arg, proc_formal->sym->name))
+	  && proc->n.tb->pass_arg == proc_formal->sym->name)
 	proc_pass_arg = argpos;
       if (old->n.tb->pass_arg
-	  && !strcmp (old->n.tb->pass_arg, old_formal->sym->name))
+	  && old->n.tb->pass_arg == old_formal->sym->name)
 	old_pass_arg = argpos;
 
       /* Check that the names correspond.  */
-      if (strcmp (proc_formal->sym->name, old_formal->sym->name))
+      if (proc_formal->sym->name != old_formal->sym->name)
 	{
 	  gfc_error ("Dummy argument %qs of %qs at %L should be named %qs as"
 		     " to match the corresponding argument of the overridden"
diff --git a/gcc/fortran/match.c b/gcc/fortran/match.c
index 6596bd87c09..f27249ec6ed 100644
--- a/gcc/fortran/match.c
+++ b/gcc/fortran/match.c
@@ -1716,7 +1716,7 @@  gfc_match_else (void)
       return MATCH_ERROR;
     }
 
-  if (strcmp (name, gfc_current_block ()->name) != 0)
+  if (name != gfc_current_block ()->name)
     {
       gfc_error ("Label %qs at %C doesn't match IF label %qs",
 		 name, gfc_current_block ()->name);
@@ -1751,7 +1751,7 @@  gfc_match_elseif (void)
       goto cleanup;
     }
 
-  if (strcmp (name, gfc_current_block ()->name) != 0)
+  if (name != gfc_current_block ()->name)
     {
       gfc_error ("Label %qs at %C doesn't match IF label %qs",
 		 name, gfc_current_block ()->name);
@@ -5914,7 +5914,7 @@  match_case_eos (void)
   if (m != MATCH_YES)
     return m;
 
-  if (strcmp (name, gfc_current_block ()->name) != 0)
+  if (name != gfc_current_block ()->name)
     {
       gfc_error ("Expected block name %qs of SELECT construct at %C",
 		 gfc_current_block ()->name);
@@ -6640,7 +6640,7 @@  gfc_match_elsewhere (void)
       if (gfc_match_eos () != MATCH_YES)
 	goto syntax;
 
-      if (strcmp (name, gfc_current_block ()->name) != 0)
+      if (name != gfc_current_block ()->name)
 	{
 	  gfc_error ("Label %qs at %C doesn't match WHERE label %qs",
 		     name, gfc_current_block ()->name);
diff --git a/gcc/fortran/module.c b/gcc/fortran/module.c
index 3ad47f57930..fe5ae34dd13 100644
--- a/gcc/fortran/module.c
+++ b/gcc/fortran/module.c
@@ -3689,7 +3689,7 @@  mio_namelist (gfc_symbol *sym)
       if (sym->attr.flavor == FL_NAMELIST)
 	{
 	  check_name = find_use_name (sym->name, false);
-	  if (check_name && strcmp (check_name, sym->name) != 0)
+	  if (check_name && check_name != sym->name)
 	    gfc_error ("Namelist %s cannot be renamed by USE "
 		       "association to %s", sym->name, check_name);
 	}
@@ -4379,16 +4379,15 @@  static gfc_symtree *
 find_symbol (gfc_symtree *st, const char *name,
 	     const char *module, int generic)
 {
-  int c;
   gfc_symtree *retval, *s;
 
   if (st == NULL || st->n.sym == NULL)
     return NULL;
 
-  c = strcmp (name, st->n.sym->name);
-  if (c == 0 && st->n.sym->module
-	     && strcmp (module, st->n.sym->module) == 0
-	     && !check_unique_name (st->name))
+  if (name == st->n.sym->name
+      && st->n.sym->module
+      && module == st->n.sym->module
+      && !check_unique_name (st->name))
     {
       s = gfc_find_symtree (gfc_current_ns->sym_root, name);
 
@@ -4804,7 +4803,7 @@  load_omp_udrs (void)
 	{
 	  require_atom (ATOM_INTEGER);
 	  pointer_info *p = get_integer (atom_int);
-	  if (strcmp (p->u.rsym.module, udr->omp_out->module))
+	  if (p->u.rsym.module != udr->omp_out->module)
 	    {
 	      gfc_error ("Ambiguous !$OMP DECLARE REDUCTION from "
 			 "module %s at %L",
@@ -5203,9 +5202,9 @@  read_module (void)
 	    {
 	      st = gfc_find_symtree (gfc_current_ns->sym_root, name);
 	      if (st != NULL
-		  && strcmp (st->n.sym->name, info->u.rsym.true_name) == 0
+		  && st->n.sym->name == info->u.rsym.true_name
 		  && st->n.sym->module != NULL
-		  && strcmp (st->n.sym->module, info->u.rsym.module) == 0)
+		  && st->n.sym->module == info->u.rsym.module)
 		{
 		  info->u.rsym.symtree = st;
 		  info->u.rsym.sym = st->n.sym;
diff --git a/gcc/fortran/openmp.c b/gcc/fortran/openmp.c
index 08bc05cbc28..a868e34193f 100644
--- a/gcc/fortran/openmp.c
+++ b/gcc/fortran/openmp.c
@@ -2297,7 +2297,7 @@  gfc_match_oacc_routine (void)
 	    {
 	      sym = st->n.sym;
 	      if (gfc_current_ns->proc_name != NULL
-		  && strcmp (sym->name, gfc_current_ns->proc_name->name) == 0)
+		  && sym->name == gfc_current_ns->proc_name->name)
 	        sym = NULL;
 	    }
 
@@ -2628,8 +2628,7 @@  match_udr_expr (gfc_symtree *omp_sym1, gfc_symtree *omp_sym2)
   if (m != MATCH_YES)
     return false;
 
-  if (strcmp (sname, omp_sym1->name) == 0
-      || strcmp (sname, omp_sym2->name) == 0)
+  if (sname == omp_sym1->name || sname == omp_sym2->name)
     return false;
 
   gfc_current_ns = ns->parent;
@@ -2763,7 +2762,7 @@  gfc_omp_udr_find (gfc_symtree *st, gfc_typespec *ts)
       {
 	if (omp_udr->ts.type == BT_DERIVED || omp_udr->ts.type == BT_CLASS)
 	  {
-	    if (strcmp (omp_udr->ts.u.derived->name, ts->u.derived->name) == 0)
+	    if (omp_udr->ts.u.derived->name == ts->u.derived->name)
 	      return omp_udr;
 	  }
 	else if (omp_udr->ts.kind == ts->kind)
diff --git a/gcc/fortran/parse.c b/gcc/fortran/parse.c
index 880671b57f4..389eead0691 100644
--- a/gcc/fortran/parse.c
+++ b/gcc/fortran/parse.c
@@ -3569,8 +3569,7 @@  decl:
 
   if (current_interface.ns
 	&& current_interface.ns->proc_name
-	&& strcmp (current_interface.ns->proc_name->name,
-		   prog_unit->name) == 0)
+	&& current_interface.ns->proc_name->name == prog_unit->name)
     gfc_error ("INTERFACE procedure %qs at %L has the same name as the "
 	       "enclosing procedure", prog_unit->name,
 	       &current_interface.ns->proc_name->declared_at);
@@ -3617,7 +3616,7 @@  match_deferred_characteristics (gfc_typespec * ts)
      function name, there is an error.  */
   if (m == MATCH_YES
       && gfc_match ("function% %n", &name) == MATCH_YES
-      && strcmp (name, gfc_current_block ()->name) == 0)
+      && name == gfc_current_block ()->name)
     {
       gfc_current_block ()->declared_at = gfc_current_locus;
       gfc_commit_symbols ();
@@ -5224,8 +5223,7 @@  parse_omp_structured_block (gfc_statement omp_st, bool workshare_stmts_only)
     case EXEC_OMP_END_CRITICAL:
       if (((cp->ext.omp_clauses == NULL) ^ (new_st.ext.omp_name == NULL))
 	  || (new_st.ext.omp_name != NULL
-	      && strcmp (cp->ext.omp_clauses->critical_name,
-			 new_st.ext.omp_name) != 0))
+	      && cp->ext.omp_clauses->critical_name != new_st.ext.omp_name))
 	gfc_error ("Name after !$omp critical and !$omp end critical does "
 		   "not match at %C");
       new_st.ext.omp_name = NULL;
@@ -5998,7 +5996,7 @@  add_global_procedure (bool sub)
   /* Don't add the symbol multiple times.  */
   if (gfc_new_block->binding_label
       && (!gfc_notification_std (GFC_STD_F2008)
-          || strcmp (gfc_new_block->name, gfc_new_block->binding_label) != 0))
+          || gfc_new_block->name != gfc_new_block->binding_label))
     {
       s = gfc_get_gsymbol (gfc_new_block->binding_label);
 
diff --git a/gcc/fortran/resolve.c b/gcc/fortran/resolve.c
index ded27624283..afb745bddc5 100644
--- a/gcc/fortran/resolve.c
+++ b/gcc/fortran/resolve.c
@@ -149,7 +149,7 @@  check_proc_interface (gfc_symbol *ifc, locus *where)
       /* For generic interfaces, check if there is
 	 a specific procedure with the same name.  */
       gfc_interface *gen = ifc->generic;
-      while (gen && strcmp (gen->sym->name, ifc->name) != 0)
+      while (gen && gen->sym->name != ifc->name)
 	gen = gen->next;
       if (!gen)
 	{
@@ -310,7 +310,7 @@  resolve_formal_arglist (gfc_symbol *proc)
 	       && !resolve_procedure_interface (sym))
 	return;
 
-      if (strcmp (proc->name, sym->name) == 0)
+      if (proc->name == sym->name)
         {
           gfc_error ("Self-referential argument "
                      "%qs at %L is not allowed", sym->name,
@@ -573,7 +573,7 @@  resolve_contained_fntype (gfc_symbol *sym, gfc_namespace *ns)
       && sym->ns->parent
       && sym->ns->parent->proc_name
       && sym->ns->parent->proc_name->attr.flavor == FL_PROCEDURE
-      && !strcmp (sym->name, sym->ns->parent->proc_name->name))
+      && sym->name == sym->ns->parent->proc_name->name)
     gfc_error ("Contained procedure %qs at %L has the same name as its "
 	       "encompassing procedure", sym->name, &sym->declared_at);
 
@@ -1015,8 +1015,8 @@  resolve_common_blocks (gfc_symtree *common_root)
 	  && gsym->type == GSYM_COMMON
 	  && ((common_root->n.common->binding_label
 	       && (!gsym->binding_label
-		   || strcmp (common_root->n.common->binding_label,
-			      gsym->binding_label) != 0))
+		   || common_root->n.common->binding_label !=
+			      gsym->binding_label))
 	      || (!common_root->n.common->binding_label
 		  && gsym->binding_label)))
 	{
@@ -1650,7 +1650,7 @@  count_specific_procs (gfc_expr *e)
   sym = e->symtree->n.sym;
 
   for (p = sym->generic; p; p = p->next)
-    if (strcmp (sym->name, p->sym->name) == 0)
+    if (sym->name == p->sym->name)
       {
 	e->symtree = gfc_find_symtree (p->sym->ns->sym_root,
 				       sym->name);
@@ -2337,15 +2337,14 @@  not_entry_self_reference  (gfc_symbol *sym, gfc_namespace *gsym_ns)
 
       for (; entry; entry = entry->next)
 	{
-	  if (strcmp (sym->name, entry->sym->name) == 0)
+	  if (sym->name == entry->sym->name)
 	    {
-	      if (strcmp (gsym_ns->proc_name->name,
-			  sym->ns->proc_name->name) == 0)
+	      if (gsym_ns->proc_name->name == sym->ns->proc_name->name)
 		return false;
 
 	      if (sym->ns->parent
-		  && strcmp (gsym_ns->proc_name->name,
-			     sym->ns->parent->proc_name->name) == 0)
+		  && gsym_ns->proc_name->name ==
+			     sym->ns->parent->proc_name->name)
 		return false;
 	    }
 	}
@@ -2550,7 +2549,7 @@  resolve_global_procedure (gfc_symbol *sym, locus *where,
 	{
 	  gfc_entry_list *entry;
 	  for (entry = gsym->ns->entries; entry; entry = entry->next)
-	    if (strcmp (entry->sym->name, sym->name) == 0)
+	    if (entry->sym->name == sym->name)
 	      {
 		def_sym = entry->sym;
 		break;
@@ -8912,8 +8911,7 @@  resolve_select_type (gfc_code *code, gfc_namespace *old_ns)
 	      if (c->ts.type == d->ts.type
 		  && ((c->ts.type == BT_DERIVED
 		       && c->ts.u.derived && d->ts.u.derived
-		       && !strcmp (c->ts.u.derived->name,
-				   d->ts.u.derived->name))
+		       && c->ts.u.derived->name == d->ts.u.derived->name)
 		      || c->ts.type == BT_UNKNOWN
 		      || (!(c->ts.type == BT_DERIVED || c->ts.type == BT_CLASS)
 			  && c->ts.kind == d->ts.kind)))
@@ -11733,7 +11731,7 @@  gfc_verify_binding_labels (gfc_symbol *sym)
     }
   else if (sym->attr.flavor == FL_VARIABLE && module
 	   && (strcmp (module, gsym->mod_name) != 0
-	       || strcmp (sym->name, gsym->sym_name) != 0))
+	       || sym->name != gsym->sym_name))
     {
       /* This can only happen if the variable is defined in a module - if it
 	 isn't the same module, reject it.  */
@@ -11748,7 +11746,7 @@  gfc_verify_binding_labels (gfc_symbol *sym)
 	       || (gsym->defined && sym->attr.if_source != IFSRC_IFBODY))
 	   && sym != gsym->ns->proc_name
 	   && (module != gsym->mod_name
-	       || strcmp (gsym->sym_name, sym->name) != 0
+	       || gsym->sym_name != sym->name
 	       || (module && strcmp (module, gsym->mod_name) != 0)))
     {
       /* Print an error if the procedure is defined multiple times; we have to
@@ -11895,7 +11893,7 @@  build_init_assign (gfc_symbol *sym, gfc_expr *init)
     {
       ns = ns->contained;
       for (;ns; ns = ns->sibling)
-	if (strcmp (ns->proc_name->name, sym->name) == 0)
+	if (ns->proc_name->name == sym->name)
 	  break;
     }
 
@@ -12388,7 +12386,7 @@  compare_fsyms (gfc_symbol *sym)
   if (sym == fsym)
     return;
 
-  if (strcmp (sym->name, fsym->name) == 0)
+  if (sym->name == fsym->name)
     {
       if (!gfc_check_dummy_characteristics (fsym, sym, true, errmsg, 200))
 	gfc_error ("%s at %L", errmsg, &fsym->declared_at);
@@ -13382,7 +13380,7 @@  resolve_typebound_procedure (gfc_symtree* stree)
 	  stree->n.tb->pass_arg_num = 1;
 	  for (i = dummy_args; i; i = i->next)
 	    {
-	      if (!strcmp (i->sym->name, stree->n.tb->pass_arg))
+	      if (i->sym->name == stree->n.tb->pass_arg)
 		{
 		  me_arg = i->sym;
 		  break;
@@ -13812,7 +13810,7 @@  resolve_component (gfc_component *c, gfc_symbol *sym)
           c->tb->pass_arg_num = 1;
           for (i = c->ts.interface->formal; i; i = i->next)
             {
-              if (!strcmp (i->sym->name, c->tb->pass_arg))
+              if (i->sym->name == c->tb->pass_arg)
                 {
                   me_arg = i->sym;
                   break;
@@ -13914,7 +13912,7 @@  resolve_component (gfc_component *c, gfc_symbol *sym)
       && ((sym->attr.is_class
            && c == sym->components->ts.u.derived->components)
           || (!sym->attr.is_class && c == sym->components))
-      && strcmp (super_type->name, c->name) == 0)
+      && super_type->name == c->name)
     c->attr.access = super_type->attr.access;
 
   /* If this type is an extension, see if this component has the same name
diff --git a/gcc/fortran/symbol.c b/gcc/fortran/symbol.c
index e576bc1cb69..00a178772df 100644
--- a/gcc/fortran/symbol.c
+++ b/gcc/fortran/symbol.c
@@ -2239,7 +2239,7 @@  gfc_add_component (gfc_symbol *sym, const char *name,
 
   for (p = sym->components; p; p = p->next)
     {
-      if (strcmp (p->name, name) == 0)
+      if (p->name == name)
 	{
 	  gfc_error ("Component %qs at %C already declared at %L",
 		     name, &p->loc);
@@ -2504,7 +2504,8 @@  gfc_find_component (gfc_symbol *sym, const char *name,
               return check;
             }
         }
-      else if (strcmp (p->name, name) == 0)
+      else if (p->name == name || strcmp (p->name, name) == 0)
+	/* FORNOW: name could be "_data" et al so fallback to strcmp.  */
         break;
 
       continue;
@@ -2902,7 +2903,6 @@  compare_symtree (void *_st1, void *_st2)
 
   st1 = (gfc_symtree *) _st1;
   st2 = (gfc_symtree *) _st2;
-
   return strcmp (st1->name, st2->name);
 }
 
diff --git a/gcc/fortran/trans-array.c b/gcc/fortran/trans-array.c
index adb2c0575a8..78132908929 100644
--- a/gcc/fortran/trans-array.c
+++ b/gcc/fortran/trans-array.c
@@ -9024,7 +9024,7 @@  structure_alloc_comps (gfc_symbol * der_type, tree decl,
 	      gfc_actual_arglist *param = pdt_param_list;
 	      gfc_init_se (&tse, NULL);
 	      for (; param; param = param->next)
-		if (param->name && !strcmp (c->name, param->name))
+		if (param->name && c->name == param->name)
 		  c_expr = param->expr;
 
 	      if (!c_expr)
@@ -9266,7 +9266,7 @@  structure_alloc_comps (gfc_symbol * der_type, tree decl,
 
 	      gfc_init_se (&tse, NULL);
 	      for (; param; param = param->next)
-		if (!strcmp (c->name, param->name)
+		if (c->name == param->name
 		    && param->spec_type == SPEC_EXPLICIT)
 		  c_expr = param->expr;
 
diff --git a/gcc/fortran/trans-decl.c b/gcc/fortran/trans-decl.c
index e2adfa2e2db..6e717633a8f 100644
--- a/gcc/fortran/trans-decl.c
+++ b/gcc/fortran/trans-decl.c
@@ -1994,7 +1994,7 @@  gfc_get_extern_function_decl (gfc_symbol * sym)
 
 	  for (; entry; entry = entry->next)
 	    {
-	      if (strcmp (gsym->name, entry->sym->name) == 0)
+	      if (gsym->name == entry->sym->name)
 		{
 	          sym->backend_decl = entry->sym->backend_decl;
 		  break;
@@ -2787,9 +2787,10 @@  build_entry_thunks (gfc_namespace * ns, bool global)
 
 	  for (field = TYPE_FIELDS (TREE_TYPE (union_decl));
 	       field; field = DECL_CHAIN (field))
-	    if (strcmp (IDENTIFIER_POINTER (DECL_NAME (field)),
-		thunk_sym->result->name) == 0)
+	    if (IDENTIFIER_POINTER (DECL_NAME (field)) ==
+		thunk_sym->result->name)
 	      break;
+
 	  gcc_assert (field != NULL_TREE);
 	  tmp = fold_build3_loc (input_location, COMPONENT_REF,
 				 TREE_TYPE (field), union_decl, field,
@@ -2912,7 +2913,7 @@  gfc_get_fake_result_decl (gfc_symbol * sym, int parent_flag)
       tree t = NULL, var;
       if (this_fake_result_decl != NULL)
 	for (t = TREE_CHAIN (this_fake_result_decl); t; t = TREE_CHAIN (t))
-	  if (strcmp (IDENTIFIER_POINTER (TREE_PURPOSE (t)), sym->name) == 0)
+	  if (IDENTIFIER_POINTER (TREE_PURPOSE (t)) == sym->name)
 	    break;
       if (t)
 	return TREE_VALUE (t);
@@ -2929,10 +2930,8 @@  gfc_get_fake_result_decl (gfc_symbol * sym, int parent_flag)
 
 	  for (field = TYPE_FIELDS (TREE_TYPE (decl));
 	       field; field = DECL_CHAIN (field))
-	    if (strcmp (IDENTIFIER_POINTER (DECL_NAME (field)),
-		sym->name) == 0)
+	    if (IDENTIFIER_POINTER (DECL_NAME (field)) == sym->name)
 	      break;
-
 	  gcc_assert (field != NULL_TREE);
 	  decl = fold_build3_loc (input_location, COMPONENT_REF,
 				  TREE_TYPE (field), decl, field, NULL_TREE);
@@ -4794,7 +4793,7 @@  struct module_hasher : ggc_ptr_hash<module_htab_entry>
   static bool
   equal (module_htab_entry *a, const char *b)
   {
-    return !strcmp (a->name, b);
+    return a->name == b;
   }
 };
 
@@ -4817,7 +4816,7 @@  module_decl_hasher::equal (tree t1, const char *x2)
   const_tree n1 = DECL_NAME (t1);
   if (n1 == NULL_TREE)
     n1 = TYPE_NAME (TREE_TYPE (t1));
-  return strcmp (IDENTIFIER_POINTER (n1), x2) == 0;
+  return IDENTIFIER_POINTER (n1) == x2;
 }
 
 struct module_htab_entry *
@@ -5071,7 +5070,7 @@  gfc_trans_use_stmts (gfc_namespace * ns)
 	      if (st->n.sym->backend_decl
 		  && DECL_P (st->n.sym->backend_decl)
 		  && st->n.sym->module
-		  && strcmp (st->n.sym->module, use_stmt->module_name) == 0)
+		  && st->n.sym->module == use_stmt->module_name)
 		{
 		  gcc_assert (DECL_EXTERNAL (entry->namespace_decl)
 			      || !VAR_P (st->n.sym->backend_decl));
@@ -5084,8 +5083,7 @@  gfc_trans_use_stmts (gfc_namespace * ns)
 	      else if (st->n.sym->attr.flavor == FL_NAMELIST
 		       && st->n.sym->attr.use_only
 		       && st->n.sym->module
-		       && strcmp (st->n.sym->module, use_stmt->module_name)
-			  == 0)
+		       && st->n.sym->module == use_stmt->module_name)
 		{
 		  decl = generate_namelist_decl (st->n.sym);
 		  DECL_CONTEXT (decl) = entry->namespace_decl;
@@ -5613,7 +5611,7 @@  generate_local_decl (gfc_symbol * sym)
 	      gfc_entry_list *el;
 
 	      for (el = sym->ns->entries; el; el=el->next)
-		if (strcmp(sym->name, el->sym->name) == 0)
+		if (sym->name == el->sym->name)
 		  enter = true;
 
 	      if (!enter)
diff --git a/gcc/fortran/trans-expr.c b/gcc/fortran/trans-expr.c
index 56ce98c78c6..6c8a5b30568 100644
--- a/gcc/fortran/trans-expr.c
+++ b/gcc/fortran/trans-expr.c
@@ -2490,7 +2490,7 @@  conv_parent_component_references (gfc_se * se, gfc_ref * ref)
 
   /* Return if the component is in the parent type.  */
   for (cmp = dt->components; cmp; cmp = cmp->next)
-    if (strcmp (c->name, cmp->name) == 0)
+    if (c->name == cmp->name)
       return;
 
   /* Build a gfc_ref to recursively call gfc_conv_component_ref.  */
@@ -5199,8 +5199,7 @@  gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
 			   && fsym->ts.type == BT_CLASS
 			   && !CLASS_DATA (fsym)->as
 			   && !CLASS_DATA (e)->as
-			   && strcmp (fsym->ts.u.derived->name,
-				      e->ts.u.derived->name))
+			   && fsym->ts.u.derived->name != e->ts.u.derived->name)
 		    {
 		      type = gfc_typenode_for_spec (&fsym->ts);
 		      var = gfc_create_var (type, fsym->name);
@@ -6001,7 +6000,7 @@  gfc_conv_procedure_call (gfc_se * se, gfc_symbol * sym,
 	    {
 	      formal = gfc_sym_get_dummy_args (sym->ns->proc_name);
 	      for (; formal; formal = formal->next)
-		if (strcmp (formal->sym->name, sym->name) == 0)
+		if (formal->sym->name == sym->name)
 		  cl.backend_decl = formal->sym->ts.u.cl->backend_decl;
 	    }
 	  len = cl.backend_decl;