(zero_extend:HI (match_dup 2)))]
"operands[2] = gen_rtx_REG (QImode, REGNO (operands[0]));")
-;; The compiler can synthesize a H8/300H variant of this which is
-;; just as efficient as one that we'd create
-(define_insn "zero_extendqisi2"
+(define_expand "zero_extendqisi2"
+ [(set (match_operand:SI 0 "register_operand" "")
+ (zero_extend:SI (match_operand:QI 1 "general_operand_src" "")))]
+ ""
+ "")
+
+(define_insn "*zero_extendqisi2_h8300"
[(set (match_operand:SI 0 "register_operand" "=r,r")
(zero_extend:SI (match_operand:QI 1 "general_operand_src" "0,g>")))]
"TARGET_H8300"
[(set_attr "length" "4,8")
(set_attr "cc" "clobber,clobber")])
+(define_insn "*zero_extendqisi2_h8300hs"
+ [(set (match_operand:SI 0 "register_operand" "=r,r")
+ (zero_extend:SI (match_operand:QI 1 "general_operand_src" "0,g>")))]
+ "TARGET_H8300H || TARGET_H8300S"
+ "@
+ extu.w %T0\;extu.l %S0
+ mov.b %R1,%w0\;extu.w %T0\;extu.l %S0"
+ [(set_attr "length" "4,12")
+ (set_attr "cc" "set_znv,set_znv")])
+
+(define_split
+ [(set (match_operand:SI 0 "register_operand" "")
+ (zero_extend:SI (match_operand:QI 1 "general_operand_src" "")))]
+ "(TARGET_H8300H || TARGET_H8300S)
+ && reg_overlap_mentioned_p (operands[0], operands[1])
+ && reload_completed"
+ [(set (match_dup 2)
+ (match_dup 1))
+ (set (match_dup 0)
+ (zero_extend:SI (match_dup 2)))]
+ "operands[2] = gen_rtx_REG (QImode, REGNO (operands[0]));")
+
+(define_split
+ [(set (match_operand:SI 0 "register_operand" "")
+ (zero_extend:SI (match_operand:QI 1 "general_operand_src" "")))]
+ "(TARGET_H8300H || TARGET_H8300S)
+ && !reg_overlap_mentioned_p (operands[0], operands[1])
+ && reload_completed"
+ [(set (match_dup 0)
+ (const_int 0))
+ (set (strict_low_part (match_dup 2))
+ (match_dup 1))]
+ "operands[2] = gen_rtx_REG (QImode, REGNO (operands[0]));")
+
(define_expand "zero_extendhisi2"
[(set (match_operand:SI 0 "register_operand" "")
(zero_extend:SI (match_operand:HI 1 "register_operand" "")))]