]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
[NDS32] Merge movqi and movhi patterns.
authorChung-Ju Wu <jasonwucj@gmail.com>
Wed, 4 Apr 2018 09:19:39 +0000 (09:19 +0000)
committerChung-Ju Wu <jasonwucj@gcc.gnu.org>
Wed, 4 Apr 2018 09:19:39 +0000 (09:19 +0000)
gcc/
* config/nds32/nds32.md (movqi, movhi): Merge into mov<mode>.

From-SVN: r259071

gcc/ChangeLog
gcc/config/nds32/nds32.md

index 651523fab1ef185ab7c3912646f493862b49b0b6..3555f35e18ceb73b43e9c5dcb498229368949d9b 100644 (file)
@@ -1,3 +1,7 @@
+2018-04-04  Chung-Ju Wu  <jasonwucj@gmail.com>
+
+       * config/nds32/nds32.md (movqi, movhi): Merge into mov<mode>.
+
 2018-04-04  Chung-Ju Wu  <jasonwucj@gmail.com>
            Kito Cheng  <kito.cheng@gmail.com>
 
index 662be73d8e8e4c4c51057f39af434217e1d4b9c6..9a12598e21100f6d614c13f7763929b8e9fdd51a 100644 (file)
 ;; For QImode and HImode, the immediate value can be fit in imm20s.
 ;; So there is no need to split rtx for QI and HI patterns.
 
-(define_expand "movqi"
-  [(set (match_operand:QI 0 "general_operand" "")
-       (match_operand:QI 1 "general_operand" ""))]
+(define_expand "mov<mode>"
+  [(set (match_operand:QIHI 0 "general_operand" "")
+       (match_operand:QIHI 1 "general_operand" ""))]
   ""
 {
   /* Need to force register if mem <- !reg.  */
   if (MEM_P (operands[0]) && !REG_P (operands[1]))
-    operands[1] = force_reg (QImode, operands[1]);
-})
+    operands[1] = force_reg (<MODE>mode, operands[1]);
 
-(define_expand "movhi"
-  [(set (match_operand:HI 0 "general_operand" "")
-       (match_operand:HI 1 "general_operand" ""))]
-  ""
-{
-  /* Need to force register if mem <- !reg.  */
-  if (MEM_P (operands[0]) && !REG_P (operands[1]))
-    operands[1] = force_reg (HImode, operands[1]);
+  if (MEM_P (operands[1]) && optimize > 0)
+    {
+      rtx reg = gen_reg_rtx (SImode);
+
+      emit_insn (gen_zero_extend<mode>si2 (reg, operands[1]));
+      operands[1] = gen_lowpart (<MODE>mode, reg);
+    }
 })
 
+
 (define_expand "movsi"
   [(set (match_operand:SI 0 "general_operand" "")
        (match_operand:SI 1 "general_operand" ""))]