public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [PATCH][C++] Improve compile-time by ordering expensive checks last
@ 2019-04-16 12:34 Richard Biener
  2019-04-17 15:35 ` Richard Biener
  0 siblings, 1 reply; 9+ messages in thread
From: Richard Biener @ 2019-04-16 12:34 UTC (permalink / raw)
  To: gcc-patches; +Cc: Jakub Jelinek


Two cases from a -fsynax-only tramp3d callgrind profile.

Bootstrapped / tested on x86_64-unknown-linux-gnu.

OK for trunk?

Richard.

2019-04-16  Richard Biener  <rguenther@suse.de>

	cp/
	* call.c (null_ptr_cst_p): Order checks according to expensiveness.
	(conversion_null_warnings): Likewise.

Index: gcc/cp/call.c
===================================================================
--- gcc/cp/call.c	(revision 270387)
+++ gcc/cp/call.c	(working copy)
@@ -541,11 +541,11 @@ null_ptr_cst_p (tree t)
       STRIP_ANY_LOCATION_WRAPPER (t);
 
       /* Core issue 903 says only literal 0 is a null pointer constant.  */
-      if (TREE_CODE (type) == INTEGER_TYPE
-	  && !char_type_p (type)
-	  && TREE_CODE (t) == INTEGER_CST
+      if (TREE_CODE (t) == INTEGER_CST
+	  && !TREE_OVERFLOW (t)
+	  && TREE_CODE (type) == INTEGER_TYPE
 	  && integer_zerop (t)
-	  && !TREE_OVERFLOW (t))
+	  && !char_type_p (type))
 	return true;
     }
   else if (CP_INTEGRAL_TYPE_P (type))
@@ -6882,8 +6882,8 @@ conversion_null_warnings (tree totype, t
     }
   /* Handle zero as null pointer warnings for cases other
      than EQ_EXPR and NE_EXPR */
-  else if (null_ptr_cst_p (expr) &&
-	   (TYPE_PTR_OR_PTRMEM_P (totype) || NULLPTR_TYPE_P (totype)))
+  else if ((TYPE_PTR_OR_PTRMEM_P (totype) || NULLPTR_TYPE_P (totype))
+	   && null_ptr_cst_p (expr))
     {
       location_t loc = get_location_for_expr_unwinding_for_system_header (expr);
       maybe_warn_zero_as_null_pointer_constant (expr, loc);

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

end of thread, other threads:[~2019-04-25 21:10 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-16 12:34 [PATCH][C++] Improve compile-time by ordering expensive checks last Richard Biener
2019-04-17 15:35 ` Richard Biener
2019-04-19  5:32   ` Jason Merrill
2019-04-25 11:27   ` Rainer Orth
2019-04-25 11:36     ` [PATCH] Fix -Wunused-var-35.C (was Re: [PATCH][C++] Improve compile-time by ordering expensive checks last) Jakub Jelinek
2019-04-25 11:48       ` Richard Biener
2019-04-25 11:55         ` Jakub Jelinek
2019-04-25 12:16           ` Richard Biener
2019-04-25 21:14       ` Jason Merrill

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).