[NDS32] Add divsi4 and udivsi4 patterns.
authorChung-Ju Wu <jasonwucj@gmail.com>
Thu, 5 Apr 2018 03:05:45 +0000 (03:05 +0000)
committerChung-Ju Wu <jasonwucj@gcc.gnu.org>
Thu, 5 Apr 2018 03:05:45 +0000 (03:05 +0000)
gcc/
* config/nds32/nds32.md (divsi4, udivsi4): New patterns.

From-SVN: r259119

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

index cb27056da934e8e8ffc418cdb099a9fdc40d3632..485c59ea79761d20655b97f1e4d8ac563d5a433a 100644 (file)
@@ -1,3 +1,7 @@
+2018-04-05  Chung-Ju Wu  <jasonwucj@gmail.com>
+
+       * config/nds32/nds32.md (divsi4, udivsi4): New patterns.
+
 2018-04-05  Chung-Ju Wu  <jasonwucj@gmail.com>
 
        * config/nds32/nds32.md (negsi2): Refine pattern.
index f69dd9de92fb3dbb0640af191a8b0c1d98746ef9..2d0f1d3e91bf70507b5f210ab6731b40713b5365 100644 (file)
   [(set_attr "type"   "div")
    (set_attr "length"   "4")])
 
+;; divsr/divr will keep quotient only when quotient and remainder is the same
+;; register in our ISA spec, it's can reduce 1 register presure if we don't
+;; want remainder.
+(define_insn "divsi4"
+  [(set (match_operand:SI 0 "register_operand"         "=r")
+       (div:SI (match_operand:SI 1 "register_operand" " r")
+               (match_operand:SI 2 "register_operand" " r")))]
+  ""
+  "divsr\t%0, %0, %1, %2"
+  [(set_attr "type"   "div")
+   (set_attr "length"   "4")])
+
+(define_insn "udivsi4"
+  [(set (match_operand:SI 0 "register_operand"          "=r")
+       (udiv:SI (match_operand:SI 1 "register_operand" " r")
+                (match_operand:SI 2 "register_operand"  " r")))]
+  ""
+  "divr\t%0, %0, %1, %2"
+  [(set_attr "type"   "div")
+   (set_attr "length"   "4")])
 
 ;; ----------------------------------------------------------------------------