From: Sanjay Patel Date: Wed, 22 Mar 2017 22:39:17 +0000 (+0000) Subject: [x86] improve tests, add tests, auto-generate checks; NFC X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=2a46794da9a72463bb66923bc2a52e298a41f9e7;p=llvm [x86] improve tests, add tests, auto-generate checks; NFC git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@298553 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/test/CodeGen/X86/memcmp.ll b/test/CodeGen/X86/memcmp.ll index 02e2e1be547..61d29031c20 100644 --- a/test/CodeGen/X86/memcmp.ll +++ b/test/CodeGen/X86/memcmp.ll @@ -1,130 +1,191 @@ -; RUN: llc < %s -mtriple=x86_64-linux | FileCheck %s -; RUN: llc < %s -disable-simplify-libcalls -mtriple=x86_64-linux | FileCheck %s --check-prefix=NOBUILTIN -; RUN: llc < %s -mtriple=x86_64-win32 | FileCheck %s +; 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 ; This tests codegen time inlining/optimization of memcmp ; rdar://6480398 -@.str = private constant [23 x i8] c"fooooooooooooooooooooo\00", align 1 ; <[23 x i8]*> [#uses=1] +@.str = private constant [23 x i8] c"fooooooooooooooooooooo\00", align 1 declare i32 @memcmp(i8*, i8*, i64) -define void @memcmp2(i8* %X, i8* %Y, i32* nocapture %P) nounwind { -entry: - %0 = tail call i32 @memcmp(i8* %X, i8* %Y, i64 2) nounwind ; [#uses=1] - %1 = icmp eq i32 %0, 0 ; [#uses=1] - br i1 %1, label %return, label %bb - -bb: ; preds = %entry - store i32 4, i32* %P, align 4 - ret void - -return: ; preds = %entry - ret void -; CHECK-LABEL: memcmp2: -; CHECK: movzwl -; CHECK-NEXT: cmpw -; NOBUILTIN-LABEL: memcmp2: -; NOBUILTIN: callq +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 + %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 2) nounwind + %c = icmp eq i32 %m, 0 + ret i1 %c } -define void @memcmp2a(i8* %X, i32* nocapture %P) nounwind { -entry: - %0 = tail call i32 @memcmp(i8* %X, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i32 0, i32 1), i64 2) nounwind ; [#uses=1] - %1 = icmp eq i32 %0, 0 ; [#uses=1] - br i1 %1, label %return, label %bb - -bb: ; preds = %entry - store i32 4, i32* %P, align 4 - ret void - -return: ; preds = %entry - ret void -; CHECK-LABEL: memcmp2a: -; CHECK: movzwl -; CHECK-NEXT: cmpl $28527, +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 + %c = icmp ne i32 %m, 0 + ret i1 %c } -define void @memcmp2nb(i8* %X, i8* %Y, i32* nocapture %P) nounwind { -entry: - %0 = tail call i32 @memcmp(i8* %X, i8* %Y, i64 2) nounwind nobuiltin ; [#uses=1] - %1 = icmp eq i32 %0, 0 ; [#uses=1] - br i1 %1, label %return, label %bb - -bb: ; preds = %entry - store i32 4, i32* %P, align 4 - ret void - -return: ; preds = %entry - ret void -; CHECK-LABEL: memcmp2nb: -; CHECK: callq +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 + %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 2) nounwind nobuiltin + %c = icmp eq i32 %m, 0 + ret i1 %c } -define void @memcmp4(i8* %X, i8* %Y, i32* nocapture %P) nounwind { -entry: - %0 = tail call i32 @memcmp(i8* %X, i8* %Y, i64 4) nounwind ; [#uses=1] - %1 = icmp eq i32 %0, 0 ; [#uses=1] - br i1 %1, label %return, label %bb - -bb: ; preds = %entry - store i32 4, i32* %P, align 4 - ret void - -return: ; preds = %entry - ret void -; CHECK-LABEL: memcmp4: -; CHECK: movl -; CHECK-NEXT: cmpl +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 + %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 4) nounwind + %c = icmp ne i32 %m, 0 + ret i1 %c } -define void @memcmp4a(i8* %X, i32* nocapture %P) nounwind { -entry: - %0 = tail call i32 @memcmp(i8* %X, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i32 0, i32 1), i64 4) nounwind ; [#uses=1] - %1 = icmp eq i32 %0, 0 ; [#uses=1] - br i1 %1, label %return, label %bb - -bb: ; preds = %entry - store i32 4, i32* %P, align 4 - ret void - -return: ; preds = %entry - ret void -; CHECK-LABEL: memcmp4a: -; CHECK: cmpl $1869573999, +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 + %c = icmp eq i32 %m, 0 + ret i1 %c } -define void @memcmp8(i8* %X, i8* %Y, i32* nocapture %P) nounwind { -entry: - %0 = tail call i32 @memcmp(i8* %X, i8* %Y, i64 8) nounwind ; [#uses=1] - %1 = icmp eq i32 %0, 0 ; [#uses=1] - br i1 %1, label %return, label %bb - -bb: ; preds = %entry - store i32 4, i32* %P, align 4 - ret void - -return: ; preds = %entry - ret void -; CHECK-LABEL: memcmp8: -; CHECK: movq -; CHECK: cmpq +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 + %m = tail call i32 @memcmp(i8* %X, i8* %Y, i64 8) nounwind + %c = icmp eq i32 %m, 0 + ret i1 %c } -define void @memcmp8a(i8* %X, i32* nocapture %P) nounwind { -entry: - %0 = tail call i32 @memcmp(i8* %X, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i32 0, i32 0), i64 8) nounwind ; [#uses=1] - %1 = icmp eq i32 %0, 0 ; [#uses=1] - br i1 %1, label %return, label %bb +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 + %c = icmp ne i32 %m, 0 + ret i1 %c +} -bb: ; preds = %entry - store i32 4, i32* %P, align 4 - ret void +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 + %call = tail call i32 @memcmp(i8* %x, i8* %y, i64 16) nounwind + %cmp = icmp ne i32 %call, 0 + ret i1 %cmp +} -return: ; preds = %entry - ret void -; CHECK-LABEL: memcmp8a: -; CHECK: movabsq $8029759185026510694, -; CHECK: cmpq +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 + %c = icmp eq i32 %m, 0 + ret i1 %c }