[llvm] r298611 - [x86] add memcmp tests, remove run

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 23 08:38:22 PDT 2017


Author: spatel
Date: Thu Mar 23 10:38:22 2017
New Revision: 298611

URL: http://llvm.org/viewvc/llvm-project?rev=298611&view=rev
Log:
[x86] add memcmp tests, remove run

Add tests for vector lengths that could be handled without a libcall.

There's an explicit test for 'nobuiltin', so there's not much value
in a separate run that checks that same behavior over and over again.


Modified:
    llvm/trunk/test/CodeGen/X86/memcmp.ll

Modified: llvm/trunk/test/CodeGen/X86/memcmp.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/memcmp.ll?rev=298611&r1=298610&r2=298611&view=diff
==============================================================================
--- llvm/trunk/test/CodeGen/X86/memcmp.ll (original)
+++ llvm/trunk/test/CodeGen/X86/memcmp.ll Thu Mar 23 10:38:22 2017
@@ -1,190 +1,188 @@
 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
-; RUN: llc < %s                            -mtriple=x86_64-unknown-unknown | FileCheck %s --check-prefix=ALL --check-prefix=BUILTIN
-; RUN: llc < %s -disable-simplify-libcalls -mtriple=x86_64-unknown-unknown | FileCheck %s --check-prefix=ALL --check-prefix=NOBUILTIN
+; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s
 
 ; This tests codegen time inlining/optimization of memcmp
 ; rdar://6480398
 
- at .str = private constant [23 x i8] c"fooooooooooooooooooooo\00", align 1
+ at .str = private constant [65 x i8] c"0123456789012345678901234567890123456789012345678901234567890123\00", align 1
 
 declare i32 @memcmp(i8*, i8*, i64)
 
-define i1 @two_bytes(i8* %X, i8* %Y, i32* nocapture %P) nounwind {
-; BUILTIN-LABEL: two_bytes:
-; BUILTIN:       # BB#0:
-; BUILTIN-NEXT:    movzwl (%rdi), %eax
-; BUILTIN-NEXT:    cmpw (%rsi), %ax
-; BUILTIN-NEXT:    sete %al
-; BUILTIN-NEXT:    retq
-;
-; NOBUILTIN-LABEL: two_bytes:
-; NOBUILTIN:       # BB#0:
-; NOBUILTIN-NEXT:    pushq %rax
-; NOBUILTIN-NEXT:    movl $2, %edx
-; NOBUILTIN-NEXT:    callq memcmp
-; NOBUILTIN-NEXT:    testl %eax, %eax
-; NOBUILTIN-NEXT:    sete %al
-; NOBUILTIN-NEXT:    popq %rcx
-; NOBUILTIN-NEXT:    retq
+define i1 @length2(i8* %X, i8* %Y, i32* nocapture %P) nounwind {
+; CHECK-LABEL: length2:
+; CHECK:       # BB#0:
+; CHECK-NEXT:    movzwl (%rdi), %eax
+; CHECK-NEXT:    cmpw (%rsi), %ax
+; CHECK-NEXT:    sete %al
+; CHECK-NEXT:    retq
   %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 2) nounwind
   %c = icmp eq i32 %m, 0
   ret i1 %c
 }
 
-define i1 @two_bytes_const(i8* %X, i32* nocapture %P) nounwind {
-; BUILTIN-LABEL: two_bytes_const:
-; BUILTIN:       # BB#0:
-; BUILTIN-NEXT:    movzwl (%rdi), %eax
-; BUILTIN-NEXT:    cmpl $28527, %eax # imm = 0x6F6F
-; BUILTIN-NEXT:    setne %al
-; BUILTIN-NEXT:    retq
-;
-; NOBUILTIN-LABEL: two_bytes_const:
-; NOBUILTIN:       # BB#0:
-; NOBUILTIN-NEXT:    pushq %rax
-; NOBUILTIN-NEXT:    movl $.L.str+1, %esi
-; NOBUILTIN-NEXT:    movl $2, %edx
-; NOBUILTIN-NEXT:    callq memcmp
-; NOBUILTIN-NEXT:    testl %eax, %eax
-; NOBUILTIN-NEXT:    setne %al
-; NOBUILTIN-NEXT:    popq %rcx
-; NOBUILTIN-NEXT:    retq
-  %m = tail call i32 @memcmp(i8* %X, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i32 0, i32 1), i64 2) nounwind
+define i1 @length2_const(i8* %X, i32* nocapture %P) nounwind {
+; CHECK-LABEL: length2_const:
+; CHECK:       # BB#0:
+; CHECK-NEXT:    movzwl (%rdi), %eax
+; CHECK-NEXT:    cmpl $12849, %eax # imm = 0x3231
+; CHECK-NEXT:    setne %al
+; CHECK-NEXT:    retq
+  %m = tail call i32 @memcmp(i8* %X, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i32 0, i32 1), i64 2) nounwind
   %c = icmp ne i32 %m, 0
   ret i1 %c
 }
 
-define i1 @two_bytes_nobuiltin_attr(i8* %X, i8* %Y, i32* nocapture %P) nounwind {
-; ALL-LABEL: two_bytes_nobuiltin_attr:
-; ALL:       # BB#0:
-; ALL-NEXT:    pushq %rax
-; ALL-NEXT:    movl $2, %edx
-; ALL-NEXT:    callq memcmp
-; ALL-NEXT:    testl %eax, %eax
-; ALL-NEXT:    sete %al
-; ALL-NEXT:    popq %rcx
-; ALL-NEXT:    retq
+define i1 @length2_nobuiltin_attr(i8* %X, i8* %Y, i32* nocapture %P) nounwind {
+; CHECK-LABEL: length2_nobuiltin_attr:
+; CHECK:       # BB#0:
+; CHECK-NEXT:    pushq %rax
+; CHECK-NEXT:    movl $2, %edx
+; CHECK-NEXT:    callq memcmp
+; CHECK-NEXT:    testl %eax, %eax
+; CHECK-NEXT:    sete %al
+; CHECK-NEXT:    popq %rcx
+; CHECK-NEXT:    retq
   %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 2) nounwind nobuiltin
   %c = icmp eq i32 %m, 0
   ret i1 %c
 }
 
-define i1 @four_bytes(i8* %X, i8* %Y, i32* nocapture %P) nounwind {
-; BUILTIN-LABEL: four_bytes:
-; BUILTIN:       # BB#0:
-; BUILTIN-NEXT:    movl (%rdi), %eax
-; BUILTIN-NEXT:    cmpl (%rsi), %eax
-; BUILTIN-NEXT:    setne %al
-; BUILTIN-NEXT:    retq
-;
-; NOBUILTIN-LABEL: four_bytes:
-; NOBUILTIN:       # BB#0:
-; NOBUILTIN-NEXT:    pushq %rax
-; NOBUILTIN-NEXT:    movl $4, %edx
-; NOBUILTIN-NEXT:    callq memcmp
-; NOBUILTIN-NEXT:    testl %eax, %eax
-; NOBUILTIN-NEXT:    setne %al
-; NOBUILTIN-NEXT:    popq %rcx
-; NOBUILTIN-NEXT:    retq
+define i1 @length4(i8* %X, i8* %Y, i32* nocapture %P) nounwind {
+; CHECK-LABEL: length4:
+; CHECK:       # BB#0:
+; CHECK-NEXT:    movl (%rdi), %eax
+; CHECK-NEXT:    cmpl (%rsi), %eax
+; CHECK-NEXT:    setne %al
+; CHECK-NEXT:    retq
   %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 4) nounwind
   %c = icmp ne i32 %m, 0
   ret i1 %c
 }
 
-define i1 @four_bytes_const(i8* %X, i32* nocapture %P) nounwind {
-; BUILTIN-LABEL: four_bytes_const:
-; BUILTIN:       # BB#0:
-; BUILTIN-NEXT:    cmpl $1869573999, (%rdi) # imm = 0x6F6F6F6F
-; BUILTIN-NEXT:    sete %al
-; BUILTIN-NEXT:    retq
-;
-; NOBUILTIN-LABEL: four_bytes_const:
-; NOBUILTIN:       # BB#0:
-; NOBUILTIN-NEXT:    pushq %rax
-; NOBUILTIN-NEXT:    movl $.L.str+1, %esi
-; NOBUILTIN-NEXT:    movl $4, %edx
-; NOBUILTIN-NEXT:    callq memcmp
-; NOBUILTIN-NEXT:    testl %eax, %eax
-; NOBUILTIN-NEXT:    sete %al
-; NOBUILTIN-NEXT:    popq %rcx
-; NOBUILTIN-NEXT:    retq
-  %m = tail call i32 @memcmp(i8* %X, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i32 0, i32 1), i64 4) nounwind
+define i1 @length4_const(i8* %X, i32* nocapture %P) nounwind {
+; CHECK-LABEL: length4_const:
+; CHECK:       # BB#0:
+; CHECK-NEXT:    cmpl $875770417, (%rdi) # imm = 0x34333231
+; CHECK-NEXT:    sete %al
+; CHECK-NEXT:    retq
+  %m = tail call i32 @memcmp(i8* %X, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i32 0, i32 1), i64 4) nounwind
   %c = icmp eq i32 %m, 0
   ret i1 %c
 }
 
-define i1 @eight_bytes(i8* %X, i8* %Y, i32* nocapture %P) nounwind {
-; BUILTIN-LABEL: eight_bytes:
-; BUILTIN:       # BB#0:
-; BUILTIN-NEXT:    movq (%rdi), %rax
-; BUILTIN-NEXT:    cmpq (%rsi), %rax
-; BUILTIN-NEXT:    sete %al
-; BUILTIN-NEXT:    retq
-;
-; NOBUILTIN-LABEL: eight_bytes:
-; NOBUILTIN:       # BB#0:
-; NOBUILTIN-NEXT:    pushq %rax
-; NOBUILTIN-NEXT:    movl $8, %edx
-; NOBUILTIN-NEXT:    callq memcmp
-; NOBUILTIN-NEXT:    testl %eax, %eax
-; NOBUILTIN-NEXT:    sete %al
-; NOBUILTIN-NEXT:    popq %rcx
-; NOBUILTIN-NEXT:    retq
+define i1 @length8(i8* %X, i8* %Y, i32* nocapture %P) nounwind {
+; CHECK-LABEL: length8:
+; CHECK:       # BB#0:
+; CHECK-NEXT:    movq (%rdi), %rax
+; CHECK-NEXT:    cmpq (%rsi), %rax
+; CHECK-NEXT:    sete %al
+; CHECK-NEXT:    retq
   %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 8) nounwind
   %c = icmp eq i32 %m, 0
   ret i1 %c
 }
 
-define i1 @eight_bytes_const(i8* %X, i32* nocapture %P) nounwind {
-; BUILTIN-LABEL: eight_bytes_const:
-; BUILTIN:       # BB#0:
-; BUILTIN-NEXT:    movabsq $8029759185026510694, %rax # imm = 0x6F6F6F6F6F6F6F66
-; BUILTIN-NEXT:    cmpq %rax, (%rdi)
-; BUILTIN-NEXT:    setne %al
-; BUILTIN-NEXT:    retq
-;
-; NOBUILTIN-LABEL: eight_bytes_const:
-; NOBUILTIN:       # BB#0:
-; NOBUILTIN-NEXT:    pushq %rax
-; NOBUILTIN-NEXT:    movl $.L.str, %esi
-; NOBUILTIN-NEXT:    movl $8, %edx
-; NOBUILTIN-NEXT:    callq memcmp
-; NOBUILTIN-NEXT:    testl %eax, %eax
-; NOBUILTIN-NEXT:    setne %al
-; NOBUILTIN-NEXT:    popq %rcx
-; NOBUILTIN-NEXT:    retq
-  %m = tail call i32 @memcmp(i8* %X, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i32 0, i32 0), i64 8) nounwind
+define i1 @length8_const(i8* %X, i32* nocapture %P) nounwind {
+; CHECK-LABEL: length8_const:
+; CHECK:       # BB#0:
+; CHECK-NEXT:    movabsq $3978425819141910832, %rax # imm = 0x3736353433323130
+; CHECK-NEXT:    cmpq %rax, (%rdi)
+; CHECK-NEXT:    setne %al
+; CHECK-NEXT:    retq
+  %m = tail call i32 @memcmp(i8* %X, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i32 0, i32 0), i64 8) nounwind
   %c = icmp ne i32 %m, 0
   ret i1 %c
 }
 
-define i1 @sixteen_bytes(i8* %x, i8* %y) nounwind {
-; ALL-LABEL: sixteen_bytes:
-; ALL:       # BB#0:
-; ALL-NEXT:    pushq %rax
-; ALL-NEXT:    movl $16, %edx
-; ALL-NEXT:    callq memcmp
-; ALL-NEXT:    testl %eax, %eax
-; ALL-NEXT:    setne %al
-; ALL-NEXT:    popq %rcx
-; ALL-NEXT:    retq
+define i1 @length16(i8* %x, i8* %y) nounwind {
+; CHECK-LABEL: length16:
+; CHECK:       # BB#0:
+; CHECK-NEXT:    pushq %rax
+; CHECK-NEXT:    movl $16, %edx
+; CHECK-NEXT:    callq memcmp
+; CHECK-NEXT:    testl %eax, %eax
+; CHECK-NEXT:    setne %al
+; CHECK-NEXT:    popq %rcx
+; CHECK-NEXT:    retq
   %call = tail call i32 @memcmp(i8* %x, i8* %y, i64 16) nounwind
   %cmp = icmp ne i32 %call, 0
   ret i1 %cmp
 }
 
-define i1 @sixteen_bytes_const(i8* %X, i32* nocapture %P) nounwind {
-; ALL-LABEL: sixteen_bytes_const:
-; ALL:       # BB#0:
-; ALL-NEXT:    pushq %rax
-; ALL-NEXT:    movl $.L.str, %esi
-; ALL-NEXT:    movl $16, %edx
-; ALL-NEXT:    callq memcmp
-; ALL-NEXT:    testl %eax, %eax
-; ALL-NEXT:    sete %al
-; ALL-NEXT:    popq %rcx
-; ALL-NEXT:    retq
-  %m = tail call i32 @memcmp(i8* %X, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i32 0, i32 0), i64 16) nounwind
+define i1 @length16_const(i8* %X, i32* nocapture %P) nounwind {
+; CHECK-LABEL: length16_const:
+; CHECK:       # BB#0:
+; CHECK-NEXT:    pushq %rax
+; CHECK-NEXT:    movl $.L.str, %esi
+; CHECK-NEXT:    movl $16, %edx
+; CHECK-NEXT:    callq memcmp
+; CHECK-NEXT:    testl %eax, %eax
+; CHECK-NEXT:    sete %al
+; CHECK-NEXT:    popq %rcx
+; CHECK-NEXT:    retq
+  %m = tail call i32 @memcmp(i8* %X, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i32 0, i32 0), i64 16) nounwind
+  %c = icmp eq i32 %m, 0
+  ret i1 %c
+}
+
+define i1 @length32(i8* %x, i8* %y) nounwind {
+; CHECK-LABEL: length32:
+; CHECK:       # BB#0:
+; CHECK-NEXT:    pushq %rax
+; CHECK-NEXT:    movl $32, %edx
+; CHECK-NEXT:    callq memcmp
+; CHECK-NEXT:    testl %eax, %eax
+; CHECK-NEXT:    sete %al
+; CHECK-NEXT:    popq %rcx
+; CHECK-NEXT:    retq
+  %call = tail call i32 @memcmp(i8* %x, i8* %y, i64 32) nounwind
+  %cmp = icmp eq i32 %call, 0
+  ret i1 %cmp
+}
+
+define i1 @length32_const(i8* %X, i32* nocapture %P) nounwind {
+; CHECK-LABEL: length32_const:
+; CHECK:       # BB#0:
+; CHECK-NEXT:    pushq %rax
+; CHECK-NEXT:    movl $.L.str, %esi
+; CHECK-NEXT:    movl $32, %edx
+; CHECK-NEXT:    callq memcmp
+; CHECK-NEXT:    testl %eax, %eax
+; CHECK-NEXT:    setne %al
+; CHECK-NEXT:    popq %rcx
+; CHECK-NEXT:    retq
+  %m = tail call i32 @memcmp(i8* %X, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i32 0, i32 0), i64 32) nounwind
+  %c = icmp ne i32 %m, 0
+  ret i1 %c
+}
+
+define i1 @length64(i8* %x, i8* %y) nounwind {
+; CHECK-LABEL: length64:
+; CHECK:       # BB#0:
+; CHECK-NEXT:    pushq %rax
+; CHECK-NEXT:    movl $64, %edx
+; CHECK-NEXT:    callq memcmp
+; CHECK-NEXT:    testl %eax, %eax
+; CHECK-NEXT:    setne %al
+; CHECK-NEXT:    popq %rcx
+; CHECK-NEXT:    retq
+  %call = tail call i32 @memcmp(i8* %x, i8* %y, i64 64) nounwind
+  %cmp = icmp ne i32 %call, 0
+  ret i1 %cmp
+}
+
+define i1 @length64_const(i8* %X, i32* nocapture %P) nounwind {
+; CHECK-LABEL: length64_const:
+; CHECK:       # BB#0:
+; CHECK-NEXT:    pushq %rax
+; CHECK-NEXT:    movl $.L.str, %esi
+; CHECK-NEXT:    movl $64, %edx
+; CHECK-NEXT:    callq memcmp
+; CHECK-NEXT:    testl %eax, %eax
+; CHECK-NEXT:    sete %al
+; CHECK-NEXT:    popq %rcx
+; CHECK-NEXT:    retq
+  %m = tail call i32 @memcmp(i8* %X, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str, i32 0, i32 0), i64 64) nounwind
   %c = icmp eq i32 %m, 0
   ret i1 %c
 }




More information about the llvm-commits mailing list