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