[llvm-commits] [llvm] r62661 - in /llvm/trunk: lib/Target/X86/X86InstrInfo.td test/CodeGen/X86/xor_not.ll

Dan Gohman gohman at apple.com
Tue Jan 20 19:00:49 PST 2009


Hi Evan,

Please make the corresponding change for 64-bit instructions too.

Thanks,

Dan

On Jan 20, 2009, at 6:09 PM, Evan Cheng wrote:

> Author: evancheng
> Date: Tue Jan 20 20:09:05 2009
> New Revision: 62661
>
> URL: http://llvm.org/viewvc/llvm-project?rev=62661&view=rev
> Log:
> Favors generating "not" over "xor -1". For example.
> unsigned test(unsigned a) {
>  return ~a;
> }
> llvm used to generate:
> movl    $4294967295, %eax
> xorl    4(%esp), %eax
>
> Now it generates:
> movl      4(%esp), %eax
> notl      %eax
>
> It's 3 bytes shorter.
>
> Modified:
>    llvm/trunk/lib/Target/X86/X86InstrInfo.td
>    llvm/trunk/test/CodeGen/X86/xor_not.ll
>
> Modified: llvm/trunk/lib/Target/X86/X86InstrInfo.td
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86InstrInfo.td?rev=62661&r1=62660&r2=62661&view=diff
>
> =
> =
> =
> =
> =
> =
> =
> =
> ======================================================================
> --- llvm/trunk/lib/Target/X86/X86InstrInfo.td (original)
> +++ llvm/trunk/lib/Target/X86/X86InstrInfo.td Tue Jan 20 20:09:05 2009
> @@ -1235,12 +1235,15 @@
> }
> } // Defs = [EFLAGS]
>
> +// Match xor -1 to not. Favors these over a move imm + xor to save  
> code size.
> +let AddedComplexity = 15 in {
> def NOT8r  : I<0xF6, MRM2r, (outs GR8 :$dst), (ins GR8 :$src),  
> "not{b}\t$dst",
>                [(set GR8:$dst, (not GR8:$src))]>;
> def NOT16r : I<0xF7, MRM2r, (outs GR16:$dst), (ins GR16:$src),  
> "not{w}\t$dst",
>                [(set GR16:$dst, (not GR16:$src))]>, OpSize;
> def NOT32r : I<0xF7, MRM2r, (outs GR32:$dst), (ins GR32:$src),  
> "not{l}\t$dst",
>                [(set GR32:$dst, (not GR32:$src))]>;
> +}
> let isTwoAddress = 0 in {
>   def NOT8m  : I<0xF6, MRM2m, (outs), (ins i8mem :$dst), "not{b}\t 
> $dst",
>                  [(store (not (loadi8 addr:$dst)), addr:$dst)]>;
>
> Modified: llvm/trunk/test/CodeGen/X86/xor_not.ll
> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/xor_not.ll?rev=62661&r1=62660&r2=62661&view=diff
>
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> = 
> ======================================================================
> --- llvm/trunk/test/CodeGen/X86/xor_not.ll (original)
> +++ llvm/trunk/test/CodeGen/X86/xor_not.ll Tue Jan 20 20:09:05 2009
> @@ -1,4 +1,4 @@
> -; RUN: llvm-as < %s | llc -march=x86 | grep {not\[lwb\]} | count 3
> +; RUN: llvm-as < %s | llc -march=x86 | grep {not\[lwb\]} | count 4
> ; RUN: llvm-as < %s | llc -march=x86-64 | grep {not\[lwb\]}  | count 4
> define i32 @test(i32 %a, i32 %b) nounwind  {
> entry:
>
>
> _______________________________________________
> llvm-commits mailing list
> llvm-commits at cs.uiuc.edu
> http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list