[llvm] r361409 - [NFC][X86][AArch64] Add tests for missing (x - y) + -1 -> not(y) + x fold

Roman Lebedev via llvm-commits llvm-commits at lists.llvm.org
Wed May 22 09:58:26 PDT 2019


Author: lebedevri
Date: Wed May 22 09:58:26 2019
New Revision: 361409

URL: http://llvm.org/viewvc/llvm-project?rev=361409&view=rev
Log:
[NFC][X86][AArch64] Add tests for missing (x - y) + -1  ->  not(y) + x  fold

https://rise4fun.com/Alive/OaY

Modified:
    llvm/trunk/test/CodeGen/AArch64/xor.ll
    llvm/trunk/test/CodeGen/X86/xor.ll

Modified: llvm/trunk/test/CodeGen/AArch64/xor.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/AArch64/xor.ll?rev=361409&r1=361408&r2=361409&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/AArch64/xor.ll (original)
+++ llvm/trunk/test/CodeGen/AArch64/xor.ll Wed May 22 09:58:26 2019
@@ -15,3 +15,72 @@ define i32 @PR39657(i8* %p, i64 %x) {
   ret i32 %load
 }
 
+define i32 @add_of_not(i32 %x, i32 %y) {
+; CHECK-LABEL: add_of_not:
+; CHECK:       // %bb.0:
+; CHECK-NEXT:    sub w8, w0, w1
+; CHECK-NEXT:    sub w0, w8, #1 // =1
+; CHECK-NEXT:    ret
+  %t0 = sub i32 %x, %y
+  %r = add i32 %t0, -1
+  ret i32 %r
+}
+
+define i32 @add_of_not_decrement(i32 %x, i32 %y) {
+; CHECK-LABEL: add_of_not_decrement:
+; CHECK:       // %bb.0:
+; CHECK-NEXT:    sub w8, w0, w1
+; CHECK-NEXT:    sub w0, w8, #1 // =1
+; CHECK-NEXT:    ret
+  %t0 = sub i32 %x, %y
+  %r = sub i32 %t0, 1
+  ret i32 %r
+}
+
+define <4 x i32> @vec_add_of_not(<4 x i32> %x, <4 x i32> %y) {
+; CHECK-LABEL: vec_add_of_not:
+; CHECK:       // %bb.0:
+; CHECK-NEXT:    sub v0.4s, v0.4s, v1.4s
+; CHECK-NEXT:    movi v1.2d, #0xffffffffffffffff
+; CHECK-NEXT:    add v0.4s, v0.4s, v1.4s
+; CHECK-NEXT:    ret
+  %t0 = sub <4 x i32> %x, %y
+  %r = add <4 x i32> %t0, <i32 -1, i32 -1, i32 -1, i32 -1>
+  ret <4 x i32> %r
+}
+
+define <4 x i32> @vec_add_of_not_decrement(<4 x i32> %x, <4 x i32> %y) {
+; CHECK-LABEL: vec_add_of_not_decrement:
+; CHECK:       // %bb.0:
+; CHECK-NEXT:    sub v0.4s, v0.4s, v1.4s
+; CHECK-NEXT:    movi v1.4s, #1
+; CHECK-NEXT:    sub v0.4s, v0.4s, v1.4s
+; CHECK-NEXT:    ret
+  %t0 = sub <4 x i32> %x, %y
+  %r = sub <4 x i32> %t0, <i32 1, i32 1, i32 1, i32 1>
+  ret <4 x i32> %r
+}
+
+define <4 x i32> @vec_add_of_not_with_undef(<4 x i32> %x, <4 x i32> %y) {
+; CHECK-LABEL: vec_add_of_not_with_undef:
+; CHECK:       // %bb.0:
+; CHECK-NEXT:    sub v0.4s, v0.4s, v1.4s
+; CHECK-NEXT:    movi v1.2d, #0xffffffffffffffff
+; CHECK-NEXT:    add v0.4s, v0.4s, v1.4s
+; CHECK-NEXT:    ret
+  %t0 = sub <4 x i32> %x, %y
+  %r = add <4 x i32> %t0, <i32 -1, i32 undef, i32 -1, i32 -1>
+  ret <4 x i32> %r
+}
+
+define <4 x i32> @vec_add_of_not_with_undef_decrement(<4 x i32> %x, <4 x i32> %y) {
+; CHECK-LABEL: vec_add_of_not_with_undef_decrement:
+; CHECK:       // %bb.0:
+; CHECK-NEXT:    sub v0.4s, v0.4s, v1.4s
+; CHECK-NEXT:    movi v1.4s, #1
+; CHECK-NEXT:    add v0.4s, v0.4s, v1.4s
+; CHECK-NEXT:    ret
+  %t0 = sub <4 x i32> %x, %y
+  %r = add <4 x i32> %t0, <i32 1, i32 undef, i32 1, i32 1>
+  ret <4 x i32> %r
+}

Modified: llvm/trunk/test/CodeGen/X86/xor.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/xor.ll?rev=361409&r1=361408&r2=361409&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/xor.ll (original)
+++ llvm/trunk/test/CodeGen/X86/xor.ll Wed May 22 09:58:26 2019
@@ -528,3 +528,162 @@ define i32 @PR39657(i8* %p, i64 %x) {
   ret i32 %load
 }
 
+define i32 @add_of_not(i32 %x, i32 %y) {
+; X32-LABEL: add_of_not:
+; X32:       # %bb.0:
+; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; X32-NEXT:    subl {{[0-9]+}}(%esp), %eax
+; X32-NEXT:    decl %eax
+; X32-NEXT:    retl
+;
+; X64-LIN-LABEL: add_of_not:
+; X64-LIN:       # %bb.0:
+; X64-LIN-NEXT:    # kill: def $edi killed $edi def $rdi
+; X64-LIN-NEXT:    subl %esi, %edi
+; X64-LIN-NEXT:    leal -1(%rdi), %eax
+; X64-LIN-NEXT:    retq
+;
+; X64-WIN-LABEL: add_of_not:
+; X64-WIN:       # %bb.0:
+; X64-WIN-NEXT:    # kill: def $ecx killed $ecx def $rcx
+; X64-WIN-NEXT:    subl %edx, %ecx
+; X64-WIN-NEXT:    leal -1(%rcx), %eax
+; X64-WIN-NEXT:    retq
+  %t0 = sub i32 %x, %y
+  %r = add i32 %t0, -1
+  ret i32 %r
+}
+
+define i32 @add_of_not_decrement(i32 %x, i32 %y) {
+; X32-LABEL: add_of_not_decrement:
+; X32:       # %bb.0:
+; X32-NEXT:    movl {{[0-9]+}}(%esp), %eax
+; X32-NEXT:    subl {{[0-9]+}}(%esp), %eax
+; X32-NEXT:    decl %eax
+; X32-NEXT:    retl
+;
+; X64-LIN-LABEL: add_of_not_decrement:
+; X64-LIN:       # %bb.0:
+; X64-LIN-NEXT:    # kill: def $edi killed $edi def $rdi
+; X64-LIN-NEXT:    subl %esi, %edi
+; X64-LIN-NEXT:    leal -1(%rdi), %eax
+; X64-LIN-NEXT:    retq
+;
+; X64-WIN-LABEL: add_of_not_decrement:
+; X64-WIN:       # %bb.0:
+; X64-WIN-NEXT:    # kill: def $ecx killed $ecx def $rcx
+; X64-WIN-NEXT:    subl %edx, %ecx
+; X64-WIN-NEXT:    leal -1(%rcx), %eax
+; X64-WIN-NEXT:    retq
+  %t0 = sub i32 %x, %y
+  %r = sub i32 %t0, 1
+  ret i32 %r
+}
+
+define <4 x i32> @vec_add_of_not(<4 x i32> %x, <4 x i32> %y) {
+; X32-LABEL: vec_add_of_not:
+; X32:       # %bb.0:
+; X32-NEXT:    psubd %xmm1, %xmm0
+; X32-NEXT:    pcmpeqd %xmm1, %xmm1
+; X32-NEXT:    paddd %xmm1, %xmm0
+; X32-NEXT:    retl
+;
+; X64-LIN-LABEL: vec_add_of_not:
+; X64-LIN:       # %bb.0:
+; X64-LIN-NEXT:    psubd %xmm1, %xmm0
+; X64-LIN-NEXT:    pcmpeqd %xmm1, %xmm1
+; X64-LIN-NEXT:    paddd %xmm1, %xmm0
+; X64-LIN-NEXT:    retq
+;
+; X64-WIN-LABEL: vec_add_of_not:
+; X64-WIN:       # %bb.0:
+; X64-WIN-NEXT:    movdqa (%rcx), %xmm1
+; X64-WIN-NEXT:    psubd (%rdx), %xmm1
+; X64-WIN-NEXT:    pcmpeqd %xmm0, %xmm0
+; X64-WIN-NEXT:    paddd %xmm1, %xmm0
+; X64-WIN-NEXT:    retq
+  %t0 = sub <4 x i32> %x, %y
+  %r = add <4 x i32> %t0, <i32 -1, i32 -1, i32 -1, i32 -1>
+  ret <4 x i32> %r
+}
+
+define <4 x i32> @vec_add_of_not_decrement(<4 x i32> %x, <4 x i32> %y) {
+; X32-LABEL: vec_add_of_not_decrement:
+; X32:       # %bb.0:
+; X32-NEXT:    psubd %xmm1, %xmm0
+; X32-NEXT:    pcmpeqd %xmm1, %xmm1
+; X32-NEXT:    paddd %xmm1, %xmm0
+; X32-NEXT:    retl
+;
+; X64-LIN-LABEL: vec_add_of_not_decrement:
+; X64-LIN:       # %bb.0:
+; X64-LIN-NEXT:    psubd %xmm1, %xmm0
+; X64-LIN-NEXT:    pcmpeqd %xmm1, %xmm1
+; X64-LIN-NEXT:    paddd %xmm1, %xmm0
+; X64-LIN-NEXT:    retq
+;
+; X64-WIN-LABEL: vec_add_of_not_decrement:
+; X64-WIN:       # %bb.0:
+; X64-WIN-NEXT:    movdqa (%rcx), %xmm1
+; X64-WIN-NEXT:    psubd (%rdx), %xmm1
+; X64-WIN-NEXT:    pcmpeqd %xmm0, %xmm0
+; X64-WIN-NEXT:    paddd %xmm1, %xmm0
+; X64-WIN-NEXT:    retq
+  %t0 = sub <4 x i32> %x, %y
+  %r = sub <4 x i32> %t0, <i32 1, i32 1, i32 1, i32 1>
+  ret <4 x i32> %r
+}
+
+define <4 x i32> @vec_add_of_not_with_undef(<4 x i32> %x, <4 x i32> %y) {
+; X32-LABEL: vec_add_of_not_with_undef:
+; X32:       # %bb.0:
+; X32-NEXT:    psubd %xmm1, %xmm0
+; X32-NEXT:    pcmpeqd %xmm1, %xmm1
+; X32-NEXT:    paddd %xmm1, %xmm0
+; X32-NEXT:    retl
+;
+; X64-LIN-LABEL: vec_add_of_not_with_undef:
+; X64-LIN:       # %bb.0:
+; X64-LIN-NEXT:    psubd %xmm1, %xmm0
+; X64-LIN-NEXT:    pcmpeqd %xmm1, %xmm1
+; X64-LIN-NEXT:    paddd %xmm1, %xmm0
+; X64-LIN-NEXT:    retq
+;
+; X64-WIN-LABEL: vec_add_of_not_with_undef:
+; X64-WIN:       # %bb.0:
+; X64-WIN-NEXT:    movdqa (%rcx), %xmm1
+; X64-WIN-NEXT:    psubd (%rdx), %xmm1
+; X64-WIN-NEXT:    pcmpeqd %xmm0, %xmm0
+; X64-WIN-NEXT:    paddd %xmm1, %xmm0
+; X64-WIN-NEXT:    retq
+  %t0 = sub <4 x i32> %x, %y
+  %r = add <4 x i32> %t0, <i32 -1, i32 undef, i32 -1, i32 -1>
+  ret <4 x i32> %r
+}
+
+define <4 x i32> @vec_add_of_not_with_undef_decrement(<4 x i32> %x, <4 x i32> %y) {
+; X32-LABEL: vec_add_of_not_with_undef_decrement:
+; X32:       # %bb.0:
+; X32-NEXT:    psubd %xmm1, %xmm0
+; X32-NEXT:    pcmpeqd %xmm1, %xmm1
+; X32-NEXT:    psubd %xmm1, %xmm0
+; X32-NEXT:    retl
+;
+; X64-LIN-LABEL: vec_add_of_not_with_undef_decrement:
+; X64-LIN:       # %bb.0:
+; X64-LIN-NEXT:    psubd %xmm1, %xmm0
+; X64-LIN-NEXT:    pcmpeqd %xmm1, %xmm1
+; X64-LIN-NEXT:    psubd %xmm1, %xmm0
+; X64-LIN-NEXT:    retq
+;
+; X64-WIN-LABEL: vec_add_of_not_with_undef_decrement:
+; X64-WIN:       # %bb.0:
+; X64-WIN-NEXT:    movdqa (%rcx), %xmm0
+; X64-WIN-NEXT:    psubd (%rdx), %xmm0
+; X64-WIN-NEXT:    pcmpeqd %xmm1, %xmm1
+; X64-WIN-NEXT:    psubd %xmm1, %xmm0
+; X64-WIN-NEXT:    retq
+  %t0 = sub <4 x i32> %x, %y
+  %r = add <4 x i32> %t0, <i32 1, i32 undef, i32 1, i32 1>
+  ret <4 x i32> %r
+}




More information about the llvm-commits mailing list