"REGNO (operands[0]) == REGNO (operands[1])
&& (<SWI48:MODE>mode != SImode
|| !TARGET_ZERO_EXTEND_WITH_AND
- || !optimize_function_for_speed_p (cfun))"
+ || !optimize_function_for_speed_p (cfun))
+ && !(optimize_insn_for_size_p () && optimize_size > 1)"
[(set (match_dup 0) (zero_extend:SWI48 (match_dup 2)))])
;; Likewise, but preserving FLAGS_REG.
|| !TARGET_ZERO_EXTEND_WITH_AND
|| !optimize_function_for_speed_p (cfun))"
[(set (match_dup 0) (zero_extend:SWI48 (match_dup 2)))])
+
+;; With -Oz, convert mov eax,200 (5 bytes) to xor eax,eax; mov al,200
+;; (4 bytes) when the flags register is dead.
+(define_peephole2
+ [(set (match_operand:SWI48 0 "any_QIreg_operand")
+ (match_operand:SWI48 1 "const_int_operand"))]
+ "optimize_insn_for_size_p () && optimize_size > 1
+ && IN_RANGE (INTVAL (operands[1]), 128, 255)
+ && peep2_regno_dead_p (0, FLAGS_REG)"
+ [(parallel [(set (match_dup 0) (const_int 0))
+ (clobber (reg:CC FLAGS_REG))])
+ (set (strict_low_part (match_dup 2)) (match_dup 3))]
+{
+ operands[2] = gen_lowpart (QImode, operands[0]);
+ operands[3] = gen_int_mode (INTVAL (operands[1]), QImode);
+})
+
+;; With -Oz, convert mov eax,512 (5 bytes) to xor eax,eax; mov ah,2
+;; (4 bytes) when the flags register is dead.
+(define_peephole2
+ [(set (match_operand:SWI48 0 "QIreg_operand")
+ (match_operand:SWI48 1 "const_int_operand"))]
+ "optimize_insn_for_size_p () && optimize_size > 1
+ && (INTVAL (operands[1]) & ~0xff00) == 0
+ && peep2_regno_dead_p (0, FLAGS_REG)"
+ [(parallel [(set (match_dup 0) (const_int 0))
+ (clobber (reg:CC FLAGS_REG))])
+ (set (zero_extract:SWI48 (match_dup 0) (const_int 8) (const_int 8))
+ (match_dup 2))]
+ "operands[2] = gen_int_mode (INTVAL (operands[1]) >> 8, QImode);")
\f
;; Sign extension instructions