From: Amaury Sechet Date: Sat, 2 Mar 2019 14:28:59 +0000 (+0000) Subject: Add test case for add to sub transformation. NFC X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=954735141519398580615e0907a85ed0972b50cb;p=llvm Add test case for add to sub transformation. NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@355269 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/CodeGen/X86/add.ll b/test/CodeGen/X86/add.ll index a8c254f4b0f..c54711a93a7 100644 --- a/test/CodeGen/X86/add.ll +++ b/test/CodeGen/X86/add.ll @@ -477,3 +477,33 @@ define void @uaddo1_not(i32 %a, i32* %p0, i1* %p1) { store i1 %r1, i1* %p1 ret void } + +define i32 @add_to_sub(i32 %a, i32 %b) { +; X32-LABEL: add_to_sub: +; X32: # %bb.0: +; X32-NEXT: movl {{[0-9]+}}(%esp), %eax +; X32-NEXT: movl {{[0-9]+}}(%esp), %ecx +; X32-NEXT: notl %ecx +; X32-NEXT: leal 1(%ecx,%eax), %eax +; X32-NEXT: retl +; +; X64-LINUX-LABEL: add_to_sub: +; X64-LINUX: # %bb.0: +; X64-LINUX-NEXT: # kill: def $esi killed $esi def $rsi +; X64-LINUX-NEXT: # kill: def $edi killed $edi def $rdi +; X64-LINUX-NEXT: notl %edi +; X64-LINUX-NEXT: leal 1(%rdi,%rsi), %eax +; X64-LINUX-NEXT: retq +; +; X64-WIN32-LABEL: add_to_sub: +; X64-WIN32: # %bb.0: +; X64-WIN32-NEXT: # kill: def $edx killed $edx def $rdx +; X64-WIN32-NEXT: # kill: def $ecx killed $ecx def $rcx +; X64-WIN32-NEXT: notl %ecx +; X64-WIN32-NEXT: leal 1(%rcx,%rdx), %eax +; X64-WIN32-NEXT: retq + %nota = xor i32 %a, -1 + %add = add i32 %nota, %b + %r = add i32 %add, 1 + ret i32 %r +}