446 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=cmov | FileCheck %s --check-prefixes=X86,X86-NOSSE3; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefixes=X86,X86-SSE24 5; This tests codegen time inlining/optimization of memcmp6; rdar://64803987 8@.str = private constant [65 x i8] c"0123456789012345678901234567890123456789012345678901234567890123\00", align 19 10declare dso_local i32 @memcmp(ptr, ptr, i32)11 12define i32 @length2(ptr %X, ptr %Y) nounwind minsize {13; X86-LABEL: length2:14; X86: # %bb.0:15; X86-NEXT: pushl $216; X86-NEXT: pushl {{[0-9]+}}(%esp)17; X86-NEXT: pushl {{[0-9]+}}(%esp)18; X86-NEXT: calll memcmp19; X86-NEXT: addl $12, %esp20; X86-NEXT: retl21 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 2) nounwind22 ret i32 %m23}24 25define i1 @length2_eq(ptr %X, ptr %Y) nounwind minsize {26; X86-LABEL: length2_eq:27; X86: # %bb.0:28; X86-NEXT: movl {{[0-9]+}}(%esp), %eax29; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx30; X86-NEXT: movzwl (%ecx), %ecx31; X86-NEXT: cmpw (%eax), %cx32; X86-NEXT: sete %al33; X86-NEXT: retl34 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 2) nounwind35 %c = icmp eq i32 %m, 036 ret i1 %c37}38 39define i1 @length2_eq_const(ptr %X) nounwind minsize {40; X86-LABEL: length2_eq_const:41; X86: # %bb.0:42; X86-NEXT: movl {{[0-9]+}}(%esp), %eax43; X86-NEXT: cmpw $12849, (%eax) # imm = 0x323144; X86-NEXT: setne %al45; X86-NEXT: retl46 %m = tail call i32 @memcmp(ptr %X, ptr getelementptr inbounds ([65 x i8], ptr @.str, i32 0, i32 1), i32 2) nounwind47 %c = icmp ne i32 %m, 048 ret i1 %c49}50 51define i1 @length2_eq_nobuiltin_attr(ptr %X, ptr %Y) nounwind minsize {52; X86-LABEL: length2_eq_nobuiltin_attr:53; X86: # %bb.0:54; X86-NEXT: pushl $255; X86-NEXT: pushl {{[0-9]+}}(%esp)56; X86-NEXT: pushl {{[0-9]+}}(%esp)57; X86-NEXT: calll memcmp58; X86-NEXT: addl $12, %esp59; X86-NEXT: testl %eax, %eax60; X86-NEXT: sete %al61; X86-NEXT: retl62 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 2) nounwind nobuiltin63 %c = icmp eq i32 %m, 064 ret i1 %c65}66 67define i32 @length3(ptr %X, ptr %Y) nounwind minsize {68; X86-LABEL: length3:69; X86: # %bb.0:70; X86-NEXT: pushl $371; X86-NEXT: pushl {{[0-9]+}}(%esp)72; X86-NEXT: pushl {{[0-9]+}}(%esp)73; X86-NEXT: calll memcmp74; X86-NEXT: addl $12, %esp75; X86-NEXT: retl76 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 3) nounwind77 ret i32 %m78}79 80define i1 @length3_eq(ptr %X, ptr %Y) nounwind minsize {81; X86-LABEL: length3_eq:82; X86: # %bb.0:83; X86-NEXT: pushl $384; X86-NEXT: pushl {{[0-9]+}}(%esp)85; X86-NEXT: pushl {{[0-9]+}}(%esp)86; X86-NEXT: calll memcmp87; X86-NEXT: addl $12, %esp88; X86-NEXT: testl %eax, %eax89; X86-NEXT: setne %al90; X86-NEXT: retl91 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 3) nounwind92 %c = icmp ne i32 %m, 093 ret i1 %c94}95 96define i32 @length4(ptr %X, ptr %Y) nounwind minsize {97; X86-LABEL: length4:98; X86: # %bb.0:99; X86-NEXT: pushl $4100; X86-NEXT: pushl {{[0-9]+}}(%esp)101; X86-NEXT: pushl {{[0-9]+}}(%esp)102; X86-NEXT: calll memcmp103; X86-NEXT: addl $12, %esp104; X86-NEXT: retl105 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 4) nounwind106 ret i32 %m107}108 109define i1 @length4_eq(ptr %X, ptr %Y) nounwind minsize {110; X86-LABEL: length4_eq:111; X86: # %bb.0:112; X86-NEXT: movl {{[0-9]+}}(%esp), %eax113; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx114; X86-NEXT: movl (%ecx), %ecx115; X86-NEXT: cmpl (%eax), %ecx116; X86-NEXT: setne %al117; X86-NEXT: retl118 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 4) nounwind119 %c = icmp ne i32 %m, 0120 ret i1 %c121}122 123define i1 @length4_eq_const(ptr %X) nounwind minsize {124; X86-LABEL: length4_eq_const:125; X86: # %bb.0:126; X86-NEXT: movl {{[0-9]+}}(%esp), %eax127; X86-NEXT: cmpl $875770417, (%eax) # imm = 0x34333231128; X86-NEXT: sete %al129; X86-NEXT: retl130 %m = tail call i32 @memcmp(ptr %X, ptr getelementptr inbounds ([65 x i8], ptr @.str, i32 0, i32 1), i32 4) nounwind131 %c = icmp eq i32 %m, 0132 ret i1 %c133}134 135define i32 @length5(ptr %X, ptr %Y) nounwind minsize {136; X86-LABEL: length5:137; X86: # %bb.0:138; X86-NEXT: pushl $5139; X86-NEXT: pushl {{[0-9]+}}(%esp)140; X86-NEXT: pushl {{[0-9]+}}(%esp)141; X86-NEXT: calll memcmp142; X86-NEXT: addl $12, %esp143; X86-NEXT: retl144 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 5) nounwind145 ret i32 %m146}147 148define i1 @length5_eq(ptr %X, ptr %Y) nounwind minsize {149; X86-LABEL: length5_eq:150; X86: # %bb.0:151; X86-NEXT: pushl $5152; X86-NEXT: pushl {{[0-9]+}}(%esp)153; X86-NEXT: pushl {{[0-9]+}}(%esp)154; X86-NEXT: calll memcmp155; X86-NEXT: addl $12, %esp156; X86-NEXT: testl %eax, %eax157; X86-NEXT: setne %al158; X86-NEXT: retl159 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 5) nounwind160 %c = icmp ne i32 %m, 0161 ret i1 %c162}163 164define i32 @length8(ptr %X, ptr %Y) nounwind minsize {165; X86-LABEL: length8:166; X86: # %bb.0:167; X86-NEXT: pushl $8168; X86-NEXT: pushl {{[0-9]+}}(%esp)169; X86-NEXT: pushl {{[0-9]+}}(%esp)170; X86-NEXT: calll memcmp171; X86-NEXT: addl $12, %esp172; X86-NEXT: retl173 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 8) nounwind174 ret i32 %m175}176 177define i1 @length8_eq(ptr %X, ptr %Y) nounwind minsize {178; X86-LABEL: length8_eq:179; X86: # %bb.0:180; X86-NEXT: pushl $8181; X86-NEXT: pushl {{[0-9]+}}(%esp)182; X86-NEXT: pushl {{[0-9]+}}(%esp)183; X86-NEXT: calll memcmp184; X86-NEXT: addl $12, %esp185; X86-NEXT: testl %eax, %eax186; X86-NEXT: sete %al187; X86-NEXT: retl188 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 8) nounwind189 %c = icmp eq i32 %m, 0190 ret i1 %c191}192 193define i1 @length8_eq_const(ptr %X) nounwind minsize {194; X86-LABEL: length8_eq_const:195; X86: # %bb.0:196; X86-NEXT: pushl $8197; X86-NEXT: pushl $.L.str198; X86-NEXT: pushl {{[0-9]+}}(%esp)199; X86-NEXT: calll memcmp200; X86-NEXT: addl $12, %esp201; X86-NEXT: testl %eax, %eax202; X86-NEXT: setne %al203; X86-NEXT: retl204 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i32 8) nounwind205 %c = icmp ne i32 %m, 0206 ret i1 %c207}208 209define i1 @length12_eq(ptr %X, ptr %Y) nounwind minsize {210; X86-LABEL: length12_eq:211; X86: # %bb.0:212; X86-NEXT: pushl $12213; X86-NEXT: pushl {{[0-9]+}}(%esp)214; X86-NEXT: pushl {{[0-9]+}}(%esp)215; X86-NEXT: calll memcmp216; X86-NEXT: addl $12, %esp217; X86-NEXT: testl %eax, %eax218; X86-NEXT: setne %al219; X86-NEXT: retl220 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 12) nounwind221 %c = icmp ne i32 %m, 0222 ret i1 %c223}224 225define i32 @length12(ptr %X, ptr %Y) nounwind minsize {226; X86-LABEL: length12:227; X86: # %bb.0:228; X86-NEXT: pushl $12229; X86-NEXT: pushl {{[0-9]+}}(%esp)230; X86-NEXT: pushl {{[0-9]+}}(%esp)231; X86-NEXT: calll memcmp232; X86-NEXT: addl $12, %esp233; X86-NEXT: retl234 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 12) nounwind235 ret i32 %m236}237 238; PR33329 - https://bugs.llvm.org/show_bug.cgi?id=33329239 240define i32 @length16(ptr %X, ptr %Y) nounwind minsize {241; X86-LABEL: length16:242; X86: # %bb.0:243; X86-NEXT: pushl $16244; X86-NEXT: pushl {{[0-9]+}}(%esp)245; X86-NEXT: pushl {{[0-9]+}}(%esp)246; X86-NEXT: calll memcmp247; X86-NEXT: addl $12, %esp248; X86-NEXT: retl249 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 16) nounwind250 ret i32 %m251}252 253define i1 @length16_eq(ptr %x, ptr %y) nounwind minsize {254; X86-NOSSE-LABEL: length16_eq:255; X86-NOSSE: # %bb.0:256; X86-NOSSE-NEXT: pushl $16257; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp)258; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp)259; X86-NOSSE-NEXT: calll memcmp260; X86-NOSSE-NEXT: addl $12, %esp261; X86-NOSSE-NEXT: testl %eax, %eax262; X86-NOSSE-NEXT: setne %al263; X86-NOSSE-NEXT: retl264;265; X86-SSE2-LABEL: length16_eq:266; X86-SSE2: # %bb.0:267; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax268; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %ecx269; X86-SSE2-NEXT: movdqu (%ecx), %xmm0270; X86-SSE2-NEXT: movdqu (%eax), %xmm1271; X86-SSE2-NEXT: pcmpeqb %xmm0, %xmm1272; X86-SSE2-NEXT: pmovmskb %xmm1, %eax273; X86-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF274; X86-SSE2-NEXT: setne %al275; X86-SSE2-NEXT: retl276 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 16) nounwind277 %cmp = icmp ne i32 %call, 0278 ret i1 %cmp279}280 281define i1 @length16_eq_const(ptr %X) nounwind minsize {282; X86-NOSSE-LABEL: length16_eq_const:283; X86-NOSSE: # %bb.0:284; X86-NOSSE-NEXT: pushl $16285; X86-NOSSE-NEXT: pushl $.L.str286; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp)287; X86-NOSSE-NEXT: calll memcmp288; X86-NOSSE-NEXT: addl $12, %esp289; X86-NOSSE-NEXT: testl %eax, %eax290; X86-NOSSE-NEXT: sete %al291; X86-NOSSE-NEXT: retl292;293; X86-SSE2-LABEL: length16_eq_const:294; X86-SSE2: # %bb.0:295; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax296; X86-SSE2-NEXT: movdqu (%eax), %xmm0297; X86-SSE2-NEXT: pcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0298; X86-SSE2-NEXT: pmovmskb %xmm0, %eax299; X86-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF300; X86-SSE2-NEXT: sete %al301; X86-SSE2-NEXT: retl302 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i32 16) nounwind303 %c = icmp eq i32 %m, 0304 ret i1 %c305}306 307; PR33914 - https://bugs.llvm.org/show_bug.cgi?id=33914308 309define i32 @length24(ptr %X, ptr %Y) nounwind minsize {310; X86-LABEL: length24:311; X86: # %bb.0:312; X86-NEXT: pushl $24313; X86-NEXT: pushl {{[0-9]+}}(%esp)314; X86-NEXT: pushl {{[0-9]+}}(%esp)315; X86-NEXT: calll memcmp316; X86-NEXT: addl $12, %esp317; X86-NEXT: retl318 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 24) nounwind319 ret i32 %m320}321 322define i1 @length24_eq(ptr %x, ptr %y) nounwind minsize {323; X86-LABEL: length24_eq:324; X86: # %bb.0:325; X86-NEXT: pushl $24326; X86-NEXT: pushl {{[0-9]+}}(%esp)327; X86-NEXT: pushl {{[0-9]+}}(%esp)328; X86-NEXT: calll memcmp329; X86-NEXT: addl $12, %esp330; X86-NEXT: testl %eax, %eax331; X86-NEXT: sete %al332; X86-NEXT: retl333 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 24) nounwind334 %cmp = icmp eq i32 %call, 0335 ret i1 %cmp336}337 338define i1 @length24_eq_const(ptr %X) nounwind minsize {339; X86-LABEL: length24_eq_const:340; X86: # %bb.0:341; X86-NEXT: pushl $24342; X86-NEXT: pushl $.L.str343; X86-NEXT: pushl {{[0-9]+}}(%esp)344; X86-NEXT: calll memcmp345; X86-NEXT: addl $12, %esp346; X86-NEXT: testl %eax, %eax347; X86-NEXT: setne %al348; X86-NEXT: retl349 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i32 24) nounwind350 %c = icmp ne i32 %m, 0351 ret i1 %c352}353 354define i32 @length32(ptr %X, ptr %Y) nounwind minsize {355; X86-LABEL: length32:356; X86: # %bb.0:357; X86-NEXT: pushl $32358; X86-NEXT: pushl {{[0-9]+}}(%esp)359; X86-NEXT: pushl {{[0-9]+}}(%esp)360; X86-NEXT: calll memcmp361; X86-NEXT: addl $12, %esp362; X86-NEXT: retl363 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 32) nounwind364 ret i32 %m365}366 367; PR33325 - https://bugs.llvm.org/show_bug.cgi?id=33325368 369define i1 @length32_eq(ptr %x, ptr %y) nounwind minsize {370; X86-LABEL: length32_eq:371; X86: # %bb.0:372; X86-NEXT: pushl $32373; X86-NEXT: pushl {{[0-9]+}}(%esp)374; X86-NEXT: pushl {{[0-9]+}}(%esp)375; X86-NEXT: calll memcmp376; X86-NEXT: addl $12, %esp377; X86-NEXT: testl %eax, %eax378; X86-NEXT: sete %al379; X86-NEXT: retl380 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 32) nounwind381 %cmp = icmp eq i32 %call, 0382 ret i1 %cmp383}384 385define i1 @length32_eq_const(ptr %X) nounwind minsize {386; X86-LABEL: length32_eq_const:387; X86: # %bb.0:388; X86-NEXT: pushl $32389; X86-NEXT: pushl $.L.str390; X86-NEXT: pushl {{[0-9]+}}(%esp)391; X86-NEXT: calll memcmp392; X86-NEXT: addl $12, %esp393; X86-NEXT: testl %eax, %eax394; X86-NEXT: setne %al395; X86-NEXT: retl396 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i32 32) nounwind397 %c = icmp ne i32 %m, 0398 ret i1 %c399}400 401define i32 @length64(ptr %X, ptr %Y) nounwind minsize {402; X86-LABEL: length64:403; X86: # %bb.0:404; X86-NEXT: pushl $64405; X86-NEXT: pushl {{[0-9]+}}(%esp)406; X86-NEXT: pushl {{[0-9]+}}(%esp)407; X86-NEXT: calll memcmp408; X86-NEXT: addl $12, %esp409; X86-NEXT: retl410 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 64) nounwind411 ret i32 %m412}413 414define i1 @length64_eq(ptr %x, ptr %y) nounwind minsize {415; X86-LABEL: length64_eq:416; X86: # %bb.0:417; X86-NEXT: pushl $64418; X86-NEXT: pushl {{[0-9]+}}(%esp)419; X86-NEXT: pushl {{[0-9]+}}(%esp)420; X86-NEXT: calll memcmp421; X86-NEXT: addl $12, %esp422; X86-NEXT: testl %eax, %eax423; X86-NEXT: setne %al424; X86-NEXT: retl425 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 64) nounwind426 %cmp = icmp ne i32 %call, 0427 ret i1 %cmp428}429 430define i1 @length64_eq_const(ptr %X) nounwind minsize {431; X86-LABEL: length64_eq_const:432; X86: # %bb.0:433; X86-NEXT: pushl $64434; X86-NEXT: pushl $.L.str435; X86-NEXT: pushl {{[0-9]+}}(%esp)436; X86-NEXT: calll memcmp437; X86-NEXT: addl $12, %esp438; X86-NEXT: testl %eax, %eax439; X86-NEXT: sete %al440; X86-NEXT: retl441 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i32 64) nounwind442 %c = icmp eq i32 %m, 0443 ret i1 %c444}445 446