13f101
commit 93ed472702aad6d9b8998592775a0ab4120b6242
13f101
Author: law <law@138bc75d-0d04-0410-961f-82ee72b054a4>
13f101
Date:   Wed Sep 20 21:59:50 2017 +0000
13f101
13f101
            * explow.c (compute_stack_clash_protection_loop_data): Use
13f101
            CONST_INT_P instead of explicit test.  Verify object is a
13f101
            CONST_INT_P before looking at INTVAL.
13f101
            (anti_adjust_stack_and_probe_stack_clash): Use CONST_INT_P
13f101
            instead of explicit test.
13f101
    
13f101
            * gcc.target/i386/stack-check-11.c: Update test and regexp
13f101
            so that it works for both i?86 and x86_64.
13f101
    
13f101
    git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@253034 138bc75d-0d04-0410-961f-82ee72b054a4
13f101
13f101
diff --git a/gcc/explow.c b/gcc/explow.c
13f101
index 2526e8513b7..d118e0d7782 100644
13f101
--- a/gcc/explow.c
13f101
+++ b/gcc/explow.c
13f101
@@ -1778,11 +1778,11 @@ compute_stack_clash_protection_loop_data (rtx *rounded_size, rtx *last_addr,
13f101
       if (*rounded_size == CONST0_RTX (Pmode))
13f101
 	fprintf (dump_file,
13f101
 		 "Stack clash skipped dynamic allocation and probing loop.\n");
13f101
-      else if (GET_CODE (*rounded_size) == CONST_INT
13f101
+      else if (CONST_INT_P (*rounded_size)
13f101
 	       && INTVAL (*rounded_size) <= 4 * *probe_interval)
13f101
 	fprintf (dump_file,
13f101
 		 "Stack clash dynamic allocation and probing inline.\n");
13f101
-      else if (GET_CODE (*rounded_size) == CONST_INT)
13f101
+      else if (CONST_INT_P (*rounded_size))
13f101
 	fprintf (dump_file,
13f101
 		 "Stack clash dynamic allocation and probing in "
13f101
 		 "rotated loop.\n");
13f101
@@ -1880,7 +1880,8 @@ anti_adjust_stack_and_probe_stack_clash (rtx size)
13f101
 
13f101
   if (rounded_size != CONST0_RTX (Pmode))
13f101
     {
13f101
-      if (INTVAL (rounded_size) <= 4 * probe_interval)
13f101
+      if (CONST_INT_P (rounded_size)
13f101
+	  && INTVAL (rounded_size) <= 4 * probe_interval)
13f101
 	{
13f101
 	  for (HOST_WIDE_INT i = 0;
13f101
 	       i < INTVAL (rounded_size);
13f101
@@ -1900,7 +1901,7 @@ anti_adjust_stack_and_probe_stack_clash (rtx size)
13f101
       else
13f101
 	{
13f101
 	  rtx loop_lab, end_loop;
13f101
-	  bool rotate_loop = GET_CODE (rounded_size) == CONST_INT;
13f101
+	  bool rotate_loop = CONST_INT_P (rounded_size);
13f101
 	  emit_stack_clash_protection_probe_loop_start (&loop_lab, &end_loop,
13f101
 							last_addr, rotate_loop);
13f101
 
13f101
@@ -1938,7 +1939,7 @@ anti_adjust_stack_and_probe_stack_clash (rtx size)
13f101
 	 might hold live data.  So probe at *sp if we know that
13f101
 	 an allocation was made, otherwise probe into the red zone
13f101
 	 which is obviously undesirable.  */
13f101
-      if (GET_CODE (size) == CONST_INT)
13f101
+      if (CONST_INT_P (size))
13f101
 	{
13f101
 	  emit_stack_probe (stack_pointer_rtx);
13f101
 	  emit_insn (gen_blockage ());
13f101
diff --git a/gcc/testsuite/gcc.target/i386/stack-check-11.c b/gcc/testsuite/gcc.target/i386/stack-check-11.c
13f101
index 183103f01e5..fe5b2c2b844 100644
13f101
--- a/gcc/testsuite/gcc.target/i386/stack-check-11.c
13f101
+++ b/gcc/testsuite/gcc.target/i386/stack-check-11.c
13f101
@@ -2,15 +2,17 @@
13f101
 /* { dg-options "-O2 -fstack-clash-protection" } */
13f101
 /* { dg-require-effective-target supports_stack_clash_protection } */
13f101
 
13f101
-extern void arf (unsigned long int *, unsigned long int *);
13f101
+#include <stdint.h>
13f101
+
13f101
+extern void arf (uint64_t *, uint64_t *);
13f101
 void
13f101
 frob ()
13f101
 {
13f101
-  unsigned long int num[859];
13f101
-  unsigned long int den[859];
13f101
+  uint64_t num[859];
13f101
+  uint64_t den[859];
13f101
   arf (den, num);
13f101
 }
13f101
 
13f101
-/* { dg-final { scan-assembler-times "subq" 4 } } */
13f101
-/* { dg-final { scan-assembler-times "orq" 3 } } */
13f101
+/* { dg-final { scan-assembler-times "sub\[ql\]" 4 } } */
13f101
+/* { dg-final { scan-assembler-times "or\[ql\]" 3 } } */
13f101