PATCH: Support -mmovbe

Uros Bizjak ubizjak@gmail.com
Thu May 21 17:38:00 GMT 2009


H.J. Lu wrote:

>>>> +(define_insn "*movbedi2"
>>>> + �[(set (match_operand:DI 0 "nonimmediate_operand" "=r,m")
>>>> + � � � (bswap:DI (match_operand:DI 1 "nonimmediate_operand" "m,r")))]
>>>> + �"TARGET_MOVBE && TARGET_64BIT"
>>>> + �"movbe\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" "DI")])
>>>>         
>>> Also the pattern above; it should be integrated with existing bswapdi2.
>>>       
>> movbe doesn't support "movbe reg, reg".
>>     

Sure, but attached patch automatically emits bswap in this case.

> It is much cleaner to have a separate pattern since expander is
>   

The constraints on expanders are actually not that important. The 
constraints on the insns pattern operands are what matters, and combine 
does a great job to merge memory operands whenever it can.
> (define_expand "bswapsi2"
>   [(set (match_operand:SI 0 "register_operand" "")
>         (bswap:SI (match_operand:SI 1 "register_operand" "")))]
>
> The new movbe pattern will be used optimizer.
>   

Please see attached i386.md part of the patch. The patch assumes that 
TARGET_MOVBE also supports bswap insn, so following part is not needed 
anymore:

+  /* Enable bswap if movbe is enabled.  */
+  if (TARGET_MOVBE)
+    TARGET_BSWAP = 1;
+


BTW: the patch uses shadowing to select between two patterns.

Uros.

-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: p.diff.txt
URL: <http://gcc.gnu.org/pipermail/gcc-patches/attachments/20090521/78914fca/attachment.txt>


More information about the Gcc-patches mailing list