brintos

brintos / llvm-project-archived public Read only

0
0
Text · 12.3 KiB · 9c20f3e Raw
434 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s --check-prefixes=X64,X64-SSE23; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=avx | FileCheck %s --check-prefixes=X64,X64-AVX,X64-AVX14; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=avx2 | FileCheck %s --check-prefixes=X64,X64-AVX,X64-AVX25 6; This tests codegen time inlining/optimization of memcmp7; rdar://64803988 9@.str = private constant [65 x i8] c"0123456789012345678901234567890123456789012345678901234567890123\00", align 110 11declare dso_local i32 @memcmp(ptr, ptr, i64)12 13define i32 @length2(ptr %X, ptr %Y) nounwind minsize {14; X64-LABEL: length2:15; X64:       # %bb.0:16; X64-NEXT:    pushq $217; X64-NEXT:    popq %rdx18; X64-NEXT:    jmp memcmp # TAILCALL19  %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 2) nounwind20  ret i32 %m21}22 23define i1 @length2_eq(ptr %X, ptr %Y) nounwind minsize {24; X64-LABEL: length2_eq:25; X64:       # %bb.0:26; X64-NEXT:    movzwl (%rdi), %eax27; X64-NEXT:    cmpw (%rsi), %ax28; X64-NEXT:    sete %al29; X64-NEXT:    retq30  %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 2) nounwind31  %c = icmp eq i32 %m, 032  ret i1 %c33}34 35define i1 @length2_eq_const(ptr %X) nounwind minsize {36; X64-LABEL: length2_eq_const:37; X64:       # %bb.0:38; X64-NEXT:    cmpw $12849, (%rdi) # imm = 0x323139; X64-NEXT:    setne %al40; X64-NEXT:    retq41  %m = tail call i32 @memcmp(ptr %X, ptr getelementptr inbounds ([65 x i8], ptr @.str, i32 0, i32 1), i64 2) nounwind42  %c = icmp ne i32 %m, 043  ret i1 %c44}45 46define i1 @length2_eq_nobuiltin_attr(ptr %X, ptr %Y) nounwind minsize {47; X64-LABEL: length2_eq_nobuiltin_attr:48; X64:       # %bb.0:49; X64-NEXT:    pushq %rax50; X64-NEXT:    pushq $251; X64-NEXT:    popq %rdx52; X64-NEXT:    callq memcmp53; X64-NEXT:    testl %eax, %eax54; X64-NEXT:    sete %al55; X64-NEXT:    popq %rcx56; X64-NEXT:    retq57  %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 2) nounwind nobuiltin58  %c = icmp eq i32 %m, 059  ret i1 %c60}61 62define i32 @length3(ptr %X, ptr %Y) nounwind minsize {63; X64-LABEL: length3:64; X64:       # %bb.0:65; X64-NEXT:    pushq $366; X64-NEXT:    popq %rdx67; X64-NEXT:    jmp memcmp # TAILCALL68  %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 3) nounwind69  ret i32 %m70}71 72define i1 @length3_eq(ptr %X, ptr %Y) nounwind minsize {73; X64-LABEL: length3_eq:74; X64:       # %bb.0:75; X64-NEXT:    pushq %rax76; X64-NEXT:    pushq $377; X64-NEXT:    popq %rdx78; X64-NEXT:    callq memcmp79; X64-NEXT:    testl %eax, %eax80; X64-NEXT:    setne %al81; X64-NEXT:    popq %rcx82; X64-NEXT:    retq83  %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 3) nounwind84  %c = icmp ne i32 %m, 085  ret i1 %c86}87 88define i32 @length4(ptr %X, ptr %Y) nounwind minsize {89; X64-LABEL: length4:90; X64:       # %bb.0:91; X64-NEXT:    pushq $492; X64-NEXT:    popq %rdx93; X64-NEXT:    jmp memcmp # TAILCALL94  %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 4) nounwind95  ret i32 %m96}97 98define i1 @length4_eq(ptr %X, ptr %Y) nounwind minsize {99; X64-LABEL: length4_eq:100; X64:       # %bb.0:101; X64-NEXT:    movl (%rdi), %eax102; X64-NEXT:    cmpl (%rsi), %eax103; X64-NEXT:    setne %al104; X64-NEXT:    retq105  %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 4) nounwind106  %c = icmp ne i32 %m, 0107  ret i1 %c108}109 110define i1 @length4_eq_const(ptr %X) nounwind minsize {111; X64-LABEL: length4_eq_const:112; X64:       # %bb.0:113; X64-NEXT:    cmpl $875770417, (%rdi) # imm = 0x34333231114; X64-NEXT:    sete %al115; X64-NEXT:    retq116  %m = tail call i32 @memcmp(ptr %X, ptr getelementptr inbounds ([65 x i8], ptr @.str, i32 0, i32 1), i64 4) nounwind117  %c = icmp eq i32 %m, 0118  ret i1 %c119}120 121define i32 @length5(ptr %X, ptr %Y) nounwind minsize {122; X64-LABEL: length5:123; X64:       # %bb.0:124; X64-NEXT:    pushq $5125; X64-NEXT:    popq %rdx126; X64-NEXT:    jmp memcmp # TAILCALL127  %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 5) nounwind128  ret i32 %m129}130 131define i1 @length5_eq(ptr %X, ptr %Y) nounwind minsize {132; X64-LABEL: length5_eq:133; X64:       # %bb.0:134; X64-NEXT:    pushq %rax135; X64-NEXT:    pushq $5136; X64-NEXT:    popq %rdx137; X64-NEXT:    callq memcmp138; X64-NEXT:    testl %eax, %eax139; X64-NEXT:    setne %al140; X64-NEXT:    popq %rcx141; X64-NEXT:    retq142  %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 5) nounwind143  %c = icmp ne i32 %m, 0144  ret i1 %c145}146 147define i32 @length8(ptr %X, ptr %Y) nounwind minsize {148; X64-LABEL: length8:149; X64:       # %bb.0:150; X64-NEXT:    pushq $8151; X64-NEXT:    popq %rdx152; X64-NEXT:    jmp memcmp # TAILCALL153  %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 8) nounwind154  ret i32 %m155}156 157define i1 @length8_eq(ptr %X, ptr %Y) nounwind minsize {158; X64-LABEL: length8_eq:159; X64:       # %bb.0:160; X64-NEXT:    movq (%rdi), %rax161; X64-NEXT:    cmpq (%rsi), %rax162; X64-NEXT:    sete %al163; X64-NEXT:    retq164  %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 8) nounwind165  %c = icmp eq i32 %m, 0166  ret i1 %c167}168 169define i1 @length8_eq_const(ptr %X) nounwind minsize {170; X64-LABEL: length8_eq_const:171; X64:       # %bb.0:172; X64-NEXT:    movabsq $3978425819141910832, %rax # imm = 0x3736353433323130173; X64-NEXT:    cmpq %rax, (%rdi)174; X64-NEXT:    setne %al175; X64-NEXT:    retq176  %m = tail call i32 @memcmp(ptr %X, ptr @.str, i64 8) nounwind177  %c = icmp ne i32 %m, 0178  ret i1 %c179}180 181define i1 @length12_eq(ptr %X, ptr %Y) nounwind minsize {182; X64-LABEL: length12_eq:183; X64:       # %bb.0:184; X64-NEXT:    pushq %rax185; X64-NEXT:    pushq $12186; X64-NEXT:    popq %rdx187; X64-NEXT:    callq memcmp188; X64-NEXT:    testl %eax, %eax189; X64-NEXT:    setne %al190; X64-NEXT:    popq %rcx191; X64-NEXT:    retq192  %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 12) nounwind193  %c = icmp ne i32 %m, 0194  ret i1 %c195}196 197define i32 @length12(ptr %X, ptr %Y) nounwind minsize {198; X64-LABEL: length12:199; X64:       # %bb.0:200; X64-NEXT:    pushq $12201; X64-NEXT:    popq %rdx202; X64-NEXT:    jmp memcmp # TAILCALL203  %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 12) nounwind204  ret i32 %m205}206 207; PR33329 - https://bugs.llvm.org/show_bug.cgi?id=33329208 209define i32 @length16(ptr %X, ptr %Y) nounwind minsize {210;211; X64-LABEL: length16:212; X64:       # %bb.0:213; X64-NEXT:    pushq $16214; X64-NEXT:    popq %rdx215; X64-NEXT:    jmp memcmp # TAILCALL216  %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 16) nounwind217  ret i32 %m218}219 220define i1 @length16_eq(ptr %x, ptr %y) nounwind minsize {221; X64-SSE2-LABEL: length16_eq:222; X64-SSE2:       # %bb.0:223; X64-SSE2-NEXT:    movdqu (%rsi), %xmm0224; X64-SSE2-NEXT:    movdqu (%rdi), %xmm1225; X64-SSE2-NEXT:    pcmpeqb %xmm0, %xmm1226; X64-SSE2-NEXT:    pmovmskb %xmm1, %eax227; X64-SSE2-NEXT:    cmpl $65535, %eax # imm = 0xFFFF228; X64-SSE2-NEXT:    setne %al229; X64-SSE2-NEXT:    retq230;231; X64-AVX-LABEL: length16_eq:232; X64-AVX:       # %bb.0:233; X64-AVX-NEXT:    vmovdqu (%rdi), %xmm0234; X64-AVX-NEXT:    vpxor (%rsi), %xmm0, %xmm0235; X64-AVX-NEXT:    vptest %xmm0, %xmm0236; X64-AVX-NEXT:    setne %al237; X64-AVX-NEXT:    retq238  %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 16) nounwind239  %cmp = icmp ne i32 %call, 0240  ret i1 %cmp241}242 243define i1 @length16_eq_const(ptr %X) nounwind minsize {244; X64-SSE2-LABEL: length16_eq_const:245; X64-SSE2:       # %bb.0:246; X64-SSE2-NEXT:    movdqu (%rdi), %xmm0247; X64-SSE2-NEXT:    pcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0248; X64-SSE2-NEXT:    pmovmskb %xmm0, %eax249; X64-SSE2-NEXT:    cmpl $65535, %eax # imm = 0xFFFF250; X64-SSE2-NEXT:    sete %al251; X64-SSE2-NEXT:    retq252;253; X64-AVX-LABEL: length16_eq_const:254; X64-AVX:       # %bb.0:255; X64-AVX-NEXT:    vmovdqu (%rdi), %xmm0256; X64-AVX-NEXT:    vpxor {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm0, %xmm0257; X64-AVX-NEXT:    vptest %xmm0, %xmm0258; X64-AVX-NEXT:    sete %al259; X64-AVX-NEXT:    retq260  %m = tail call i32 @memcmp(ptr %X, ptr @.str, i64 16) nounwind261  %c = icmp eq i32 %m, 0262  ret i1 %c263}264 265; PR33914 - https://bugs.llvm.org/show_bug.cgi?id=33914266 267define i32 @length24(ptr %X, ptr %Y) nounwind minsize {268; X64-LABEL: length24:269; X64:       # %bb.0:270; X64-NEXT:    pushq $24271; X64-NEXT:    popq %rdx272; X64-NEXT:    jmp memcmp # TAILCALL273  %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 24) nounwind274  ret i32 %m275}276 277define i1 @length24_eq(ptr %x, ptr %y) nounwind minsize {278; X64-LABEL: length24_eq:279; X64:       # %bb.0:280; X64-NEXT:    pushq %rax281; X64-NEXT:    pushq $24282; X64-NEXT:    popq %rdx283; X64-NEXT:    callq memcmp284; X64-NEXT:    testl %eax, %eax285; X64-NEXT:    sete %al286; X64-NEXT:    popq %rcx287; X64-NEXT:    retq288  %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 24) nounwind289  %cmp = icmp eq i32 %call, 0290  ret i1 %cmp291}292 293define i1 @length24_eq_const(ptr %X) nounwind minsize {294; X64-LABEL: length24_eq_const:295; X64:       # %bb.0:296; X64-NEXT:    pushq %rax297; X64-NEXT:    pushq $24298; X64-NEXT:    popq %rdx299; X64-NEXT:    movl $.L.str, %esi300; X64-NEXT:    callq memcmp301; X64-NEXT:    testl %eax, %eax302; X64-NEXT:    setne %al303; X64-NEXT:    popq %rcx304; X64-NEXT:    retq305  %m = tail call i32 @memcmp(ptr %X, ptr @.str, i64 24) nounwind306  %c = icmp ne i32 %m, 0307  ret i1 %c308}309 310define i32 @length32(ptr %X, ptr %Y) nounwind minsize {311; X64-LABEL: length32:312; X64:       # %bb.0:313; X64-NEXT:    pushq $32314; X64-NEXT:    popq %rdx315; X64-NEXT:    jmp memcmp # TAILCALL316  %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 32) nounwind317  ret i32 %m318}319 320; PR33325 - https://bugs.llvm.org/show_bug.cgi?id=33325321 322define i1 @length32_eq(ptr %x, ptr %y) nounwind minsize {323; X64-SSE2-LABEL: length32_eq:324; X64-SSE2:       # %bb.0:325; X64-SSE2-NEXT:    pushq %rax326; X64-SSE2-NEXT:    pushq $32327; X64-SSE2-NEXT:    popq %rdx328; X64-SSE2-NEXT:    callq memcmp329; X64-SSE2-NEXT:    testl %eax, %eax330; X64-SSE2-NEXT:    sete %al331; X64-SSE2-NEXT:    popq %rcx332; X64-SSE2-NEXT:    retq333;334; X64-AVX1-LABEL: length32_eq:335; X64-AVX1:       # %bb.0:336; X64-AVX1-NEXT:    vmovups (%rdi), %ymm0337; X64-AVX1-NEXT:    vxorps (%rsi), %ymm0, %ymm0338; X64-AVX1-NEXT:    vptest %ymm0, %ymm0339; X64-AVX1-NEXT:    sete %al340; X64-AVX1-NEXT:    vzeroupper341; X64-AVX1-NEXT:    retq342;343; X64-AVX2-LABEL: length32_eq:344; X64-AVX2:       # %bb.0:345; X64-AVX2-NEXT:    vmovdqu (%rdi), %ymm0346; X64-AVX2-NEXT:    vpxor (%rsi), %ymm0, %ymm0347; X64-AVX2-NEXT:    vptest %ymm0, %ymm0348; X64-AVX2-NEXT:    sete %al349; X64-AVX2-NEXT:    vzeroupper350; X64-AVX2-NEXT:    retq351  %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 32) nounwind352  %cmp = icmp eq i32 %call, 0353  ret i1 %cmp354}355 356define i1 @length32_eq_const(ptr %X) nounwind minsize {357; X64-SSE2-LABEL: length32_eq_const:358; X64-SSE2:       # %bb.0:359; X64-SSE2-NEXT:    pushq %rax360; X64-SSE2-NEXT:    pushq $32361; X64-SSE2-NEXT:    popq %rdx362; X64-SSE2-NEXT:    movl $.L.str, %esi363; X64-SSE2-NEXT:    callq memcmp364; X64-SSE2-NEXT:    testl %eax, %eax365; X64-SSE2-NEXT:    setne %al366; X64-SSE2-NEXT:    popq %rcx367; X64-SSE2-NEXT:    retq368;369; X64-AVX1-LABEL: length32_eq_const:370; X64-AVX1:       # %bb.0:371; X64-AVX1-NEXT:    vmovups (%rdi), %ymm0372; X64-AVX1-NEXT:    vxorps {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm0, %ymm0373; X64-AVX1-NEXT:    vptest %ymm0, %ymm0374; X64-AVX1-NEXT:    setne %al375; X64-AVX1-NEXT:    vzeroupper376; X64-AVX1-NEXT:    retq377;378; X64-AVX2-LABEL: length32_eq_const:379; X64-AVX2:       # %bb.0:380; X64-AVX2-NEXT:    vmovdqu (%rdi), %ymm0381; X64-AVX2-NEXT:    vpxor {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %ymm0, %ymm0382; X64-AVX2-NEXT:    vptest %ymm0, %ymm0383; X64-AVX2-NEXT:    setne %al384; X64-AVX2-NEXT:    vzeroupper385; X64-AVX2-NEXT:    retq386  %m = tail call i32 @memcmp(ptr %X, ptr @.str, i64 32) nounwind387  %c = icmp ne i32 %m, 0388  ret i1 %c389}390 391define i32 @length64(ptr %X, ptr %Y) nounwind minsize {392; X64-LABEL: length64:393; X64:       # %bb.0:394; X64-NEXT:    pushq $64395; X64-NEXT:    popq %rdx396; X64-NEXT:    jmp memcmp # TAILCALL397  %m = tail call i32 @memcmp(ptr %X, ptr %Y, i64 64) nounwind398  ret i32 %m399}400 401define i1 @length64_eq(ptr %x, ptr %y) nounwind minsize {402; X64-LABEL: length64_eq:403; X64:       # %bb.0:404; X64-NEXT:    pushq %rax405; X64-NEXT:    pushq $64406; X64-NEXT:    popq %rdx407; X64-NEXT:    callq memcmp408; X64-NEXT:    testl %eax, %eax409; X64-NEXT:    setne %al410; X64-NEXT:    popq %rcx411; X64-NEXT:    retq412  %call = tail call i32 @memcmp(ptr %x, ptr %y, i64 64) nounwind413  %cmp = icmp ne i32 %call, 0414  ret i1 %cmp415}416 417define i1 @length64_eq_const(ptr %X) nounwind minsize {418; X64-LABEL: length64_eq_const:419; X64:       # %bb.0:420; X64-NEXT:    pushq %rax421; X64-NEXT:    pushq $64422; X64-NEXT:    popq %rdx423; X64-NEXT:    movl $.L.str, %esi424; X64-NEXT:    callq memcmp425; X64-NEXT:    testl %eax, %eax426; X64-NEXT:    sete %al427; X64-NEXT:    popq %rcx428; X64-NEXT:    retq429  %m = tail call i32 @memcmp(ptr %X, ptr @.str, i64 64) nounwind430  %c = icmp eq i32 %m, 0431  ret i1 %c432}433 434