operands[1] = force_reg (HImode, operands[1]);
})
-(define_insn "*bswaphi2_movbe"
+(define_insn "*movbehi2"
+ [(set (match_operand:HI 0 "nonimmediate_operand" "=r,m")
+ (bswap:HI (match_operand:HI 1 "nonimmediate_operand" "m,r")))]
+ "TARGET_MOVBE
+ && MEM_P (operands[0]) != MEM_P (operands[1])
+ && reload_completed"
+ "movbe{w}\t{%1, %0|%0, %1}"
+ [(set_attr "type" "imov")
+ (set_attr "modrm" "1")
+ (set_attr "prefix_0f" "1")
+ (set_attr "prefix_extra" "1")
+ (set_attr "mode" "HI")])
+
+;; Convert movbe to avoid flags dependency.
+(define_insn_and_split "*bswaphi2_movbe"
[(set (match_operand:HI 0 "nonimmediate_operand" "=Q,r,r,m")
(bswap:HI (match_operand:HI 1 "nonimmediate_operand" "0,0,m,r")))
(clobber (reg:CC FLAGS_REG))]
"@
xchg{b}\t{%h0, %b0|%b0, %h0}
rol{w}\t{$8, %0|%0, 8}
- movbe{w}\t{%1, %0|%0, %1}
- movbe{w}\t{%1, %0|%0, %1}"
+ #
+ #"
+ "&& MEM_P (operands[0]) != MEM_P (operands[1])
+ && reload_completed"
+ [(set (match_dup 0)
+ (bswap:HI (match_dup 1)))]
+ ""
[(set_attr "type" "imov,rotate1,imov,imov")
(set_attr "modrm" "*,*,1,1")
(set_attr "prefix_0f" "*,*,1,1")