This works around an assumption in optabs, namely that if a widening-mul insn is available but no mul<mode>3 insn, then the widening multiplication insn is preferred over expanding the <mode> multiply as a libcall.

The problem occurs only if !AVR_HAVE_MUL, so I added that condition to respective mulsidi3 patterns in avr-dimode.md.

Ok for trunk, 5-branch and 4_9-branch?


        PR target/66956
        * config/avr/avr-dimode.md (<extend_u>mulsidi3_insn)
        (<extend_u>mulsidi3): Don't use if !AVR_HAVE_MUL.

Index: avr-dimode.md
===================================================================
--- avr-dimode.md	(revision 226011)
+++ avr-dimode.md	(working copy)
@@ -461,7 +461,8 @@ (define_expand "<extend_u>mulsidi3"
               (match_operand:SI 2 "general_operand" "")
               ;; Just to mention the iterator 
               (clobber (any_extend:SI (match_dup 1)))])]
-  "avr_have_dimode"
+  "avr_have_dimode
+   && AVR_HAVE_MUL"
   {
     avr_fix_inputs (operands, 1 << 2, regmask (SImode, 22));
     emit_move_insn (gen_rtx_REG (SImode, 22), operands[1]);
@@ -480,7 +481,8 @@ (define_insn "<extend_u>mulsidi3_insn"
                  (any_extend:DI (reg:SI 22))))
    (clobber (reg:HI REG_X))
    (clobber (reg:HI REG_Z))]
-  "avr_have_dimode"
+  "avr_have_dimode
+   && AVR_HAVE_MUL"
   "%~call __<extend_u>mulsidi3"
   [(set_attr "adjust_len" "call")
    (set_attr "cc" "clobber")])

Reply via email to