On 05/03/2016 08:50 AM, Oleg Endo wrote:
Hi,

The attached patch cleans up the SH div and mul patterns a bit.  Almost
no changes in CSiBE, except for a few minor improvements.

Tested on sh-elf with
make -k check RUNTESTFLAGS="--target_board=sh-sim\{-m2/-ml,-m2/-mb,
-m2a/-mb,-m4/-ml,-m4/-mb,-m4a/-ml,-m4a/-mb}"

Committed as r235803.

Cheers,
Oleg

gcc/ChangeLog:
        * config/sh/sh.md (udivsi3, divsi3, mulsi3): Simplify.
        (mulhisi3, umulhisi3, (smulsi3_highpart, umulsi3_highpart): Convert to
        define_insn_and_split.
        (mulsi3_i): New define_insn_and_split.
        (mulsi3_call): Convert to define_insn.
        (mulsidi3, mulsidi3_compact, umulsidi3, umulsidi3_compact):
        Remove constraints.


sh_cleanup_mul_div.patch


diff --git a/gcc/config/sh/sh.md b/gcc/config/sh/sh.md
index da1dfe9..2d9502b 100644
--- a/gcc/config/sh/sh.md
+++ b/gcc/config/sh/sh.md
@@ -2244,16 +2244,9 @@
(define_expand "udivsi3"
-  [(set (match_dup 3) (symbol_ref:SI "__udivsi3"))
-   (set (reg:SI R4_REG) (match_operand:SI 1 "general_operand" ""))
-   (set (reg:SI R5_REG) (match_operand:SI 2 "general_operand" ""))
-   (parallel [(set (match_operand:SI 0 "register_operand" "")
-                  (udiv:SI (reg:SI R4_REG)
-                           (reg:SI R5_REG)))
-             (clobber (reg:SI T_REG))
-             (clobber (reg:SI PR_REG))
-             (clobber (reg:SI R4_REG))
-             (use (match_dup 3))])]
+  [(set (match_operand:SI 0 "register_operand")
+       (udiv:SI (match_operand:SI 1 "general_operand")
+                (match_operand:SI 2 "general_operand")))]
    ""
  {
    rtx last;
@@ -2379,18 +2372,9 @@
     (set_attr "needs_delay_slot" "yes")])
(define_expand "divsi3"
-  [(set (match_dup 3) (symbol_ref:SI "__sdivsi3"))
-   (set (reg:SI R4_REG) (match_operand:SI 1 "general_operand" ""))
-   (set (reg:SI R5_REG) (match_operand:SI 2 "general_operand" ""))
-   (parallel [(set (match_operand:SI 0 "register_operand" "")
-                  (div:SI (reg:SI R4_REG)
-                          (reg:SI R5_REG)))
-             (clobber (reg:SI T_REG))
-             (clobber (reg:SI PR_REG))
-             (clobber (reg:SI R1_REG))
-             (clobber (reg:SI R2_REG))
-             (clobber (reg:SI R3_REG))
-             (use (match_dup 3))])]
+  [(set (match_operand:SI 0 "register_operand")
+       (div:SI (match_operand:SI 1 "general_operand")
+               (match_operand:SI 2 "general_operand")))]
    ""
  {
    rtx last;

Hi,

this caused PR83111 - "[sh] stack smashing detected in gen_udivsi3" ( https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83111 ).

Thanks,
- Tom

Reply via email to