> There is a follow-up patch that I will be working on that will correctly
> update the other
> branch tests to correctly test out of range branch behaviour for
> micromips.  Currently these
> are passing because the mips branch range offset is large enough.  These
> offsets will
> need to be reduced for micromips to verify the compiler is calculating branch
> ranges correctly.

The following patch and ChangeLog adds out-of-range branch checks for micromips.
It also adds micromips versions of the branch range run tests (branch-14.c and
branch-15.c).

I have tested this on the mips-mti-elf target using 
mips32r2/{-mno-micromips/-mmicromips}
test options and there are no new regressions.

Ok to commit?

Many thanks,


Andrew


testsuite/
        * gcc.target/mips/branch-3.c: Add -mno-micromips to dg-options.
        * gcc.target/mips/branch-5.c: Ditto.
        * gcc.target/mips/branch-7.c: Ditto.
        * gcc.target/mips/branch-9.c: Ditto.
        * gcc.target/mips/branch-11.c: Ditto.
        * gcc.target/mips/branch-13.c: Ditto.    
        * gcc.target/mips/branch-14.c: Ditto.
        * gcc.target/mips/branch-15.c: Ditto.
        * gcc.target/mips/branch-umips-3.c: New file.    
        * gcc.target/mips/branch-umips-5.c: New file.            
        * gcc.target/mips/branch-umips-7.c: New file.                    
        * gcc.target/mips/branch-umips-9.c: New file.                           
 
        * gcc.target/mips/branch-umips-11.c: New file.                          
         
        * gcc.target/mips/branch-umips-13.c: New file.                          
                 
        * gcc.target/mips/branch-umips-14.c: New file.
        * gcc.target/mips/branch-umips-15.c: New file.
        * gcc.target/mips/branch-helper.h (OCCUPY_0x10000): New define.



diff --git a/gcc/testsuite/gcc.target/mips/branch-11.c 
b/gcc/testsuite/gcc.target/mips/branch-11.c
index 962eb1b..c33686a 100644
--- a/gcc/testsuite/gcc.target/mips/branch-11.c
+++ b/gcc/testsuite/gcc.target/mips/branch-11.c
@@ -1,4 +1,4 @@
-/* { dg-options "-mshared -mabi=n32" } */
+/* { dg-options "-mshared -mabi=n32 -mno-micromips" } */
 /* { dg-final { scan-assembler "\tsd\t\\\$28," } } */
 /* { dg-final { scan-assembler "\tld\t\\\$28," } } */
 /* { dg-final { scan-assembler 
"\taddiu\t\\\$28,\\\$28,%lo\\(%neg\\(%gp_rel\\(foo\\)\\)\\)\n" } } */
diff --git a/gcc/testsuite/gcc.target/mips/branch-13.c 
b/gcc/testsuite/gcc.target/mips/branch-13.c
index 8a6fb04..4da4a37 100644
--- a/gcc/testsuite/gcc.target/mips/branch-13.c
+++ b/gcc/testsuite/gcc.target/mips/branch-13.c
@@ -1,4 +1,4 @@
-/* { dg-options "-mshared -mabi=64" } */
+/* { dg-options "-mshared -mabi=64 -mno-micromips" } */
 /* { dg-final { scan-assembler "\tsd\t\\\$28," } } */
 /* { dg-final { scan-assembler "\tld\t\\\$28," } } */
 /* { dg-final { scan-assembler 
"\tdaddiu\t\\\$28,\\\$28,%lo\\(%neg\\(%gp_rel\\(foo\\)\\)\\)\n" } } */
diff --git a/gcc/testsuite/gcc.target/mips/branch-14.c 
b/gcc/testsuite/gcc.target/mips/branch-14.c
index 026417e..5193808 100644
--- a/gcc/testsuite/gcc.target/mips/branch-14.c
+++ b/gcc/testsuite/gcc.target/mips/branch-14.c
@@ -1,4 +1,5 @@
 /* An executable version of branch-2.c.  */
+/* { dg-options "-mno-micromips" } */
 /* { dg-do run } */
 
 #include "branch-helper.h"
diff --git a/gcc/testsuite/gcc.target/mips/branch-15.c 
b/gcc/testsuite/gcc.target/mips/branch-15.c
index dee7a05..a28de9a 100644
--- a/gcc/testsuite/gcc.target/mips/branch-15.c
+++ b/gcc/testsuite/gcc.target/mips/branch-15.c
@@ -1,4 +1,5 @@
 /* An executable version of branch-3.c.  */
+/* { dg-options "-mno-micromips" } */
 /* { dg-do run } */
 
 #include "branch-helper.h"
diff --git a/gcc/testsuite/gcc.target/mips/branch-3.c 
b/gcc/testsuite/gcc.target/mips/branch-3.c
index 5fcfece..1790cbc 100644
--- a/gcc/testsuite/gcc.target/mips/branch-3.c
+++ b/gcc/testsuite/gcc.target/mips/branch-3.c
@@ -1,4 +1,4 @@
-/* { dg-options "-mshared -mabi=32" } */
+/* { dg-options "-mshared -mabi=32 -mno-micromips" } */
 /* { dg-final { scan-assembler "\t\\.cpload\t\\\$25\n" } } */
 /* { dg-final { scan-assembler "\tjr\t\\\$1\n" } } */
 /* { dg-final { scan-assembler-not "\\.cprestore" } } */
diff --git a/gcc/testsuite/gcc.target/mips/branch-5.c 
b/gcc/testsuite/gcc.target/mips/branch-5.c
index 1e9c120..38dbea2 100644
--- a/gcc/testsuite/gcc.target/mips/branch-5.c
+++ b/gcc/testsuite/gcc.target/mips/branch-5.c
@@ -1,4 +1,4 @@
-/* { dg-options "-mshared -mabi=n32" } */
+/* { dg-options "-mshared -mabi=n32 -mno-micromips" } */
 /* { dg-final { scan-assembler 
"\taddiu\t\\\$3,\\\$3,%lo\\(%neg\\(%gp_rel\\(foo\\)\\)\\)\n" } } */
 /* { dg-final { scan-assembler 
"\tlw\t\\\$1,%got_page\\(\[^)\]*\\)\\(\\\$3\\)\\n" } } */
 /* { dg-final { scan-assembler "\tjr\t\\\$1\n" } } */
diff --git a/gcc/testsuite/gcc.target/mips/branch-7.c 
b/gcc/testsuite/gcc.target/mips/branch-7.c
index 8ad6808..b69a302 100644
--- a/gcc/testsuite/gcc.target/mips/branch-7.c
+++ b/gcc/testsuite/gcc.target/mips/branch-7.c
@@ -1,4 +1,4 @@
-/* { dg-options "-mshared -mabi=64" } */
+/* { dg-options "-mshared -mabi=64 -mno-micromips" } */
 /* { dg-final { scan-assembler 
"\tdaddiu\t\\\$3,\\\$3,%lo\\(%neg\\(%gp_rel\\(foo\\)\\)\\)\n" } } */
 /* { dg-final { scan-assembler 
"\tld\t\\\$1,%got_page\\(\[^)\]*\\)\\(\\\$3\\)\\n" } } */
 /* { dg-final { scan-assembler "\tjr\t\\\$1\n" } } */
diff --git a/gcc/testsuite/gcc.target/mips/branch-9.c 
b/gcc/testsuite/gcc.target/mips/branch-9.c
index cad1c00..a8124dd 100644
--- a/gcc/testsuite/gcc.target/mips/branch-9.c
+++ b/gcc/testsuite/gcc.target/mips/branch-9.c
@@ -1,4 +1,4 @@
-/* { dg-options "-mshared -mabi=32" } */
+/* { dg-options "-mshared -mabi=32 -mno-micromips" } */
 /* { dg-final { scan-assembler "\t\\.cpload\t\\\$25\n" } } */
 /* { dg-final { scan-assembler "\t\\.cprestore\t16\n" } } */
 /* { dg-final { scan-assembler "\tlw\t\\\$1,16\\(\\\$(fp|sp)\\)\n" } } */
diff --git a/gcc/testsuite/gcc.target/mips/branch-helper.h 
b/gcc/testsuite/gcc.target/mips/branch-helper.h
index bc4a31f..7979ec7 100644
--- a/gcc/testsuite/gcc.target/mips/branch-helper.h
+++ b/gcc/testsuite/gcc.target/mips/branch-helper.h
@@ -53,3 +53,5 @@
        D0 ("nop32"))
 /* Likewise emit something that is 0x1fffc bytes long.  */
 #define OCCUPY_0x1fffc do { asm ("nop"); OCCUPY_0x1fff8; } while (0)
+/* Likewise emit something that is 0x10000 bytes long.  */
+#define OCCUPY_0x10000 do { asm ("nop32"); OCCUPY_0xfffc; } while (0)
diff --git a/gcc/testsuite/gcc.target/mips/branch-umips-11.c 
b/gcc/testsuite/gcc.target/mips/branch-umips-11.c
new file mode 100644
index 0000000..f9f30a7
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/branch-umips-11.c
@@ -0,0 +1,17 @@
+/* { dg-options "-mshared -mabi=n32 -mmicromips" } */
+/* { dg-final { scan-assembler "\tsd\t\\\$28," } } */
+/* { dg-final { scan-assembler "\tld\t\\\$28," } } */
+/* { dg-final { scan-assembler 
"\taddiu\t\\\$28,\\\$28,%lo\\(%neg\\(%gp_rel\\(foo\\)\\)\\)\n" } } */
+/* { dg-final { scan-assembler 
"\tlw\t\\\$1,%got_page\\(\[^)\]*\\)\\(\\\$28\\)\n" } } */
+/* { dg-final { scan-assembler "\taddiu\t\\\$1,\\\$1,%got_ofst\\(\[^)\]*\\)\n" 
} } */
+/* { dg-final { scan-assembler "\tjr\t\\\$1\n" } } */
+
+#include "branch-helper.h"
+
+NOMIPS16 void
+foo (int (*bar) (void), int *x)
+{
+  *x = bar ();
+  if (__builtin_expect (*x == 0, 1))
+    OCCUPY_0x10000;
+}
diff --git a/gcc/testsuite/gcc.target/mips/branch-umips-13.c 
b/gcc/testsuite/gcc.target/mips/branch-umips-13.c
new file mode 100644
index 0000000..95f7db5
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/branch-umips-13.c
@@ -0,0 +1,17 @@
+/* { dg-options "-mshared -mabi=64 -mmicromips" } */
+/* { dg-final { scan-assembler "\tsd\t\\\$28," } } */
+/* { dg-final { scan-assembler "\tld\t\\\$28," } } */
+/* { dg-final { scan-assembler 
"\tdaddiu\t\\\$28,\\\$28,%lo\\(%neg\\(%gp_rel\\(foo\\)\\)\\)\n" } } */
+/* { dg-final { scan-assembler 
"\tld\t\\\$1,%got_page\\(\[^)\]*\\)\\(\\\$28\\)\n" } } */
+/* { dg-final { scan-assembler 
"\tdaddiu\t\\\$1,\\\$1,%got_ofst\\(\[^)\]*\\)\n" } } */
+/* { dg-final { scan-assembler "\tjr\t\\\$1\n" } } */
+
+#include "branch-helper.h"
+
+NOMIPS16 void
+foo (int (*bar) (void), int *x)
+{
+  *x = bar ();
+  if (__builtin_expect (*x == 0, 1))
+    OCCUPY_0x10000;
+}
diff --git a/gcc/testsuite/gcc.target/mips/branch-umips-14.c 
b/gcc/testsuite/gcc.target/mips/branch-umips-14.c
new file mode 100644
index 0000000..acf5675
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/branch-umips-14.c
@@ -0,0 +1,24 @@
+/* An executable version of branch-2.c.  */
+/* { dg-options "-mmicromips" } */
+/* { dg-do run } */
+
+#include "branch-helper.h"
+
+void __attribute__((noinline))
+foo (volatile int *x)
+{
+  if (__builtin_expect (*x == 0, 1))
+    OCCUPY_0xfffc;
+}
+
+int
+main (void)
+{
+  int x = 0;
+  int y = 1;
+
+  foo (&x);
+  foo (&y);
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.target/mips/branch-umips-15.c 
b/gcc/testsuite/gcc.target/mips/branch-umips-15.c
new file mode 100644
index 0000000..e08ba5d
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/branch-umips-15.c
@@ -0,0 +1,24 @@
+/* An executable version of branch-3.c.  */
+/* { dg-options "-mmicromips" } */
+/* { dg-do run } */
+
+#include "branch-helper.h"
+
+void
+foo (volatile int *x)
+{
+  if (__builtin_expect (*x == 0, 1))
+    OCCUPY_0x10000;
+}
+
+int
+main (void)
+{
+  int x = 0;
+  int y = 1;
+
+  foo (&x);
+  foo (&y);
+
+  return 0;
+}
diff --git a/gcc/testsuite/gcc.target/mips/branch-umips-3.c 
b/gcc/testsuite/gcc.target/mips/branch-umips-3.c
new file mode 100644
index 0000000..d688bc9
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/branch-umips-3.c
@@ -0,0 +1,13 @@
+/* { dg-options "-mshared -mabi=32 -mmicromips" } */
+/* { dg-final { scan-assembler "\t\\.cpload\t\\\$25\n" } } */
+/* { dg-final { scan-assembler "\tjr\t\\\$1\n" } } */
+/* { dg-final { scan-assembler-not "\\.cprestore" } } */
+
+#include "branch-helper.h"
+
+NOMIPS16 void
+foo (volatile int *x)
+{
+  if (__builtin_expect (*x == 0, 1))
+    OCCUPY_0x10000;
+}
diff --git a/gcc/testsuite/gcc.target/mips/branch-umips-5.c 
b/gcc/testsuite/gcc.target/mips/branch-umips-5.c
new file mode 100644
index 0000000..02273cf
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/branch-umips-5.c
@@ -0,0 +1,14 @@
+/* { dg-options "-mshared -mabi=n32 -mmicromips" } */
+/* { dg-final { scan-assembler 
"\taddiu\t\\\$3,\\\$3,%lo\\(%neg\\(%gp_rel\\(foo\\)\\)\\)\n" } } */
+/* { dg-final { scan-assembler 
"\tlw\t\\\$1,%got_page\\(\[^)\]*\\)\\(\\\$3\\)\\n" } } */
+/* { dg-final { scan-assembler "\tjr\t\\\$1\n" } } */
+/* { dg-final { scan-assembler-not "\\\$28" } } */
+
+#include "branch-helper.h"
+
+NOMIPS16 void
+foo (volatile int *x)
+{
+  if (__builtin_expect (*x == 0, 1))
+    OCCUPY_0x10000;
+}
diff --git a/gcc/testsuite/gcc.target/mips/branch-umips-7.c 
b/gcc/testsuite/gcc.target/mips/branch-umips-7.c
new file mode 100644
index 0000000..714691b
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/branch-umips-7.c
@@ -0,0 +1,14 @@
+/* { dg-options "-mshared -mabi=64 -mmicromips" } */
+/* { dg-final { scan-assembler 
"\tdaddiu\t\\\$3,\\\$3,%lo\\(%neg\\(%gp_rel\\(foo\\)\\)\\)\n" } } */
+/* { dg-final { scan-assembler 
"\tld\t\\\$1,%got_page\\(\[^)\]*\\)\\(\\\$3\\)\\n" } } */
+/* { dg-final { scan-assembler "\tjr\t\\\$1\n" } } */
+/* { dg-final { scan-assembler-not "\\\$28" } } */
+
+#include "branch-helper.h"
+
+NOMIPS16 void
+foo (volatile int *x)
+{
+  if (__builtin_expect (*x == 0, 1))
+    OCCUPY_0x10000;
+}
diff --git a/gcc/testsuite/gcc.target/mips/branch-umips-9.c 
b/gcc/testsuite/gcc.target/mips/branch-umips-9.c
new file mode 100644
index 0000000..a393de9
--- /dev/null
+++ b/gcc/testsuite/gcc.target/mips/branch-umips-9.c
@@ -0,0 +1,18 @@
+/* { dg-options "-mshared -mabi=32 -mmicromips" } */
+/* { dg-final { scan-assembler "\t\\.cpload\t\\\$25\n" } } */
+/* { dg-final { scan-assembler "\t\\.cprestore\t16\n" } } */
+/* { dg-final { scan-assembler "\tlw\t\\\$1,16\\(\\\$(fp|sp)\\)\n" } } */
+/* { dg-final { scan-assembler "\tlw\t\\\$1,%got\\(\[^)\]*\\)\\(\\\$1\\)\n" } 
} */
+/* { dg-final { scan-assembler "\taddiu\t\\\$1,\\\$1,%lo\\(\[^)\]*\\)\n" } } */
+/* { dg-final { scan-assembler "\tjr\t\\\$1\n" } } */
+/* { dg-final { scan-assembler-not "\\\$28" } } */
+
+#include "branch-helper.h"
+
+NOMIPS16 void
+foo (int (*bar) (void), int *x)
+{
+  *x = bar ();
+  if (__builtin_expect (*x == 0, 1))
+    OCCUPY_0x10000;
+}

Reply via email to