summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--llvm/test/CodeGen/X86/add.ll30
1 files changed, 30 insertions, 0 deletions
diff --git a/llvm/test/CodeGen/X86/add.ll b/llvm/test/CodeGen/X86/add.ll
index a8c254f4b0f..c54711a93a7 100644
--- a/llvm/test/CodeGen/X86/add.ll
+++ b/llvm/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
+}
OpenPOWER on IntegriCloud