Commit 6deb5197 by Georg-Johann Lay Committed by Georg-Johann Lay

avr.md: (umulqihi3, mulqihi3): Write as one pattern.

	* config/avr/avr.md: (umulqihi3, mulqihi3): Write as one pattern.
	(umulqi3_highpart, smulqi3_highpart): Ditto.
	(*maddqihi4.const, *umaddqihi4.uconst): Ditto.
	(*msubqihi4.const, *umsubqihi4.uconst): Ditto.
	(*muluqihi3.uconst, *mulsqihi3.sconst): Ditto.

From-SVN: r178913
parent 1b65da7d
2011-09-16 Georg-Johann Lay <avr@gjlay.de> 2011-09-16 Georg-Johann Lay <avr@gjlay.de>
* config/avr/avr.md: (umulqihi3, mulqihi3): Write as one pattern.
(umulqi3_highpart, smulqi3_highpart): Ditto.
(*maddqihi4.const, *umaddqihi4.uconst): Ditto.
(*msubqihi4.const, *umsubqihi4.uconst): Ditto.
(*muluqihi3.uconst, *mulsqihi3.sconst): Ditto.
2011-09-16 Georg-Johann Lay <avr@gjlay.de>
PR target/50358 PR target/50358
* config/avr/avr.md (*ashiftqihi2.signx.1): New insn. * config/avr/avr.md (*ashiftqihi2.signx.1): New insn.
(*maddqi4, *maddqi4.const): New insns. (*maddqi4, *maddqi4.const): New insns.
...@@ -1027,31 +1027,21 @@ ...@@ -1027,31 +1027,21 @@
[(set_attr "type" "xcall") [(set_attr "type" "xcall")
(set_attr "cc" "clobber")]) (set_attr "cc" "clobber")])
(define_insn "smulqi3_highpart" ;; "umulqi3_highpart"
;; "smulqi3_highpart"
(define_insn "<extend_su>mulqi3_highpart"
[(set (match_operand:QI 0 "register_operand" "=r") [(set (match_operand:QI 0 "register_operand" "=r")
(truncate:QI (truncate:QI
(lshiftrt:HI (mult:HI (sign_extend:HI (match_operand:QI 1 "register_operand" "d")) (lshiftrt:HI (mult:HI (any_extend:HI (match_operand:QI 1 "register_operand" "<mul_r_d>"))
(sign_extend:HI (match_operand:QI 2 "register_operand" "d"))) (any_extend:HI (match_operand:QI 2 "register_operand" "<mul_r_d>")))
(const_int 8))))] (const_int 8))))]
"AVR_HAVE_MUL" "AVR_HAVE_MUL"
"muls %1,%2 "mul<extend_s> %1,%2
mov %0,r1 mov %0,r1
clr __zero_reg__" clr __zero_reg__"
[(set_attr "length" "3") [(set_attr "length" "3")
(set_attr "cc" "clobber")]) (set_attr "cc" "clobber")])
(define_insn "umulqi3_highpart"
[(set (match_operand:QI 0 "register_operand" "=r")
(truncate:QI
(lshiftrt:HI (mult:HI (zero_extend:HI (match_operand:QI 1 "register_operand" "r"))
(zero_extend:HI (match_operand:QI 2 "register_operand" "r")))
(const_int 8))))]
"AVR_HAVE_MUL"
"mul %1,%2
mov %0,r1
clr __zero_reg__"
[(set_attr "length" "3")
(set_attr "cc" "clobber")])
;; Used when expanding div or mod inline for some special values ;; Used when expanding div or mod inline for some special values
(define_insn "*subqi3.ashiftrt7" (define_insn "*subqi3.ashiftrt7"
...@@ -1064,25 +1054,16 @@ ...@@ -1064,25 +1054,16 @@
[(set_attr "length" "2") [(set_attr "length" "2")
(set_attr "cc" "clobber")]) (set_attr "cc" "clobber")])
(define_insn "mulqihi3" ;; "umulqihi3"
;; "mulqihi3"
(define_insn "<extend_u>mulqihi3"
[(set (match_operand:HI 0 "register_operand" "=r") [(set (match_operand:HI 0 "register_operand" "=r")
(mult:HI (sign_extend:HI (match_operand:QI 1 "register_operand" "d")) (mult:HI (any_extend:HI (match_operand:QI 1 "register_operand" "<mul_r_d>"))
(sign_extend:HI (match_operand:QI 2 "register_operand" "d"))))] (any_extend:HI (match_operand:QI 2 "register_operand" "<mul_r_d>"))))]
"AVR_HAVE_MUL"
"muls %1,%2
movw %0,r0
clr r1"
[(set_attr "length" "3")
(set_attr "cc" "clobber")])
(define_insn "umulqihi3"
[(set (match_operand:HI 0 "register_operand" "=r")
(mult:HI (zero_extend:HI (match_operand:QI 1 "register_operand" "r"))
(zero_extend:HI (match_operand:QI 2 "register_operand" "r"))))]
"AVR_HAVE_MUL" "AVR_HAVE_MUL"
"mul %1,%2 "mul<extend_s> %1,%2
movw %0,r0 movw %0,r0
clr r1" clr __zero_reg__"
[(set_attr "length" "3") [(set_attr "length" "3")
(set_attr "cc" "clobber")]) (set_attr "cc" "clobber")])
...@@ -1293,10 +1274,12 @@ ...@@ -1293,10 +1274,12 @@
;; Handle small constants ;; Handle small constants
(define_insn_and_split "*umaddqihi4.uconst" ;; "umaddqihi4.uconst"
;; "maddqihi4.sconst"
(define_insn_and_split "*<extend_u>maddqihi4.<extend_su>const"
[(set (match_operand:HI 0 "register_operand" "=r") [(set (match_operand:HI 0 "register_operand" "=r")
(plus:HI (mult:HI (zero_extend:HI (match_operand:QI 1 "register_operand" "r")) (plus:HI (mult:HI (any_extend:HI (match_operand:QI 1 "register_operand" "<mul_r_d>"))
(match_operand:HI 2 "u8_operand" "M")) (match_operand:HI 2 "<extend_su>8_operand" "n"))
(match_operand:HI 3 "register_operand" "0"))) (match_operand:HI 3 "register_operand" "0")))
(clobber (match_scratch:QI 4 "=&d"))] (clobber (match_scratch:QI 4 "=&d"))]
"AVR_HAVE_MUL" "AVR_HAVE_MUL"
...@@ -1304,31 +1287,33 @@ ...@@ -1304,31 +1287,33 @@
"&& reload_completed" "&& reload_completed"
[(set (match_dup 4) [(set (match_dup 4)
(match_dup 2)) (match_dup 2))
; *umaddqihi4 ; *umaddqihi4 resp. *maddqihi4
(set (match_dup 0) (set (match_dup 0)
(plus:HI (mult:HI (zero_extend:HI (match_dup 1)) (plus:HI (mult:HI (any_extend:HI (match_dup 1))
(zero_extend:HI (match_dup 4))) (any_extend:HI (match_dup 4)))
(match_dup 3)))] (match_dup 3)))]
{ {
operands[2] = gen_int_mode (INTVAL (operands[2]), QImode); operands[2] = gen_int_mode (INTVAL (operands[2]), QImode);
}) })
(define_insn_and_split "*umsubqihi4.uconst" ;; "*umsubqihi4.uconst"
;; "*msubqihi4.sconst"
(define_insn_and_split "*<extend_u>msubqihi4.<extend_su>const"
[(set (match_operand:HI 0 "register_operand" "=r") [(set (match_operand:HI 0 "register_operand" "=r")
(minus:HI (match_operand:HI 3 "register_operand" "0") (minus:HI (match_operand:HI 3 "register_operand" "0")
(mult:HI (zero_extend:HI (match_operand:QI 1 "register_operand" "r")) (mult:HI (any_extend:HI (match_operand:QI 1 "register_operand" "<mul_r_d>"))
(match_operand:HI 2 "u8_operand" "M")))) (match_operand:HI 2 "<extend_su>8_operand" "n"))))
(clobber (match_scratch:QI 4 "=&d"))] (clobber (match_scratch:QI 4 "=&d"))]
"AVR_HAVE_MUL" "AVR_HAVE_MUL"
"#" "#"
"&& reload_completed" "&& reload_completed"
[(set (match_dup 4) [(set (match_dup 4)
(match_dup 2)) (match_dup 2))
; *umsubqihi4 ; *umsubqihi4 resp. *msubqihi4
(set (match_dup 0) (set (match_dup 0)
(minus:HI (match_dup 3) (minus:HI (match_dup 3)
(mult:HI (zero_extend:HI (match_dup 1)) (mult:HI (any_extend:HI (match_dup 1))
(zero_extend:HI (match_dup 4)))))] (any_extend:HI (match_dup 4)))))]
{ {
operands[2] = gen_int_mode (INTVAL (operands[2]), QImode); operands[2] = gen_int_mode (INTVAL (operands[2]), QImode);
}) })
...@@ -1356,46 +1341,6 @@ ...@@ -1356,46 +1341,6 @@
operands[2] = gen_int_mode (1 << INTVAL (operands[2]), QImode); operands[2] = gen_int_mode (1 << INTVAL (operands[2]), QImode);
}) })
(define_insn_and_split "*maddqihi4.sconst"
[(set (match_operand:HI 0 "register_operand" "=r")
(plus:HI (mult:HI (sign_extend:HI (match_operand:QI 1 "register_operand" "d"))
(match_operand:HI 2 "s8_operand" "n"))
(match_operand:HI 3 "register_operand" "0")))
(clobber (match_scratch:QI 4 "=&d"))]
"AVR_HAVE_MUL"
"#"
"&& reload_completed"
[(set (match_dup 4)
(match_dup 2))
; *maddqihi4
(set (match_dup 0)
(plus:HI (mult:HI (sign_extend:HI (match_dup 1))
(sign_extend:HI (match_dup 4)))
(match_dup 3)))]
{
operands[2] = gen_int_mode (INTVAL (operands[2]), QImode);
})
(define_insn_and_split "*msubqihi4.sconst"
[(set (match_operand:HI 0 "register_operand" "=r")
(minus:HI (match_operand:HI 3 "register_operand" "0")
(mult:HI (sign_extend:HI (match_operand:QI 1 "register_operand" "d"))
(match_operand:HI 2 "s8_operand" "M"))))
(clobber (match_scratch:QI 4 "=&d"))]
"AVR_HAVE_MUL"
"#"
"&& reload_completed"
[(set (match_dup 4)
(match_dup 2))
; *smsubqihi4
(set (match_dup 0)
(minus:HI (match_dup 3)
(mult:HI (sign_extend:HI (match_dup 1))
(sign_extend:HI (match_dup 4)))))]
{
operands[2] = gen_int_mode (INTVAL (operands[2]), QImode);
})
;; Same as the insn above, but combiner tries versions canonicalized to ASHIFT ;; Same as the insn above, but combiner tries versions canonicalized to ASHIFT
;; for MULT with power of 2 and skips trying MULT insn above. We omit 128 ;; for MULT with power of 2 and skips trying MULT insn above. We omit 128
;; because this would require an extra pattern for just one value. ;; because this would require an extra pattern for just one value.
...@@ -1469,20 +1414,22 @@ ...@@ -1469,20 +1414,22 @@
; mul HI: $1 = sign/zero-extend, $2 = small constant ; mul HI: $1 = sign/zero-extend, $2 = small constant
;****************************************************************************** ;******************************************************************************
(define_insn_and_split "*muluqihi3.uconst" ;; "*muluqihi3.uconst"
;; "*mulsqihi3.sconst"
(define_insn_and_split "*mul<extend_su>qihi3.<extend_su>const"
[(set (match_operand:HI 0 "register_operand" "=r") [(set (match_operand:HI 0 "register_operand" "=r")
(mult:HI (zero_extend:HI (match_operand:QI 1 "register_operand" "r")) (mult:HI (any_extend:HI (match_operand:QI 1 "register_operand" "<mul_r_d>"))
(match_operand:HI 2 "u8_operand" "M"))) (match_operand:HI 2 "<extend_su>8_operand" "n")))
(clobber (match_scratch:QI 3 "=&d"))] (clobber (match_scratch:QI 3 "=&d"))]
"AVR_HAVE_MUL" "AVR_HAVE_MUL"
"#" "#"
"&& reload_completed" "&& reload_completed"
[(set (match_dup 3) [(set (match_dup 3)
(match_dup 2)) (match_dup 2))
; umulqihi3 ; umulqihi3 resp. mulqihi3
(set (match_dup 0) (set (match_dup 0)
(mult:HI (zero_extend:HI (match_dup 1)) (mult:HI (any_extend:HI (match_dup 1))
(zero_extend:HI (match_dup 3))))] (any_extend:HI (match_dup 3))))]
{ {
operands[2] = gen_int_mode (INTVAL (operands[2]), QImode); operands[2] = gen_int_mode (INTVAL (operands[2]), QImode);
}) })
...@@ -1505,24 +1452,6 @@ ...@@ -1505,24 +1452,6 @@
operands[2] = gen_int_mode (INTVAL (operands[2]), QImode); operands[2] = gen_int_mode (INTVAL (operands[2]), QImode);
}) })
(define_insn_and_split "*mulsqihi3.sconst"
[(set (match_operand:HI 0 "register_operand" "=r")
(mult:HI (sign_extend:HI (match_operand:QI 1 "register_operand" "d"))
(match_operand:HI 2 "s8_operand" "n")))
(clobber (match_scratch:QI 3 "=&d"))]
"AVR_HAVE_MUL"
"#"
"&& reload_completed"
[(set (match_dup 3)
(match_dup 2))
; mulqihi3
(set (match_dup 0)
(mult:HI (sign_extend:HI (match_dup 1))
(sign_extend:HI (match_dup 3))))]
{
operands[2] = gen_int_mode (INTVAL (operands[2]), QImode);
})
(define_insn_and_split "*mulsqihi3.uconst" (define_insn_and_split "*mulsqihi3.uconst"
[(set (match_operand:HI 0 "register_operand" "=r") [(set (match_operand:HI 0 "register_operand" "=r")
(mult:HI (sign_extend:HI (match_operand:QI 1 "register_operand" "a")) (mult:HI (sign_extend:HI (match_operand:QI 1 "register_operand" "a"))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment