Fix sparc %gsr write elimination and add a testcase.
authorDavid S. Miller <davem@davemloft.net>
Mon, 26 Sep 2011 20:21:19 +0000 (20:21 +0000)
committerDavid S. Miller <davem@gcc.gnu.org>
Mon, 26 Sep 2011 20:21:19 +0000 (13:21 -0700)
gcc/

* config/sparc/sparc.c (sparc_conditional_register_usage): When VIS
is enabled, mark %gsr as global.
* config/sparc/sparc.md (UNSPEC_WRGSR): Delete.
(wrgsr_vis, *wrgsr_sp64, wrgsr_v8plus): Don't wrap in an unspec.

gcc/testsuite/

* gcc.target/sparc/wrgsr.c: New test.

From-SVN: r179214

gcc/ChangeLog
gcc/config/sparc/sparc.c
gcc/config/sparc/sparc.md
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/sparc/wrgsr.c [new file with mode: 0644]

index 309eca549dfe67d5bc79de73612e535d32691e49..53afbd97fc72443999eeba05e29f3eed69480e48 100644 (file)
@@ -1,5 +1,10 @@
 2011-09-26  David S. Miller  <davem@davemloft.net>
 
+       * config/sparc/sparc.c (sparc_conditional_register_usage): When VIS
+       is enabled, mark %gsr as global.
+       * config/sparc/sparc.md (UNSPEC_WRGSR): Delete.
+       (wrgsr_vis, *wrgsr_sp64, wrgsr_v8plus): Don't wrap in an unspec.
+
        * config/sparc/sparc-c.c: New file implementing sparc_target_macros,
        which will now define __VIS and __VIS__ when -mvis is enabled.
        * config/sparc/t-sparc: Likewise.
index 8193d1cf4889772ce1c97f35ce76b16834b5f03a..a395321dd3e9ecda6265d0c429e53a5d0954ff37 100644 (file)
@@ -10426,6 +10426,8 @@ sparc_conditional_register_usage (void)
       for (regno = 0; regno < FIRST_PSEUDO_REGISTER; regno++)
        leaf_reg_remap [regno] = regno;
     }
+  if (TARGET_VIS)
+    global_regs[SPARC_GSR_REG] = 1;
 }
 
 /* Implement TARGET_PREFERRED_RELOAD_CLASS
index 3f7a93b6b7508ac9776d7596a86854abe79fc952..e79e842eadec9c379d0f90544b9e42f74ff44d53 100644 (file)
@@ -58,7 +58,7 @@
    (UNSPEC_MUL8UL              46)
    (UNSPEC_MULDUL              47)
    (UNSPEC_ALIGNDATA           48)
-   (UNSPEC_WRGSR                49)
+
    (UNSPEC_PDIST               50)
    (UNSPEC_EDGE8               51)
    (UNSPEC_EDGE8L              52)
    (set_attr "fptype" "double")])
 
 (define_expand "wrgsr_vis"
-  [(set (reg:DI GSR_REG) (unspec:DI [(match_operand:DI 0 "arith_operand" "")]
-                                    UNSPEC_WRGSR))]
+  [(set (reg:DI GSR_REG) (match_operand:DI 0 "arith_operand" ""))]
   "TARGET_VIS"
 {
   if (! TARGET_ARCH64)
 })
 
 (define_insn "*wrgsr_sp64"
-  [(set (reg:DI GSR_REG) (unspec:DI [(match_operand:DI 0 "arith_operand" "rI")]
-                                    UNSPEC_WRGSR))]
+  [(set (reg:DI GSR_REG) (match_operand:DI 0 "arith_operand" "rI"))]
   "TARGET_VIS && TARGET_ARCH64"
   "wr\t%%g0, %0, %%gsr"
   [(set_attr "type" "gsr")])
 
 (define_insn "wrgsr_v8plus"
-  [(set (reg:DI GSR_REG) (unspec:DI [(match_operand:DI 0 "arith_operand" "I,r")]
-                                    UNSPEC_WRGSR))
+  [(set (reg:DI GSR_REG) (match_operand:DI 0 "arith_operand" "I,r"))
    (clobber (match_scratch:SI 1 "=X,&h"))]
   "TARGET_VIS && ! TARGET_ARCH64"
 {
index c973b423f30d25c8d1264f6abadfa1a83d37e55b..c8619b89f4729a7e87c9de2ef03785082c1066ee 100644 (file)
@@ -1,3 +1,7 @@
+2011-09-26  David S. Miller  <davem@davemloft.net>
+
+       * gcc.target/sparc/wrgsr.c: New test.
+
 2011-09-26  Janus Weil  <janus@gcc.gnu.org>
 
        PR fortran/50515
diff --git a/gcc/testsuite/gcc.target/sparc/wrgsr.c b/gcc/testsuite/gcc.target/sparc/wrgsr.c
new file mode 100644 (file)
index 0000000..6cfa060
--- /dev/null
@@ -0,0 +1,15 @@
+/* { dg-do compile } */
+/* { dg-options "-O -mcpu=ultrasparc -mvis" } */
+
+void set_gsr (void)
+{
+       __builtin_vis_write_gsr (2 << 3);
+}
+
+void set_gsr2 (long x)
+{
+       __builtin_vis_write_gsr (x);
+}
+
+/* { dg-final { scan-assembler "wr\t%g0, 16, %gsr" } } */
+/* { dg-final { scan-assembler "wr\t%g0, %" } } */