sh.md (mov<mode>): Replace movQIHI.
authorChristian Bruel <christian.bruel@st.com>
Wed, 23 Apr 2014 07:30:12 +0000 (09:30 +0200)
committerChristian Bruel <chrbr@gcc.gnu.org>
Wed, 23 Apr 2014 07:30:12 +0000 (09:30 +0200)
2014-04-22  Christian Bruel  <christian.bruel@st.com>

        * config/sh/sh.md (mov<mode>): Replace movQIHI.
         Force immediates to SImode.

From-SVN: r209671

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

index 38d19bd..61987af 100644 (file)
@@ -1,3 +1,8 @@
+2014-04-22  Christian Bruel  <christian.bruel@st.com>
+
+       * config/sh/sh.md (mov<mode>): Replace movQIHI.
+        Force immediates to SImode.
+
 2014-04-22  Sandra Loosemore  <sandra@codesourcery.com>
 
        * config/nios2/nios2.md (UNSPEC_ROUND): New.
index 9035bfc..367f4ef 100644 (file)
@@ -6978,20 +6978,20 @@ label:
   [(set_attr "type" "sfunc")
    (set_attr "needs_delay_slot" "yes")])
 
-(define_expand "movhi"
-  [(set (match_operand:HI 0 "general_movdst_operand" "")
-       (match_operand:HI 1 "general_movsrc_operand" ""))]
+(define_expand "mov<mode>"
+  [(set (match_operand:QIHI 0 "general_movdst_operand")
+       (match_operand:QIHI 1 "general_movsrc_operand"))]
   ""
 {
-  prepare_move_operands (operands, HImode);
-})
+ if (can_create_pseudo_p () && CONST_INT_P (operands[1])
+    && REG_P (operands[0]) && REGNO (operands[0]) != R0_REG)
+    {
+        rtx reg = gen_reg_rtx(SImode);
+        emit_move_insn (reg, operands[1]);
+        operands[1] = gen_lowpart (<MODE>mode, reg);
+    }
 
-(define_expand "movqi"
-  [(set (match_operand:QI 0 "general_operand" "")
-       (match_operand:QI 1 "general_operand" ""))]
-  ""
-{
-  prepare_move_operands (operands, QImode);
+  prepare_move_operands (operands, <MODE>mode);
 })
 
 ;; Specifying the displacement addressing load / store patterns separately
index 78b0e34..69a5667 100644 (file)
@@ -1,3 +1,7 @@
+2014-04-22  Christian Bruel  <christian.bruel@st.com>
+
+       * gcc.target/sh/hiconst.c: New test.
+
 2014-04-22  Sandra Loosemore  <sandra@codesourcery.com>
 
        * gcc.target/nios2/custom-fp-conversion.c: Adjust to test that
diff --git a/gcc/testsuite/gcc.target/sh/hiconst.c b/gcc/testsuite/gcc.target/sh/hiconst.c
new file mode 100644 (file)
index 0000000..d471d20
--- /dev/null
@@ -0,0 +1,22 @@
+/* { dg-do compile { target "sh*-*-*" } } */
+/* { dg-options "-O1" } */
+
+char a;
+int b;
+
+foo(char *pt, int *pti)
+{
+  a = 0;
+  b = 0;
+  *pt = 0;
+  *pti = 0;
+}
+
+rab(char *pt, int *pti)
+{
+  pt[2] = 0;
+  pti[3] = 0;
+}
+
+/* { dg-final { scan-assembler-times "mov\t#0" 2 } } */
+