1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=cmov | FileCheck %s --check-prefixes=X86,X86-NOSSE 3; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+sse | FileCheck %s --check-prefixes=X86,X86-SSE1 4; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+sse2 | FileCheck %s --check-prefixes=X86,X86-SSE2 5; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+sse4.1 | FileCheck %s --check-prefixes=X86,X86-SSE41 6 7; This tests codegen time inlining/optimization of memcmp 8; rdar://6480398 9 10@.str = private constant [513 x i8] c"01234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901\00", align 1 11 12declare dso_local i32 @memcmp(ptr, ptr, i32) 13 14define i32 @length0(ptr %X, ptr %Y) nounwind { 15; X86-LABEL: length0: 16; X86: # %bb.0: 17; X86-NEXT: xorl %eax, %eax 18; X86-NEXT: retl 19 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 0) nounwind 20 ret i32 %m 21 } 22 23define i1 @length0_eq(ptr %X, ptr %Y) nounwind { 24; X86-LABEL: length0_eq: 25; X86: # %bb.0: 26; X86-NEXT: movb $1, %al 27; X86-NEXT: retl 28 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 0) nounwind 29 %c = icmp eq i32 %m, 0 30 ret i1 %c 31} 32 33define i1 @length0_lt(ptr %X, ptr %Y) nounwind { 34; X86-LABEL: length0_lt: 35; X86: # %bb.0: 36; X86-NEXT: xorl %eax, %eax 37; X86-NEXT: retl 38 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 0) nounwind 39 %c = icmp slt i32 %m, 0 40 ret i1 %c 41} 42 43define i32 @length2(ptr %X, ptr %Y) nounwind { 44; X86-LABEL: length2: 45; X86: # %bb.0: 46; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 47; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx 48; X86-NEXT: movzwl (%ecx), %ecx 49; X86-NEXT: movzwl (%eax), %edx 50; X86-NEXT: rolw $8, %cx 51; X86-NEXT: rolw $8, %dx 52; X86-NEXT: movzwl %cx, %eax 53; X86-NEXT: movzwl %dx, %ecx 54; X86-NEXT: subl %ecx, %eax 55; X86-NEXT: retl 56 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 2) nounwind 57 ret i32 %m 58} 59 60define i32 @length2_const(ptr %X, ptr %Y) nounwind { 61; X86-LABEL: length2_const: 62; X86: # %bb.0: 63; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 64; X86-NEXT: movzwl (%eax), %eax 65; X86-NEXT: rolw $8, %ax 66; X86-NEXT: movzwl %ax, %eax 67; X86-NEXT: addl $-12594, %eax # imm = 0xCECE 68; X86-NEXT: retl 69 %m = tail call i32 @memcmp(ptr %X, ptr getelementptr inbounds ([513 x i8], ptr @.str, i32 0, i32 1), i32 2) nounwind 70 ret i32 %m 71} 72 73define i1 @length2_gt_const(ptr %X, ptr %Y) nounwind { 74; X86-LABEL: length2_gt_const: 75; X86: # %bb.0: 76; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 77; X86-NEXT: movzwl (%eax), %eax 78; X86-NEXT: rolw $8, %ax 79; X86-NEXT: movzwl %ax, %eax 80; X86-NEXT: addl $-12594, %eax # imm = 0xCECE 81; X86-NEXT: testl %eax, %eax 82; X86-NEXT: setg %al 83; X86-NEXT: retl 84 %m = tail call i32 @memcmp(ptr %X, ptr getelementptr inbounds ([513 x i8], ptr @.str, i32 0, i32 1), i32 2) nounwind 85 %c = icmp sgt i32 %m, 0 86 ret i1 %c 87} 88 89define i1 @length2_eq(ptr %X, ptr %Y) nounwind { 90; X86-LABEL: length2_eq: 91; X86: # %bb.0: 92; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 93; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx 94; X86-NEXT: movzwl (%ecx), %ecx 95; X86-NEXT: cmpw (%eax), %cx 96; X86-NEXT: sete %al 97; X86-NEXT: retl 98 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 2) nounwind 99 %c = icmp eq i32 %m, 0 100 ret i1 %c 101} 102 103define i1 @length2_lt(ptr %X, ptr %Y) nounwind { 104; X86-LABEL: length2_lt: 105; X86: # %bb.0: 106; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 107; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx 108; X86-NEXT: movzwl (%ecx), %ecx 109; X86-NEXT: movzwl (%eax), %edx 110; X86-NEXT: rolw $8, %cx 111; X86-NEXT: rolw $8, %dx 112; X86-NEXT: movzwl %cx, %eax 113; X86-NEXT: movzwl %dx, %ecx 114; X86-NEXT: subl %ecx, %eax 115; X86-NEXT: shrl $31, %eax 116; X86-NEXT: # kill: def $al killed $al killed $eax 117; X86-NEXT: retl 118 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 2) nounwind 119 %c = icmp slt i32 %m, 0 120 ret i1 %c 121} 122 123define i1 @length2_gt(ptr %X, ptr %Y) nounwind { 124; X86-LABEL: length2_gt: 125; X86: # %bb.0: 126; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 127; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx 128; X86-NEXT: movzwl (%ecx), %ecx 129; X86-NEXT: movzwl (%eax), %eax 130; X86-NEXT: rolw $8, %cx 131; X86-NEXT: rolw $8, %ax 132; X86-NEXT: movzwl %cx, %ecx 133; X86-NEXT: movzwl %ax, %eax 134; X86-NEXT: subl %eax, %ecx 135; X86-NEXT: testl %ecx, %ecx 136; X86-NEXT: setg %al 137; X86-NEXT: retl 138 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 2) nounwind 139 %c = icmp sgt i32 %m, 0 140 ret i1 %c 141} 142 143define i1 @length2_eq_const(ptr %X) nounwind { 144; X86-LABEL: length2_eq_const: 145; X86: # %bb.0: 146; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 147; X86-NEXT: movzwl (%eax), %eax 148; X86-NEXT: cmpl $12849, %eax # imm = 0x3231 149; X86-NEXT: setne %al 150; X86-NEXT: retl 151 %m = tail call i32 @memcmp(ptr %X, ptr getelementptr inbounds ([513 x i8], ptr @.str, i32 0, i32 1), i32 2) nounwind 152 %c = icmp ne i32 %m, 0 153 ret i1 %c 154} 155 156define i1 @length2_eq_nobuiltin_attr(ptr %X, ptr %Y) nounwind { 157; X86-LABEL: length2_eq_nobuiltin_attr: 158; X86: # %bb.0: 159; X86-NEXT: pushl $2 160; X86-NEXT: pushl {{[0-9]+}}(%esp) 161; X86-NEXT: pushl {{[0-9]+}}(%esp) 162; X86-NEXT: calll memcmp 163; X86-NEXT: addl $12, %esp 164; X86-NEXT: testl %eax, %eax 165; X86-NEXT: sete %al 166; X86-NEXT: retl 167 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 2) nounwind nobuiltin 168 %c = icmp eq i32 %m, 0 169 ret i1 %c 170} 171 172define i32 @length3(ptr %X, ptr %Y) nounwind { 173; X86-LABEL: length3: 174; X86: # %bb.0: 175; X86-NEXT: pushl %esi 176; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx 177; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 178; X86-NEXT: movzwl (%eax), %edx 179; X86-NEXT: movzwl (%ecx), %esi 180; X86-NEXT: rolw $8, %dx 181; X86-NEXT: rolw $8, %si 182; X86-NEXT: cmpw %si, %dx 183; X86-NEXT: jne .LBB11_3 184; X86-NEXT: # %bb.1: # %loadbb1 185; X86-NEXT: movzbl 2(%eax), %eax 186; X86-NEXT: movzbl 2(%ecx), %ecx 187; X86-NEXT: subl %ecx, %eax 188; X86-NEXT: popl %esi 189; X86-NEXT: retl 190; X86-NEXT: .LBB11_3: # %res_block 191; X86-NEXT: setae %al 192; X86-NEXT: movzbl %al, %eax 193; X86-NEXT: leal -1(%eax,%eax), %eax 194; X86-NEXT: popl %esi 195; X86-NEXT: retl 196 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 3) nounwind 197 ret i32 %m 198} 199 200define i1 @length3_eq(ptr %X, ptr %Y) nounwind { 201; X86-LABEL: length3_eq: 202; X86: # %bb.0: 203; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 204; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx 205; X86-NEXT: movzwl (%ecx), %edx 206; X86-NEXT: xorw (%eax), %dx 207; X86-NEXT: movzbl 2(%ecx), %ecx 208; X86-NEXT: xorb 2(%eax), %cl 209; X86-NEXT: movzbl %cl, %eax 210; X86-NEXT: orw %dx, %ax 211; X86-NEXT: setne %al 212; X86-NEXT: retl 213 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 3) nounwind 214 %c = icmp ne i32 %m, 0 215 ret i1 %c 216} 217 218define i32 @length4(ptr %X, ptr %Y) nounwind { 219; X86-LABEL: length4: 220; X86: # %bb.0: 221; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 222; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx 223; X86-NEXT: movl (%ecx), %ecx 224; X86-NEXT: movl (%eax), %edx 225; X86-NEXT: bswapl %ecx 226; X86-NEXT: bswapl %edx 227; X86-NEXT: xorl %eax, %eax 228; X86-NEXT: cmpl %edx, %ecx 229; X86-NEXT: seta %al 230; X86-NEXT: sbbl $0, %eax 231; X86-NEXT: retl 232 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 4) nounwind 233 ret i32 %m 234} 235 236define i1 @length4_eq(ptr %X, ptr %Y) nounwind { 237; X86-LABEL: length4_eq: 238; X86: # %bb.0: 239; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 240; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx 241; X86-NEXT: movl (%ecx), %ecx 242; X86-NEXT: cmpl (%eax), %ecx 243; X86-NEXT: setne %al 244; X86-NEXT: retl 245 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 4) nounwind 246 %c = icmp ne i32 %m, 0 247 ret i1 %c 248} 249 250define i1 @length4_lt(ptr %X, ptr %Y) nounwind { 251; X86-LABEL: length4_lt: 252; X86: # %bb.0: 253; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 254; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx 255; X86-NEXT: movl (%ecx), %ecx 256; X86-NEXT: movl (%eax), %edx 257; X86-NEXT: bswapl %ecx 258; X86-NEXT: bswapl %edx 259; X86-NEXT: xorl %eax, %eax 260; X86-NEXT: cmpl %edx, %ecx 261; X86-NEXT: seta %al 262; X86-NEXT: sbbl $0, %eax 263; X86-NEXT: shrl $31, %eax 264; X86-NEXT: # kill: def $al killed $al killed $eax 265; X86-NEXT: retl 266 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 4) nounwind 267 %c = icmp slt i32 %m, 0 268 ret i1 %c 269} 270 271define i1 @length4_gt(ptr %X, ptr %Y) nounwind { 272; X86-LABEL: length4_gt: 273; X86: # %bb.0: 274; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 275; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx 276; X86-NEXT: movl (%ecx), %ecx 277; X86-NEXT: movl (%eax), %eax 278; X86-NEXT: bswapl %ecx 279; X86-NEXT: bswapl %eax 280; X86-NEXT: xorl %edx, %edx 281; X86-NEXT: cmpl %eax, %ecx 282; X86-NEXT: seta %dl 283; X86-NEXT: sbbl $0, %edx 284; X86-NEXT: testl %edx, %edx 285; X86-NEXT: setg %al 286; X86-NEXT: retl 287 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 4) nounwind 288 %c = icmp sgt i32 %m, 0 289 ret i1 %c 290} 291 292define i1 @length4_eq_const(ptr %X) nounwind { 293; X86-LABEL: length4_eq_const: 294; X86: # %bb.0: 295; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 296; X86-NEXT: cmpl $875770417, (%eax) # imm = 0x34333231 297; X86-NEXT: sete %al 298; X86-NEXT: retl 299 %m = tail call i32 @memcmp(ptr %X, ptr getelementptr inbounds ([513 x i8], ptr @.str, i32 0, i32 1), i32 4) nounwind 300 %c = icmp eq i32 %m, 0 301 ret i1 %c 302} 303 304define i32 @length5(ptr %X, ptr %Y) nounwind { 305; X86-LABEL: length5: 306; X86: # %bb.0: 307; X86-NEXT: pushl %esi 308; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx 309; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 310; X86-NEXT: movl (%eax), %edx 311; X86-NEXT: movl (%ecx), %esi 312; X86-NEXT: bswapl %edx 313; X86-NEXT: bswapl %esi 314; X86-NEXT: cmpl %esi, %edx 315; X86-NEXT: jne .LBB18_3 316; X86-NEXT: # %bb.1: # %loadbb1 317; X86-NEXT: movzbl 4(%eax), %eax 318; X86-NEXT: movzbl 4(%ecx), %ecx 319; X86-NEXT: subl %ecx, %eax 320; X86-NEXT: popl %esi 321; X86-NEXT: retl 322; X86-NEXT: .LBB18_3: # %res_block 323; X86-NEXT: setae %al 324; X86-NEXT: movzbl %al, %eax 325; X86-NEXT: leal -1(%eax,%eax), %eax 326; X86-NEXT: popl %esi 327; X86-NEXT: retl 328 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 5) nounwind 329 ret i32 %m 330} 331 332define i1 @length5_eq(ptr %X, ptr %Y) nounwind { 333; X86-LABEL: length5_eq: 334; X86: # %bb.0: 335; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 336; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx 337; X86-NEXT: movl (%ecx), %edx 338; X86-NEXT: xorl (%eax), %edx 339; X86-NEXT: movzbl 4(%ecx), %ecx 340; X86-NEXT: xorb 4(%eax), %cl 341; X86-NEXT: movzbl %cl, %eax 342; X86-NEXT: orl %edx, %eax 343; X86-NEXT: setne %al 344; X86-NEXT: retl 345 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 5) nounwind 346 %c = icmp ne i32 %m, 0 347 ret i1 %c 348} 349 350define i1 @length5_lt(ptr %X, ptr %Y) nounwind { 351; X86-LABEL: length5_lt: 352; X86: # %bb.0: 353; X86-NEXT: pushl %esi 354; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx 355; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 356; X86-NEXT: movl (%eax), %edx 357; X86-NEXT: movl (%ecx), %esi 358; X86-NEXT: bswapl %edx 359; X86-NEXT: bswapl %esi 360; X86-NEXT: cmpl %esi, %edx 361; X86-NEXT: jne .LBB20_3 362; X86-NEXT: # %bb.1: # %loadbb1 363; X86-NEXT: movzbl 4(%eax), %eax 364; X86-NEXT: movzbl 4(%ecx), %ecx 365; X86-NEXT: subl %ecx, %eax 366; X86-NEXT: jmp .LBB20_2 367; X86-NEXT: .LBB20_3: # %res_block 368; X86-NEXT: setae %al 369; X86-NEXT: movzbl %al, %eax 370; X86-NEXT: leal -1(%eax,%eax), %eax 371; X86-NEXT: .LBB20_2: # %endblock 372; X86-NEXT: shrl $31, %eax 373; X86-NEXT: # kill: def $al killed $al killed $eax 374; X86-NEXT: popl %esi 375; X86-NEXT: retl 376 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 5) nounwind 377 %c = icmp slt i32 %m, 0 378 ret i1 %c 379} 380 381define i32 @length7(ptr %X, ptr %Y) nounwind { 382; X86-LABEL: length7: 383; X86: # %bb.0: 384; X86-NEXT: pushl %esi 385; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 386; X86-NEXT: movl {{[0-9]+}}(%esp), %esi 387; X86-NEXT: movl (%esi), %ecx 388; X86-NEXT: movl (%eax), %edx 389; X86-NEXT: bswapl %ecx 390; X86-NEXT: bswapl %edx 391; X86-NEXT: cmpl %edx, %ecx 392; X86-NEXT: jne .LBB21_2 393; X86-NEXT: # %bb.1: # %loadbb1 394; X86-NEXT: movl 3(%esi), %ecx 395; X86-NEXT: movl 3(%eax), %edx 396; X86-NEXT: bswapl %ecx 397; X86-NEXT: bswapl %edx 398; X86-NEXT: xorl %eax, %eax 399; X86-NEXT: cmpl %edx, %ecx 400; X86-NEXT: je .LBB21_3 401; X86-NEXT: .LBB21_2: # %res_block 402; X86-NEXT: xorl %eax, %eax 403; X86-NEXT: cmpl %edx, %ecx 404; X86-NEXT: setae %al 405; X86-NEXT: leal -1(%eax,%eax), %eax 406; X86-NEXT: .LBB21_3: # %endblock 407; X86-NEXT: popl %esi 408; X86-NEXT: retl 409 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 7) nounwind 410 ret i32 %m 411} 412 413define i1 @length7_lt(ptr %X, ptr %Y) nounwind { 414; X86-LABEL: length7_lt: 415; X86: # %bb.0: 416; X86-NEXT: pushl %esi 417; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 418; X86-NEXT: movl {{[0-9]+}}(%esp), %esi 419; X86-NEXT: movl (%esi), %ecx 420; X86-NEXT: movl (%eax), %edx 421; X86-NEXT: bswapl %ecx 422; X86-NEXT: bswapl %edx 423; X86-NEXT: cmpl %edx, %ecx 424; X86-NEXT: jne .LBB22_2 425; X86-NEXT: # %bb.1: # %loadbb1 426; X86-NEXT: movl 3(%esi), %ecx 427; X86-NEXT: movl 3(%eax), %edx 428; X86-NEXT: bswapl %ecx 429; X86-NEXT: bswapl %edx 430; X86-NEXT: xorl %eax, %eax 431; X86-NEXT: cmpl %edx, %ecx 432; X86-NEXT: je .LBB22_3 433; X86-NEXT: .LBB22_2: # %res_block 434; X86-NEXT: xorl %eax, %eax 435; X86-NEXT: cmpl %edx, %ecx 436; X86-NEXT: setae %al 437; X86-NEXT: leal -1(%eax,%eax), %eax 438; X86-NEXT: .LBB22_3: # %endblock 439; X86-NEXT: shrl $31, %eax 440; X86-NEXT: # kill: def $al killed $al killed $eax 441; X86-NEXT: popl %esi 442; X86-NEXT: retl 443 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 7) nounwind 444 %c = icmp slt i32 %m, 0 445 ret i1 %c 446} 447 448define i1 @length7_eq(ptr %X, ptr %Y) nounwind { 449; X86-LABEL: length7_eq: 450; X86: # %bb.0: 451; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 452; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx 453; X86-NEXT: movl (%ecx), %edx 454; X86-NEXT: movl 3(%ecx), %ecx 455; X86-NEXT: xorl (%eax), %edx 456; X86-NEXT: xorl 3(%eax), %ecx 457; X86-NEXT: orl %edx, %ecx 458; X86-NEXT: setne %al 459; X86-NEXT: retl 460 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 7) nounwind 461 %c = icmp ne i32 %m, 0 462 ret i1 %c 463} 464 465define i32 @length8(ptr %X, ptr %Y) nounwind { 466; X86-LABEL: length8: 467; X86: # %bb.0: 468; X86-NEXT: pushl %esi 469; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 470; X86-NEXT: movl {{[0-9]+}}(%esp), %esi 471; X86-NEXT: movl (%esi), %ecx 472; X86-NEXT: movl (%eax), %edx 473; X86-NEXT: bswapl %ecx 474; X86-NEXT: bswapl %edx 475; X86-NEXT: cmpl %edx, %ecx 476; X86-NEXT: jne .LBB24_2 477; X86-NEXT: # %bb.1: # %loadbb1 478; X86-NEXT: movl 4(%esi), %ecx 479; X86-NEXT: movl 4(%eax), %edx 480; X86-NEXT: bswapl %ecx 481; X86-NEXT: bswapl %edx 482; X86-NEXT: xorl %eax, %eax 483; X86-NEXT: cmpl %edx, %ecx 484; X86-NEXT: je .LBB24_3 485; X86-NEXT: .LBB24_2: # %res_block 486; X86-NEXT: xorl %eax, %eax 487; X86-NEXT: cmpl %edx, %ecx 488; X86-NEXT: setae %al 489; X86-NEXT: leal -1(%eax,%eax), %eax 490; X86-NEXT: .LBB24_3: # %endblock 491; X86-NEXT: popl %esi 492; X86-NEXT: retl 493 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 8) nounwind 494 ret i32 %m 495} 496 497define i1 @length8_eq(ptr %X, ptr %Y) nounwind { 498; X86-LABEL: length8_eq: 499; X86: # %bb.0: 500; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 501; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx 502; X86-NEXT: movl (%ecx), %edx 503; X86-NEXT: movl 4(%ecx), %ecx 504; X86-NEXT: xorl (%eax), %edx 505; X86-NEXT: xorl 4(%eax), %ecx 506; X86-NEXT: orl %edx, %ecx 507; X86-NEXT: sete %al 508; X86-NEXT: retl 509 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 8) nounwind 510 %c = icmp eq i32 %m, 0 511 ret i1 %c 512} 513 514define i1 @length8_eq_const(ptr %X) nounwind { 515; X86-LABEL: length8_eq_const: 516; X86: # %bb.0: 517; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 518; X86-NEXT: movl $858927408, %ecx # imm = 0x33323130 519; X86-NEXT: xorl (%eax), %ecx 520; X86-NEXT: movl $926299444, %edx # imm = 0x37363534 521; X86-NEXT: xorl 4(%eax), %edx 522; X86-NEXT: orl %ecx, %edx 523; X86-NEXT: setne %al 524; X86-NEXT: retl 525 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i32 8) nounwind 526 %c = icmp ne i32 %m, 0 527 ret i1 %c 528} 529 530define i1 @length9_eq(ptr %X, ptr %Y) nounwind { 531; X86-LABEL: length9_eq: 532; X86: # %bb.0: 533; X86-NEXT: pushl $9 534; X86-NEXT: pushl {{[0-9]+}}(%esp) 535; X86-NEXT: pushl {{[0-9]+}}(%esp) 536; X86-NEXT: calll memcmp 537; X86-NEXT: addl $12, %esp 538; X86-NEXT: testl %eax, %eax 539; X86-NEXT: sete %al 540; X86-NEXT: retl 541 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 9) nounwind 542 %c = icmp eq i32 %m, 0 543 ret i1 %c 544} 545 546define i1 @length10_eq(ptr %X, ptr %Y) nounwind { 547; X86-LABEL: length10_eq: 548; X86: # %bb.0: 549; X86-NEXT: pushl $10 550; X86-NEXT: pushl {{[0-9]+}}(%esp) 551; X86-NEXT: pushl {{[0-9]+}}(%esp) 552; X86-NEXT: calll memcmp 553; X86-NEXT: addl $12, %esp 554; X86-NEXT: testl %eax, %eax 555; X86-NEXT: sete %al 556; X86-NEXT: retl 557 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 10) nounwind 558 %c = icmp eq i32 %m, 0 559 ret i1 %c 560} 561 562define i1 @length11_eq(ptr %X, ptr %Y) nounwind { 563; X86-LABEL: length11_eq: 564; X86: # %bb.0: 565; X86-NEXT: pushl $11 566; X86-NEXT: pushl {{[0-9]+}}(%esp) 567; X86-NEXT: pushl {{[0-9]+}}(%esp) 568; X86-NEXT: calll memcmp 569; X86-NEXT: addl $12, %esp 570; X86-NEXT: testl %eax, %eax 571; X86-NEXT: sete %al 572; X86-NEXT: retl 573 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 11) nounwind 574 %c = icmp eq i32 %m, 0 575 ret i1 %c 576} 577 578define i1 @length12_eq(ptr %X, ptr %Y) nounwind { 579; X86-LABEL: length12_eq: 580; X86: # %bb.0: 581; X86-NEXT: pushl $12 582; X86-NEXT: pushl {{[0-9]+}}(%esp) 583; X86-NEXT: pushl {{[0-9]+}}(%esp) 584; X86-NEXT: calll memcmp 585; X86-NEXT: addl $12, %esp 586; X86-NEXT: testl %eax, %eax 587; X86-NEXT: setne %al 588; X86-NEXT: retl 589 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 12) nounwind 590 %c = icmp ne i32 %m, 0 591 ret i1 %c 592} 593 594define i32 @length12(ptr %X, ptr %Y) nounwind { 595; X86-LABEL: length12: 596; X86: # %bb.0: 597; X86-NEXT: pushl $12 598; X86-NEXT: pushl {{[0-9]+}}(%esp) 599; X86-NEXT: pushl {{[0-9]+}}(%esp) 600; X86-NEXT: calll memcmp 601; X86-NEXT: addl $12, %esp 602; X86-NEXT: retl 603 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 12) nounwind 604 ret i32 %m 605} 606 607define i1 @length13_eq(ptr %X, ptr %Y) nounwind { 608; X86-LABEL: length13_eq: 609; X86: # %bb.0: 610; X86-NEXT: pushl $13 611; X86-NEXT: pushl {{[0-9]+}}(%esp) 612; X86-NEXT: pushl {{[0-9]+}}(%esp) 613; X86-NEXT: calll memcmp 614; X86-NEXT: addl $12, %esp 615; X86-NEXT: testl %eax, %eax 616; X86-NEXT: sete %al 617; X86-NEXT: retl 618 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 13) nounwind 619 %c = icmp eq i32 %m, 0 620 ret i1 %c 621} 622 623define i1 @length14_eq(ptr %X, ptr %Y) nounwind { 624; X86-LABEL: length14_eq: 625; X86: # %bb.0: 626; X86-NEXT: pushl $14 627; X86-NEXT: pushl {{[0-9]+}}(%esp) 628; X86-NEXT: pushl {{[0-9]+}}(%esp) 629; X86-NEXT: calll memcmp 630; X86-NEXT: addl $12, %esp 631; X86-NEXT: testl %eax, %eax 632; X86-NEXT: sete %al 633; X86-NEXT: retl 634 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 14) nounwind 635 %c = icmp eq i32 %m, 0 636 ret i1 %c 637} 638 639define i32 @length15(ptr %X, ptr %Y) nounwind { 640; X86-LABEL: length15: 641; X86: # %bb.0: 642; X86-NEXT: pushl $15 643; X86-NEXT: pushl {{[0-9]+}}(%esp) 644; X86-NEXT: pushl {{[0-9]+}}(%esp) 645; X86-NEXT: calll memcmp 646; X86-NEXT: addl $12, %esp 647; X86-NEXT: retl 648 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 15) nounwind 649 ret i32 %m 650} 651 652define i1 @length15_lt(ptr %X, ptr %Y) nounwind { 653; X86-LABEL: length15_lt: 654; X86: # %bb.0: 655; X86-NEXT: pushl $15 656; X86-NEXT: pushl {{[0-9]+}}(%esp) 657; X86-NEXT: pushl {{[0-9]+}}(%esp) 658; X86-NEXT: calll memcmp 659; X86-NEXT: addl $12, %esp 660; X86-NEXT: shrl $31, %eax 661; X86-NEXT: # kill: def $al killed $al killed $eax 662; X86-NEXT: retl 663 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 15) nounwind 664 %c = icmp slt i32 %m, 0 665 ret i1 %c 666} 667 668define i32 @length15_const(ptr %X, ptr %Y) nounwind { 669; X86-LABEL: length15_const: 670; X86: # %bb.0: 671; X86-NEXT: pushl $15 672; X86-NEXT: pushl $.L.str+1 673; X86-NEXT: pushl {{[0-9]+}}(%esp) 674; X86-NEXT: calll memcmp 675; X86-NEXT: addl $12, %esp 676; X86-NEXT: retl 677 %m = tail call i32 @memcmp(ptr %X, ptr getelementptr inbounds ([513 x i8], ptr @.str, i32 0, i32 1), i32 15) nounwind 678 ret i32 %m 679} 680 681define i1 @length15_eq(ptr %X, ptr %Y) nounwind { 682; X86-LABEL: length15_eq: 683; X86: # %bb.0: 684; X86-NEXT: pushl $15 685; X86-NEXT: pushl {{[0-9]+}}(%esp) 686; X86-NEXT: pushl {{[0-9]+}}(%esp) 687; X86-NEXT: calll memcmp 688; X86-NEXT: addl $12, %esp 689; X86-NEXT: testl %eax, %eax 690; X86-NEXT: sete %al 691; X86-NEXT: retl 692 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 15) nounwind 693 %c = icmp eq i32 %m, 0 694 ret i1 %c 695} 696 697define i1 @length15_gt_const(ptr %X, ptr %Y) nounwind { 698; X86-LABEL: length15_gt_const: 699; X86: # %bb.0: 700; X86-NEXT: pushl $15 701; X86-NEXT: pushl $.L.str+1 702; X86-NEXT: pushl {{[0-9]+}}(%esp) 703; X86-NEXT: calll memcmp 704; X86-NEXT: addl $12, %esp 705; X86-NEXT: testl %eax, %eax 706; X86-NEXT: setg %al 707; X86-NEXT: retl 708 %m = tail call i32 @memcmp(ptr %X, ptr getelementptr inbounds ([513 x i8], ptr @.str, i32 0, i32 1), i32 15) nounwind 709 %c = icmp sgt i32 %m, 0 710 ret i1 %c 711} 712 713; PR33329 - https://bugs.llvm.org/show_bug.cgi?id=33329 714 715define i32 @length16(ptr %X, ptr %Y) nounwind { 716; X86-LABEL: length16: 717; X86: # %bb.0: 718; X86-NEXT: pushl $16 719; X86-NEXT: pushl {{[0-9]+}}(%esp) 720; X86-NEXT: pushl {{[0-9]+}}(%esp) 721; X86-NEXT: calll memcmp 722; X86-NEXT: addl $12, %esp 723; X86-NEXT: retl 724 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 16) nounwind 725 ret i32 %m 726} 727 728define i1 @length16_eq(ptr %x, ptr %y) nounwind { 729; X86-NOSSE-LABEL: length16_eq: 730; X86-NOSSE: # %bb.0: 731; X86-NOSSE-NEXT: pushl $16 732; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp) 733; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp) 734; X86-NOSSE-NEXT: calll memcmp 735; X86-NOSSE-NEXT: addl $12, %esp 736; X86-NOSSE-NEXT: testl %eax, %eax 737; X86-NOSSE-NEXT: setne %al 738; X86-NOSSE-NEXT: retl 739; 740; X86-SSE1-LABEL: length16_eq: 741; X86-SSE1: # %bb.0: 742; X86-SSE1-NEXT: pushl $16 743; X86-SSE1-NEXT: pushl {{[0-9]+}}(%esp) 744; X86-SSE1-NEXT: pushl {{[0-9]+}}(%esp) 745; X86-SSE1-NEXT: calll memcmp 746; X86-SSE1-NEXT: addl $12, %esp 747; X86-SSE1-NEXT: testl %eax, %eax 748; X86-SSE1-NEXT: setne %al 749; X86-SSE1-NEXT: retl 750; 751; X86-SSE2-LABEL: length16_eq: 752; X86-SSE2: # %bb.0: 753; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax 754; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %ecx 755; X86-SSE2-NEXT: movdqu (%ecx), %xmm0 756; X86-SSE2-NEXT: movdqu (%eax), %xmm1 757; X86-SSE2-NEXT: pcmpeqb %xmm0, %xmm1 758; X86-SSE2-NEXT: pmovmskb %xmm1, %eax 759; X86-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF 760; X86-SSE2-NEXT: setne %al 761; X86-SSE2-NEXT: retl 762; 763; X86-SSE41-LABEL: length16_eq: 764; X86-SSE41: # %bb.0: 765; X86-SSE41-NEXT: movl {{[0-9]+}}(%esp), %eax 766; X86-SSE41-NEXT: movl {{[0-9]+}}(%esp), %ecx 767; X86-SSE41-NEXT: movdqu (%ecx), %xmm0 768; X86-SSE41-NEXT: movdqu (%eax), %xmm1 769; X86-SSE41-NEXT: pxor %xmm0, %xmm1 770; X86-SSE41-NEXT: ptest %xmm1, %xmm1 771; X86-SSE41-NEXT: setne %al 772; X86-SSE41-NEXT: retl 773 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 16) nounwind 774 %cmp = icmp ne i32 %call, 0 775 ret i1 %cmp 776} 777 778define i1 @length16_lt(ptr %x, ptr %y) nounwind { 779; X86-LABEL: length16_lt: 780; X86: # %bb.0: 781; X86-NEXT: pushl $16 782; X86-NEXT: pushl {{[0-9]+}}(%esp) 783; X86-NEXT: pushl {{[0-9]+}}(%esp) 784; X86-NEXT: calll memcmp 785; X86-NEXT: addl $12, %esp 786; X86-NEXT: shrl $31, %eax 787; X86-NEXT: # kill: def $al killed $al killed $eax 788; X86-NEXT: retl 789 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 16) nounwind 790 %cmp = icmp slt i32 %call, 0 791 ret i1 %cmp 792} 793 794define i1 @length16_gt(ptr %x, ptr %y) nounwind { 795; X86-LABEL: length16_gt: 796; X86: # %bb.0: 797; X86-NEXT: pushl $16 798; X86-NEXT: pushl {{[0-9]+}}(%esp) 799; X86-NEXT: pushl {{[0-9]+}}(%esp) 800; X86-NEXT: calll memcmp 801; X86-NEXT: addl $12, %esp 802; X86-NEXT: testl %eax, %eax 803; X86-NEXT: setg %al 804; X86-NEXT: retl 805 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 16) nounwind 806 %cmp = icmp sgt i32 %call, 0 807 ret i1 %cmp 808} 809 810define i1 @length16_eq_const(ptr %X) nounwind { 811; X86-NOSSE-LABEL: length16_eq_const: 812; X86-NOSSE: # %bb.0: 813; X86-NOSSE-NEXT: pushl $16 814; X86-NOSSE-NEXT: pushl $.L.str 815; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp) 816; X86-NOSSE-NEXT: calll memcmp 817; X86-NOSSE-NEXT: addl $12, %esp 818; X86-NOSSE-NEXT: testl %eax, %eax 819; X86-NOSSE-NEXT: sete %al 820; X86-NOSSE-NEXT: retl 821; 822; X86-SSE1-LABEL: length16_eq_const: 823; X86-SSE1: # %bb.0: 824; X86-SSE1-NEXT: pushl $16 825; X86-SSE1-NEXT: pushl $.L.str 826; X86-SSE1-NEXT: pushl {{[0-9]+}}(%esp) 827; X86-SSE1-NEXT: calll memcmp 828; X86-SSE1-NEXT: addl $12, %esp 829; X86-SSE1-NEXT: testl %eax, %eax 830; X86-SSE1-NEXT: sete %al 831; X86-SSE1-NEXT: retl 832; 833; X86-SSE2-LABEL: length16_eq_const: 834; X86-SSE2: # %bb.0: 835; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax 836; X86-SSE2-NEXT: movdqu (%eax), %xmm0 837; X86-SSE2-NEXT: pcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0 838; X86-SSE2-NEXT: pmovmskb %xmm0, %eax 839; X86-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF 840; X86-SSE2-NEXT: sete %al 841; X86-SSE2-NEXT: retl 842; 843; X86-SSE41-LABEL: length16_eq_const: 844; X86-SSE41: # %bb.0: 845; X86-SSE41-NEXT: movl {{[0-9]+}}(%esp), %eax 846; X86-SSE41-NEXT: movdqu (%eax), %xmm0 847; X86-SSE41-NEXT: pxor {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0 848; X86-SSE41-NEXT: ptest %xmm0, %xmm0 849; X86-SSE41-NEXT: sete %al 850; X86-SSE41-NEXT: retl 851 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i32 16) nounwind 852 %c = icmp eq i32 %m, 0 853 ret i1 %c 854} 855 856; PR33914 - https://bugs.llvm.org/show_bug.cgi?id=33914 857 858define i32 @length24(ptr %X, ptr %Y) nounwind { 859; X86-LABEL: length24: 860; X86: # %bb.0: 861; X86-NEXT: pushl $24 862; X86-NEXT: pushl {{[0-9]+}}(%esp) 863; X86-NEXT: pushl {{[0-9]+}}(%esp) 864; X86-NEXT: calll memcmp 865; X86-NEXT: addl $12, %esp 866; X86-NEXT: retl 867 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 24) nounwind 868 ret i32 %m 869} 870 871define i1 @length24_eq(ptr %x, ptr %y) nounwind { 872; X86-NOSSE-LABEL: length24_eq: 873; X86-NOSSE: # %bb.0: 874; X86-NOSSE-NEXT: pushl $24 875; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp) 876; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp) 877; X86-NOSSE-NEXT: calll memcmp 878; X86-NOSSE-NEXT: addl $12, %esp 879; X86-NOSSE-NEXT: testl %eax, %eax 880; X86-NOSSE-NEXT: sete %al 881; X86-NOSSE-NEXT: retl 882; 883; X86-SSE1-LABEL: length24_eq: 884; X86-SSE1: # %bb.0: 885; X86-SSE1-NEXT: pushl $24 886; X86-SSE1-NEXT: pushl {{[0-9]+}}(%esp) 887; X86-SSE1-NEXT: pushl {{[0-9]+}}(%esp) 888; X86-SSE1-NEXT: calll memcmp 889; X86-SSE1-NEXT: addl $12, %esp 890; X86-SSE1-NEXT: testl %eax, %eax 891; X86-SSE1-NEXT: sete %al 892; X86-SSE1-NEXT: retl 893; 894; X86-SSE2-LABEL: length24_eq: 895; X86-SSE2: # %bb.0: 896; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax 897; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %ecx 898; X86-SSE2-NEXT: movdqu (%ecx), %xmm0 899; X86-SSE2-NEXT: movdqu 8(%ecx), %xmm1 900; X86-SSE2-NEXT: movdqu (%eax), %xmm2 901; X86-SSE2-NEXT: pcmpeqb %xmm0, %xmm2 902; X86-SSE2-NEXT: movdqu 8(%eax), %xmm0 903; X86-SSE2-NEXT: pcmpeqb %xmm1, %xmm0 904; X86-SSE2-NEXT: pand %xmm2, %xmm0 905; X86-SSE2-NEXT: pmovmskb %xmm0, %eax 906; X86-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF 907; X86-SSE2-NEXT: sete %al 908; X86-SSE2-NEXT: retl 909; 910; X86-SSE41-LABEL: length24_eq: 911; X86-SSE41: # %bb.0: 912; X86-SSE41-NEXT: movl {{[0-9]+}}(%esp), %eax 913; X86-SSE41-NEXT: movl {{[0-9]+}}(%esp), %ecx 914; X86-SSE41-NEXT: movdqu (%ecx), %xmm0 915; X86-SSE41-NEXT: movdqu 8(%ecx), %xmm1 916; X86-SSE41-NEXT: movdqu (%eax), %xmm2 917; X86-SSE41-NEXT: pxor %xmm0, %xmm2 918; X86-SSE41-NEXT: movdqu 8(%eax), %xmm0 919; X86-SSE41-NEXT: pxor %xmm1, %xmm0 920; X86-SSE41-NEXT: por %xmm2, %xmm0 921; X86-SSE41-NEXT: ptest %xmm0, %xmm0 922; X86-SSE41-NEXT: sete %al 923; X86-SSE41-NEXT: retl 924 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 24) nounwind 925 %cmp = icmp eq i32 %call, 0 926 ret i1 %cmp 927} 928 929define i1 @length24_lt(ptr %x, ptr %y) nounwind { 930; X86-LABEL: length24_lt: 931; X86: # %bb.0: 932; X86-NEXT: pushl $24 933; X86-NEXT: pushl {{[0-9]+}}(%esp) 934; X86-NEXT: pushl {{[0-9]+}}(%esp) 935; X86-NEXT: calll memcmp 936; X86-NEXT: addl $12, %esp 937; X86-NEXT: shrl $31, %eax 938; X86-NEXT: # kill: def $al killed $al killed $eax 939; X86-NEXT: retl 940 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 24) nounwind 941 %cmp = icmp slt i32 %call, 0 942 ret i1 %cmp 943} 944 945define i1 @length24_gt(ptr %x, ptr %y) nounwind { 946; X86-LABEL: length24_gt: 947; X86: # %bb.0: 948; X86-NEXT: pushl $24 949; X86-NEXT: pushl {{[0-9]+}}(%esp) 950; X86-NEXT: pushl {{[0-9]+}}(%esp) 951; X86-NEXT: calll memcmp 952; X86-NEXT: addl $12, %esp 953; X86-NEXT: testl %eax, %eax 954; X86-NEXT: setg %al 955; X86-NEXT: retl 956 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 24) nounwind 957 %cmp = icmp sgt i32 %call, 0 958 ret i1 %cmp 959} 960 961define i1 @length24_eq_const(ptr %X) nounwind { 962; X86-NOSSE-LABEL: length24_eq_const: 963; X86-NOSSE: # %bb.0: 964; X86-NOSSE-NEXT: pushl $24 965; X86-NOSSE-NEXT: pushl $.L.str 966; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp) 967; X86-NOSSE-NEXT: calll memcmp 968; X86-NOSSE-NEXT: addl $12, %esp 969; X86-NOSSE-NEXT: testl %eax, %eax 970; X86-NOSSE-NEXT: setne %al 971; X86-NOSSE-NEXT: retl 972; 973; X86-SSE1-LABEL: length24_eq_const: 974; X86-SSE1: # %bb.0: 975; X86-SSE1-NEXT: pushl $24 976; X86-SSE1-NEXT: pushl $.L.str 977; X86-SSE1-NEXT: pushl {{[0-9]+}}(%esp) 978; X86-SSE1-NEXT: calll memcmp 979; X86-SSE1-NEXT: addl $12, %esp 980; X86-SSE1-NEXT: testl %eax, %eax 981; X86-SSE1-NEXT: setne %al 982; X86-SSE1-NEXT: retl 983; 984; X86-SSE2-LABEL: length24_eq_const: 985; X86-SSE2: # %bb.0: 986; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax 987; X86-SSE2-NEXT: movdqu (%eax), %xmm0 988; X86-SSE2-NEXT: movdqu 8(%eax), %xmm1 989; X86-SSE2-NEXT: pcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}, %xmm1 990; X86-SSE2-NEXT: pcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0 991; X86-SSE2-NEXT: pand %xmm1, %xmm0 992; X86-SSE2-NEXT: pmovmskb %xmm0, %eax 993; X86-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF 994; X86-SSE2-NEXT: setne %al 995; X86-SSE2-NEXT: retl 996; 997; X86-SSE41-LABEL: length24_eq_const: 998; X86-SSE41: # %bb.0: 999; X86-SSE41-NEXT: movl {{[0-9]+}}(%esp), %eax 1000; X86-SSE41-NEXT: movdqu (%eax), %xmm0 1001; X86-SSE41-NEXT: movdqu 8(%eax), %xmm1 1002; X86-SSE41-NEXT: pxor {{\.?LCPI[0-9]+_[0-9]+}}, %xmm1 1003; X86-SSE41-NEXT: pxor {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0 1004; X86-SSE41-NEXT: por %xmm1, %xmm0 1005; X86-SSE41-NEXT: ptest %xmm0, %xmm0 1006; X86-SSE41-NEXT: setne %al 1007; X86-SSE41-NEXT: retl 1008 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i32 24) nounwind 1009 %c = icmp ne i32 %m, 0 1010 ret i1 %c 1011} 1012 1013define i32 @length31(ptr %X, ptr %Y) nounwind { 1014; X86-LABEL: length31: 1015; X86: # %bb.0: 1016; X86-NEXT: pushl $31 1017; X86-NEXT: pushl {{[0-9]+}}(%esp) 1018; X86-NEXT: pushl {{[0-9]+}}(%esp) 1019; X86-NEXT: calll memcmp 1020; X86-NEXT: addl $12, %esp 1021; X86-NEXT: retl 1022 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 31) nounwind 1023 ret i32 %m 1024} 1025 1026define i1 @length31_eq(ptr %x, ptr %y) nounwind { 1027; X86-NOSSE-LABEL: length31_eq: 1028; X86-NOSSE: # %bb.0: 1029; X86-NOSSE-NEXT: pushl $31 1030; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp) 1031; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp) 1032; X86-NOSSE-NEXT: calll memcmp 1033; X86-NOSSE-NEXT: addl $12, %esp 1034; X86-NOSSE-NEXT: testl %eax, %eax 1035; X86-NOSSE-NEXT: sete %al 1036; X86-NOSSE-NEXT: retl 1037; 1038; X86-SSE1-LABEL: length31_eq: 1039; X86-SSE1: # %bb.0: 1040; X86-SSE1-NEXT: pushl $31 1041; X86-SSE1-NEXT: pushl {{[0-9]+}}(%esp) 1042; X86-SSE1-NEXT: pushl {{[0-9]+}}(%esp) 1043; X86-SSE1-NEXT: calll memcmp 1044; X86-SSE1-NEXT: addl $12, %esp 1045; X86-SSE1-NEXT: testl %eax, %eax 1046; X86-SSE1-NEXT: sete %al 1047; X86-SSE1-NEXT: retl 1048; 1049; X86-SSE2-LABEL: length31_eq: 1050; X86-SSE2: # %bb.0: 1051; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax 1052; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %ecx 1053; X86-SSE2-NEXT: movdqu (%ecx), %xmm0 1054; X86-SSE2-NEXT: movdqu 15(%ecx), %xmm1 1055; X86-SSE2-NEXT: movdqu (%eax), %xmm2 1056; X86-SSE2-NEXT: pcmpeqb %xmm0, %xmm2 1057; X86-SSE2-NEXT: movdqu 15(%eax), %xmm0 1058; X86-SSE2-NEXT: pcmpeqb %xmm1, %xmm0 1059; X86-SSE2-NEXT: pand %xmm2, %xmm0 1060; X86-SSE2-NEXT: pmovmskb %xmm0, %eax 1061; X86-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF 1062; X86-SSE2-NEXT: sete %al 1063; X86-SSE2-NEXT: retl 1064; 1065; X86-SSE41-LABEL: length31_eq: 1066; X86-SSE41: # %bb.0: 1067; X86-SSE41-NEXT: movl {{[0-9]+}}(%esp), %eax 1068; X86-SSE41-NEXT: movl {{[0-9]+}}(%esp), %ecx 1069; X86-SSE41-NEXT: movdqu (%ecx), %xmm0 1070; X86-SSE41-NEXT: movdqu 15(%ecx), %xmm1 1071; X86-SSE41-NEXT: movdqu (%eax), %xmm2 1072; X86-SSE41-NEXT: pxor %xmm0, %xmm2 1073; X86-SSE41-NEXT: movdqu 15(%eax), %xmm0 1074; X86-SSE41-NEXT: pxor %xmm1, %xmm0 1075; X86-SSE41-NEXT: por %xmm2, %xmm0 1076; X86-SSE41-NEXT: ptest %xmm0, %xmm0 1077; X86-SSE41-NEXT: sete %al 1078; X86-SSE41-NEXT: retl 1079 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 31) nounwind 1080 %cmp = icmp eq i32 %call, 0 1081 ret i1 %cmp 1082} 1083 1084define i1 @length31_lt(ptr %x, ptr %y) nounwind { 1085; X86-LABEL: length31_lt: 1086; X86: # %bb.0: 1087; X86-NEXT: pushl $31 1088; X86-NEXT: pushl {{[0-9]+}}(%esp) 1089; X86-NEXT: pushl {{[0-9]+}}(%esp) 1090; X86-NEXT: calll memcmp 1091; X86-NEXT: addl $12, %esp 1092; X86-NEXT: shrl $31, %eax 1093; X86-NEXT: # kill: def $al killed $al killed $eax 1094; X86-NEXT: retl 1095 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 31) nounwind 1096 %cmp = icmp slt i32 %call, 0 1097 ret i1 %cmp 1098} 1099 1100define i1 @length31_gt(ptr %x, ptr %y) nounwind { 1101; X86-LABEL: length31_gt: 1102; X86: # %bb.0: 1103; X86-NEXT: pushl $31 1104; X86-NEXT: pushl {{[0-9]+}}(%esp) 1105; X86-NEXT: pushl {{[0-9]+}}(%esp) 1106; X86-NEXT: calll memcmp 1107; X86-NEXT: addl $12, %esp 1108; X86-NEXT: testl %eax, %eax 1109; X86-NEXT: setg %al 1110; X86-NEXT: retl 1111 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 31) nounwind 1112 %cmp = icmp sgt i32 %call, 0 1113 ret i1 %cmp 1114} 1115 1116define i1 @length31_eq_prefer128(ptr %x, ptr %y) nounwind "prefer-vector-width"="128" { 1117; X86-NOSSE-LABEL: length31_eq_prefer128: 1118; X86-NOSSE: # %bb.0: 1119; X86-NOSSE-NEXT: pushl $31 1120; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp) 1121; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp) 1122; X86-NOSSE-NEXT: calll memcmp 1123; X86-NOSSE-NEXT: addl $12, %esp 1124; X86-NOSSE-NEXT: testl %eax, %eax 1125; X86-NOSSE-NEXT: sete %al 1126; X86-NOSSE-NEXT: retl 1127; 1128; X86-SSE1-LABEL: length31_eq_prefer128: 1129; X86-SSE1: # %bb.0: 1130; X86-SSE1-NEXT: pushl $31 1131; X86-SSE1-NEXT: pushl {{[0-9]+}}(%esp) 1132; X86-SSE1-NEXT: pushl {{[0-9]+}}(%esp) 1133; X86-SSE1-NEXT: calll memcmp 1134; X86-SSE1-NEXT: addl $12, %esp 1135; X86-SSE1-NEXT: testl %eax, %eax 1136; X86-SSE1-NEXT: sete %al 1137; X86-SSE1-NEXT: retl 1138; 1139; X86-SSE2-LABEL: length31_eq_prefer128: 1140; X86-SSE2: # %bb.0: 1141; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax 1142; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %ecx 1143; X86-SSE2-NEXT: movdqu (%ecx), %xmm0 1144; X86-SSE2-NEXT: movdqu 15(%ecx), %xmm1 1145; X86-SSE2-NEXT: movdqu (%eax), %xmm2 1146; X86-SSE2-NEXT: pcmpeqb %xmm0, %xmm2 1147; X86-SSE2-NEXT: movdqu 15(%eax), %xmm0 1148; X86-SSE2-NEXT: pcmpeqb %xmm1, %xmm0 1149; X86-SSE2-NEXT: pand %xmm2, %xmm0 1150; X86-SSE2-NEXT: pmovmskb %xmm0, %eax 1151; X86-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF 1152; X86-SSE2-NEXT: sete %al 1153; X86-SSE2-NEXT: retl 1154; 1155; X86-SSE41-LABEL: length31_eq_prefer128: 1156; X86-SSE41: # %bb.0: 1157; X86-SSE41-NEXT: movl {{[0-9]+}}(%esp), %eax 1158; X86-SSE41-NEXT: movl {{[0-9]+}}(%esp), %ecx 1159; X86-SSE41-NEXT: movdqu (%ecx), %xmm0 1160; X86-SSE41-NEXT: movdqu 15(%ecx), %xmm1 1161; X86-SSE41-NEXT: movdqu (%eax), %xmm2 1162; X86-SSE41-NEXT: pxor %xmm0, %xmm2 1163; X86-SSE41-NEXT: movdqu 15(%eax), %xmm0 1164; X86-SSE41-NEXT: pxor %xmm1, %xmm0 1165; X86-SSE41-NEXT: por %xmm2, %xmm0 1166; X86-SSE41-NEXT: ptest %xmm0, %xmm0 1167; X86-SSE41-NEXT: sete %al 1168; X86-SSE41-NEXT: retl 1169 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 31) nounwind 1170 %cmp = icmp eq i32 %call, 0 1171 ret i1 %cmp 1172} 1173 1174define i1 @length31_eq_const(ptr %X) nounwind { 1175; X86-NOSSE-LABEL: length31_eq_const: 1176; X86-NOSSE: # %bb.0: 1177; X86-NOSSE-NEXT: pushl $31 1178; X86-NOSSE-NEXT: pushl $.L.str 1179; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp) 1180; X86-NOSSE-NEXT: calll memcmp 1181; X86-NOSSE-NEXT: addl $12, %esp 1182; X86-NOSSE-NEXT: testl %eax, %eax 1183; X86-NOSSE-NEXT: setne %al 1184; X86-NOSSE-NEXT: retl 1185; 1186; X86-SSE1-LABEL: length31_eq_const: 1187; X86-SSE1: # %bb.0: 1188; X86-SSE1-NEXT: pushl $31 1189; X86-SSE1-NEXT: pushl $.L.str 1190; X86-SSE1-NEXT: pushl {{[0-9]+}}(%esp) 1191; X86-SSE1-NEXT: calll memcmp 1192; X86-SSE1-NEXT: addl $12, %esp 1193; X86-SSE1-NEXT: testl %eax, %eax 1194; X86-SSE1-NEXT: setne %al 1195; X86-SSE1-NEXT: retl 1196; 1197; X86-SSE2-LABEL: length31_eq_const: 1198; X86-SSE2: # %bb.0: 1199; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax 1200; X86-SSE2-NEXT: movdqu (%eax), %xmm0 1201; X86-SSE2-NEXT: movdqu 15(%eax), %xmm1 1202; X86-SSE2-NEXT: pcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}, %xmm1 1203; X86-SSE2-NEXT: pcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0 1204; X86-SSE2-NEXT: pand %xmm1, %xmm0 1205; X86-SSE2-NEXT: pmovmskb %xmm0, %eax 1206; X86-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF 1207; X86-SSE2-NEXT: setne %al 1208; X86-SSE2-NEXT: retl 1209; 1210; X86-SSE41-LABEL: length31_eq_const: 1211; X86-SSE41: # %bb.0: 1212; X86-SSE41-NEXT: movl {{[0-9]+}}(%esp), %eax 1213; X86-SSE41-NEXT: movdqu (%eax), %xmm0 1214; X86-SSE41-NEXT: movdqu 15(%eax), %xmm1 1215; X86-SSE41-NEXT: pxor {{\.?LCPI[0-9]+_[0-9]+}}, %xmm1 1216; X86-SSE41-NEXT: pxor {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0 1217; X86-SSE41-NEXT: por %xmm1, %xmm0 1218; X86-SSE41-NEXT: ptest %xmm0, %xmm0 1219; X86-SSE41-NEXT: setne %al 1220; X86-SSE41-NEXT: retl 1221 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i32 31) nounwind 1222 %c = icmp ne i32 %m, 0 1223 ret i1 %c 1224} 1225 1226define i32 @length32(ptr %X, ptr %Y) nounwind { 1227; X86-LABEL: length32: 1228; X86: # %bb.0: 1229; X86-NEXT: pushl $32 1230; X86-NEXT: pushl {{[0-9]+}}(%esp) 1231; X86-NEXT: pushl {{[0-9]+}}(%esp) 1232; X86-NEXT: calll memcmp 1233; X86-NEXT: addl $12, %esp 1234; X86-NEXT: retl 1235 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 32) nounwind 1236 ret i32 %m 1237} 1238 1239; PR33325 - https://bugs.llvm.org/show_bug.cgi?id=33325 1240 1241define i1 @length32_eq(ptr %x, ptr %y) nounwind { 1242; X86-NOSSE-LABEL: length32_eq: 1243; X86-NOSSE: # %bb.0: 1244; X86-NOSSE-NEXT: pushl $32 1245; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp) 1246; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp) 1247; X86-NOSSE-NEXT: calll memcmp 1248; X86-NOSSE-NEXT: addl $12, %esp 1249; X86-NOSSE-NEXT: testl %eax, %eax 1250; X86-NOSSE-NEXT: sete %al 1251; X86-NOSSE-NEXT: retl 1252; 1253; X86-SSE1-LABEL: length32_eq: 1254; X86-SSE1: # %bb.0: 1255; X86-SSE1-NEXT: pushl $32 1256; X86-SSE1-NEXT: pushl {{[0-9]+}}(%esp) 1257; X86-SSE1-NEXT: pushl {{[0-9]+}}(%esp) 1258; X86-SSE1-NEXT: calll memcmp 1259; X86-SSE1-NEXT: addl $12, %esp 1260; X86-SSE1-NEXT: testl %eax, %eax 1261; X86-SSE1-NEXT: sete %al 1262; X86-SSE1-NEXT: retl 1263; 1264; X86-SSE2-LABEL: length32_eq: 1265; X86-SSE2: # %bb.0: 1266; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax 1267; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %ecx 1268; X86-SSE2-NEXT: movdqu (%ecx), %xmm0 1269; X86-SSE2-NEXT: movdqu 16(%ecx), %xmm1 1270; X86-SSE2-NEXT: movdqu (%eax), %xmm2 1271; X86-SSE2-NEXT: pcmpeqb %xmm0, %xmm2 1272; X86-SSE2-NEXT: movdqu 16(%eax), %xmm0 1273; X86-SSE2-NEXT: pcmpeqb %xmm1, %xmm0 1274; X86-SSE2-NEXT: pand %xmm2, %xmm0 1275; X86-SSE2-NEXT: pmovmskb %xmm0, %eax 1276; X86-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF 1277; X86-SSE2-NEXT: sete %al 1278; X86-SSE2-NEXT: retl 1279; 1280; X86-SSE41-LABEL: length32_eq: 1281; X86-SSE41: # %bb.0: 1282; X86-SSE41-NEXT: movl {{[0-9]+}}(%esp), %eax 1283; X86-SSE41-NEXT: movl {{[0-9]+}}(%esp), %ecx 1284; X86-SSE41-NEXT: movdqu (%ecx), %xmm0 1285; X86-SSE41-NEXT: movdqu 16(%ecx), %xmm1 1286; X86-SSE41-NEXT: movdqu (%eax), %xmm2 1287; X86-SSE41-NEXT: pxor %xmm0, %xmm2 1288; X86-SSE41-NEXT: movdqu 16(%eax), %xmm0 1289; X86-SSE41-NEXT: pxor %xmm1, %xmm0 1290; X86-SSE41-NEXT: por %xmm2, %xmm0 1291; X86-SSE41-NEXT: ptest %xmm0, %xmm0 1292; X86-SSE41-NEXT: sete %al 1293; X86-SSE41-NEXT: retl 1294 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 32) nounwind 1295 %cmp = icmp eq i32 %call, 0 1296 ret i1 %cmp 1297} 1298 1299define i1 @length32_lt(ptr %x, ptr %y) nounwind { 1300; X86-LABEL: length32_lt: 1301; X86: # %bb.0: 1302; X86-NEXT: pushl $32 1303; X86-NEXT: pushl {{[0-9]+}}(%esp) 1304; X86-NEXT: pushl {{[0-9]+}}(%esp) 1305; X86-NEXT: calll memcmp 1306; X86-NEXT: addl $12, %esp 1307; X86-NEXT: shrl $31, %eax 1308; X86-NEXT: # kill: def $al killed $al killed $eax 1309; X86-NEXT: retl 1310 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 32) nounwind 1311 %cmp = icmp slt i32 %call, 0 1312 ret i1 %cmp 1313} 1314 1315define i1 @length32_gt(ptr %x, ptr %y) nounwind { 1316; X86-LABEL: length32_gt: 1317; X86: # %bb.0: 1318; X86-NEXT: pushl $32 1319; X86-NEXT: pushl {{[0-9]+}}(%esp) 1320; X86-NEXT: pushl {{[0-9]+}}(%esp) 1321; X86-NEXT: calll memcmp 1322; X86-NEXT: addl $12, %esp 1323; X86-NEXT: testl %eax, %eax 1324; X86-NEXT: setg %al 1325; X86-NEXT: retl 1326 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 32) nounwind 1327 %cmp = icmp sgt i32 %call, 0 1328 ret i1 %cmp 1329} 1330 1331define i1 @length32_eq_prefer128(ptr %x, ptr %y) nounwind "prefer-vector-width"="128" { 1332; X86-NOSSE-LABEL: length32_eq_prefer128: 1333; X86-NOSSE: # %bb.0: 1334; X86-NOSSE-NEXT: pushl $32 1335; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp) 1336; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp) 1337; X86-NOSSE-NEXT: calll memcmp 1338; X86-NOSSE-NEXT: addl $12, %esp 1339; X86-NOSSE-NEXT: testl %eax, %eax 1340; X86-NOSSE-NEXT: sete %al 1341; X86-NOSSE-NEXT: retl 1342; 1343; X86-SSE1-LABEL: length32_eq_prefer128: 1344; X86-SSE1: # %bb.0: 1345; X86-SSE1-NEXT: pushl $32 1346; X86-SSE1-NEXT: pushl {{[0-9]+}}(%esp) 1347; X86-SSE1-NEXT: pushl {{[0-9]+}}(%esp) 1348; X86-SSE1-NEXT: calll memcmp 1349; X86-SSE1-NEXT: addl $12, %esp 1350; X86-SSE1-NEXT: testl %eax, %eax 1351; X86-SSE1-NEXT: sete %al 1352; X86-SSE1-NEXT: retl 1353; 1354; X86-SSE2-LABEL: length32_eq_prefer128: 1355; X86-SSE2: # %bb.0: 1356; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax 1357; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %ecx 1358; X86-SSE2-NEXT: movdqu (%ecx), %xmm0 1359; X86-SSE2-NEXT: movdqu 16(%ecx), %xmm1 1360; X86-SSE2-NEXT: movdqu (%eax), %xmm2 1361; X86-SSE2-NEXT: pcmpeqb %xmm0, %xmm2 1362; X86-SSE2-NEXT: movdqu 16(%eax), %xmm0 1363; X86-SSE2-NEXT: pcmpeqb %xmm1, %xmm0 1364; X86-SSE2-NEXT: pand %xmm2, %xmm0 1365; X86-SSE2-NEXT: pmovmskb %xmm0, %eax 1366; X86-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF 1367; X86-SSE2-NEXT: sete %al 1368; X86-SSE2-NEXT: retl 1369; 1370; X86-SSE41-LABEL: length32_eq_prefer128: 1371; X86-SSE41: # %bb.0: 1372; X86-SSE41-NEXT: movl {{[0-9]+}}(%esp), %eax 1373; X86-SSE41-NEXT: movl {{[0-9]+}}(%esp), %ecx 1374; X86-SSE41-NEXT: movdqu (%ecx), %xmm0 1375; X86-SSE41-NEXT: movdqu 16(%ecx), %xmm1 1376; X86-SSE41-NEXT: movdqu (%eax), %xmm2 1377; X86-SSE41-NEXT: pxor %xmm0, %xmm2 1378; X86-SSE41-NEXT: movdqu 16(%eax), %xmm0 1379; X86-SSE41-NEXT: pxor %xmm1, %xmm0 1380; X86-SSE41-NEXT: por %xmm2, %xmm0 1381; X86-SSE41-NEXT: ptest %xmm0, %xmm0 1382; X86-SSE41-NEXT: sete %al 1383; X86-SSE41-NEXT: retl 1384 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 32) nounwind 1385 %cmp = icmp eq i32 %call, 0 1386 ret i1 %cmp 1387} 1388 1389define i1 @length32_eq_const(ptr %X) nounwind { 1390; X86-NOSSE-LABEL: length32_eq_const: 1391; X86-NOSSE: # %bb.0: 1392; X86-NOSSE-NEXT: pushl $32 1393; X86-NOSSE-NEXT: pushl $.L.str 1394; X86-NOSSE-NEXT: pushl {{[0-9]+}}(%esp) 1395; X86-NOSSE-NEXT: calll memcmp 1396; X86-NOSSE-NEXT: addl $12, %esp 1397; X86-NOSSE-NEXT: testl %eax, %eax 1398; X86-NOSSE-NEXT: setne %al 1399; X86-NOSSE-NEXT: retl 1400; 1401; X86-SSE1-LABEL: length32_eq_const: 1402; X86-SSE1: # %bb.0: 1403; X86-SSE1-NEXT: pushl $32 1404; X86-SSE1-NEXT: pushl $.L.str 1405; X86-SSE1-NEXT: pushl {{[0-9]+}}(%esp) 1406; X86-SSE1-NEXT: calll memcmp 1407; X86-SSE1-NEXT: addl $12, %esp 1408; X86-SSE1-NEXT: testl %eax, %eax 1409; X86-SSE1-NEXT: setne %al 1410; X86-SSE1-NEXT: retl 1411; 1412; X86-SSE2-LABEL: length32_eq_const: 1413; X86-SSE2: # %bb.0: 1414; X86-SSE2-NEXT: movl {{[0-9]+}}(%esp), %eax 1415; X86-SSE2-NEXT: movdqu (%eax), %xmm0 1416; X86-SSE2-NEXT: movdqu 16(%eax), %xmm1 1417; X86-SSE2-NEXT: pcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}, %xmm1 1418; X86-SSE2-NEXT: pcmpeqb {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0 1419; X86-SSE2-NEXT: pand %xmm1, %xmm0 1420; X86-SSE2-NEXT: pmovmskb %xmm0, %eax 1421; X86-SSE2-NEXT: cmpl $65535, %eax # imm = 0xFFFF 1422; X86-SSE2-NEXT: setne %al 1423; X86-SSE2-NEXT: retl 1424; 1425; X86-SSE41-LABEL: length32_eq_const: 1426; X86-SSE41: # %bb.0: 1427; X86-SSE41-NEXT: movl {{[0-9]+}}(%esp), %eax 1428; X86-SSE41-NEXT: movdqu (%eax), %xmm0 1429; X86-SSE41-NEXT: movdqu 16(%eax), %xmm1 1430; X86-SSE41-NEXT: pxor {{\.?LCPI[0-9]+_[0-9]+}}, %xmm1 1431; X86-SSE41-NEXT: pxor {{\.?LCPI[0-9]+_[0-9]+}}, %xmm0 1432; X86-SSE41-NEXT: por %xmm1, %xmm0 1433; X86-SSE41-NEXT: ptest %xmm0, %xmm0 1434; X86-SSE41-NEXT: setne %al 1435; X86-SSE41-NEXT: retl 1436 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i32 32) nounwind 1437 %c = icmp ne i32 %m, 0 1438 ret i1 %c 1439} 1440 1441define i32 @length48(ptr %X, ptr %Y) nounwind { 1442; X86-LABEL: length48: 1443; X86: # %bb.0: 1444; X86-NEXT: pushl $48 1445; X86-NEXT: pushl {{[0-9]+}}(%esp) 1446; X86-NEXT: pushl {{[0-9]+}}(%esp) 1447; X86-NEXT: calll memcmp 1448; X86-NEXT: addl $12, %esp 1449; X86-NEXT: retl 1450 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 48) nounwind 1451 ret i32 %m 1452} 1453 1454define i1 @length48_eq(ptr %x, ptr %y) nounwind { 1455; X86-LABEL: length48_eq: 1456; X86: # %bb.0: 1457; X86-NEXT: pushl $48 1458; X86-NEXT: pushl {{[0-9]+}}(%esp) 1459; X86-NEXT: pushl {{[0-9]+}}(%esp) 1460; X86-NEXT: calll memcmp 1461; X86-NEXT: addl $12, %esp 1462; X86-NEXT: testl %eax, %eax 1463; X86-NEXT: sete %al 1464; X86-NEXT: retl 1465 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 48) nounwind 1466 %cmp = icmp eq i32 %call, 0 1467 ret i1 %cmp 1468} 1469 1470define i1 @length48_lt(ptr %x, ptr %y) nounwind { 1471; X86-LABEL: length48_lt: 1472; X86: # %bb.0: 1473; X86-NEXT: pushl $48 1474; X86-NEXT: pushl {{[0-9]+}}(%esp) 1475; X86-NEXT: pushl {{[0-9]+}}(%esp) 1476; X86-NEXT: calll memcmp 1477; X86-NEXT: addl $12, %esp 1478; X86-NEXT: shrl $31, %eax 1479; X86-NEXT: # kill: def $al killed $al killed $eax 1480; X86-NEXT: retl 1481 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 48) nounwind 1482 %cmp = icmp slt i32 %call, 0 1483 ret i1 %cmp 1484} 1485 1486define i1 @length48_gt(ptr %x, ptr %y) nounwind { 1487; X86-LABEL: length48_gt: 1488; X86: # %bb.0: 1489; X86-NEXT: pushl $48 1490; X86-NEXT: pushl {{[0-9]+}}(%esp) 1491; X86-NEXT: pushl {{[0-9]+}}(%esp) 1492; X86-NEXT: calll memcmp 1493; X86-NEXT: addl $12, %esp 1494; X86-NEXT: testl %eax, %eax 1495; X86-NEXT: setg %al 1496; X86-NEXT: retl 1497 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 48) nounwind 1498 %cmp = icmp sgt i32 %call, 0 1499 ret i1 %cmp 1500} 1501 1502define i1 @length48_eq_prefer128(ptr %x, ptr %y) nounwind "prefer-vector-width"="128" { 1503; X86-LABEL: length48_eq_prefer128: 1504; X86: # %bb.0: 1505; X86-NEXT: pushl $48 1506; X86-NEXT: pushl {{[0-9]+}}(%esp) 1507; X86-NEXT: pushl {{[0-9]+}}(%esp) 1508; X86-NEXT: calll memcmp 1509; X86-NEXT: addl $12, %esp 1510; X86-NEXT: testl %eax, %eax 1511; X86-NEXT: sete %al 1512; X86-NEXT: retl 1513 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 48) nounwind 1514 %cmp = icmp eq i32 %call, 0 1515 ret i1 %cmp 1516} 1517 1518define i1 @length48_eq_const(ptr %X) nounwind { 1519; X86-LABEL: length48_eq_const: 1520; X86: # %bb.0: 1521; X86-NEXT: pushl $48 1522; X86-NEXT: pushl $.L.str 1523; X86-NEXT: pushl {{[0-9]+}}(%esp) 1524; X86-NEXT: calll memcmp 1525; X86-NEXT: addl $12, %esp 1526; X86-NEXT: testl %eax, %eax 1527; X86-NEXT: setne %al 1528; X86-NEXT: retl 1529 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i32 48) nounwind 1530 %c = icmp ne i32 %m, 0 1531 ret i1 %c 1532} 1533 1534define i32 @length63(ptr %X, ptr %Y) nounwind { 1535; X86-LABEL: length63: 1536; X86: # %bb.0: 1537; X86-NEXT: pushl $63 1538; X86-NEXT: pushl {{[0-9]+}}(%esp) 1539; X86-NEXT: pushl {{[0-9]+}}(%esp) 1540; X86-NEXT: calll memcmp 1541; X86-NEXT: addl $12, %esp 1542; X86-NEXT: retl 1543 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 63) nounwind 1544 ret i32 %m 1545} 1546 1547define i1 @length63_eq(ptr %x, ptr %y) nounwind { 1548; X86-LABEL: length63_eq: 1549; X86: # %bb.0: 1550; X86-NEXT: pushl $63 1551; X86-NEXT: pushl {{[0-9]+}}(%esp) 1552; X86-NEXT: pushl {{[0-9]+}}(%esp) 1553; X86-NEXT: calll memcmp 1554; X86-NEXT: addl $12, %esp 1555; X86-NEXT: testl %eax, %eax 1556; X86-NEXT: setne %al 1557; X86-NEXT: retl 1558 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 63) nounwind 1559 %cmp = icmp ne i32 %call, 0 1560 ret i1 %cmp 1561} 1562 1563define i1 @length63_lt(ptr %x, ptr %y) nounwind { 1564; X86-LABEL: length63_lt: 1565; X86: # %bb.0: 1566; X86-NEXT: pushl $63 1567; X86-NEXT: pushl {{[0-9]+}}(%esp) 1568; X86-NEXT: pushl {{[0-9]+}}(%esp) 1569; X86-NEXT: calll memcmp 1570; X86-NEXT: addl $12, %esp 1571; X86-NEXT: shrl $31, %eax 1572; X86-NEXT: # kill: def $al killed $al killed $eax 1573; X86-NEXT: retl 1574 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 63) nounwind 1575 %cmp = icmp slt i32 %call, 0 1576 ret i1 %cmp 1577} 1578 1579define i1 @length63_gt(ptr %x, ptr %y) nounwind { 1580; X86-LABEL: length63_gt: 1581; X86: # %bb.0: 1582; X86-NEXT: pushl $63 1583; X86-NEXT: pushl {{[0-9]+}}(%esp) 1584; X86-NEXT: pushl {{[0-9]+}}(%esp) 1585; X86-NEXT: calll memcmp 1586; X86-NEXT: addl $12, %esp 1587; X86-NEXT: testl %eax, %eax 1588; X86-NEXT: setg %al 1589; X86-NEXT: retl 1590 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 63) nounwind 1591 %cmp = icmp sgt i32 %call, 0 1592 ret i1 %cmp 1593} 1594 1595define i1 @length63_eq_const(ptr %X) nounwind { 1596; X86-LABEL: length63_eq_const: 1597; X86: # %bb.0: 1598; X86-NEXT: pushl $63 1599; X86-NEXT: pushl $.L.str 1600; X86-NEXT: pushl {{[0-9]+}}(%esp) 1601; X86-NEXT: calll memcmp 1602; X86-NEXT: addl $12, %esp 1603; X86-NEXT: testl %eax, %eax 1604; X86-NEXT: sete %al 1605; X86-NEXT: retl 1606 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i32 63) nounwind 1607 %c = icmp eq i32 %m, 0 1608 ret i1 %c 1609} 1610 1611define i32 @length64(ptr %X, ptr %Y) nounwind { 1612; X86-LABEL: length64: 1613; X86: # %bb.0: 1614; X86-NEXT: pushl $64 1615; X86-NEXT: pushl {{[0-9]+}}(%esp) 1616; X86-NEXT: pushl {{[0-9]+}}(%esp) 1617; X86-NEXT: calll memcmp 1618; X86-NEXT: addl $12, %esp 1619; X86-NEXT: retl 1620 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 64) nounwind 1621 ret i32 %m 1622} 1623 1624define i1 @length64_eq(ptr %x, ptr %y) nounwind { 1625; X86-LABEL: length64_eq: 1626; X86: # %bb.0: 1627; X86-NEXT: pushl $64 1628; X86-NEXT: pushl {{[0-9]+}}(%esp) 1629; X86-NEXT: pushl {{[0-9]+}}(%esp) 1630; X86-NEXT: calll memcmp 1631; X86-NEXT: addl $12, %esp 1632; X86-NEXT: testl %eax, %eax 1633; X86-NEXT: setne %al 1634; X86-NEXT: retl 1635 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 64) nounwind 1636 %cmp = icmp ne i32 %call, 0 1637 ret i1 %cmp 1638} 1639 1640define i1 @length64_lt(ptr %x, ptr %y) nounwind { 1641; X86-LABEL: length64_lt: 1642; X86: # %bb.0: 1643; X86-NEXT: pushl $64 1644; X86-NEXT: pushl {{[0-9]+}}(%esp) 1645; X86-NEXT: pushl {{[0-9]+}}(%esp) 1646; X86-NEXT: calll memcmp 1647; X86-NEXT: addl $12, %esp 1648; X86-NEXT: shrl $31, %eax 1649; X86-NEXT: # kill: def $al killed $al killed $eax 1650; X86-NEXT: retl 1651 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 64) nounwind 1652 %cmp = icmp slt i32 %call, 0 1653 ret i1 %cmp 1654} 1655 1656define i1 @length64_gt(ptr %x, ptr %y) nounwind { 1657; X86-LABEL: length64_gt: 1658; X86: # %bb.0: 1659; X86-NEXT: pushl $64 1660; X86-NEXT: pushl {{[0-9]+}}(%esp) 1661; X86-NEXT: pushl {{[0-9]+}}(%esp) 1662; X86-NEXT: calll memcmp 1663; X86-NEXT: addl $12, %esp 1664; X86-NEXT: testl %eax, %eax 1665; X86-NEXT: setg %al 1666; X86-NEXT: retl 1667 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 64) nounwind 1668 %cmp = icmp sgt i32 %call, 0 1669 ret i1 %cmp 1670} 1671 1672define i1 @length64_eq_const(ptr %X) nounwind { 1673; X86-LABEL: length64_eq_const: 1674; X86: # %bb.0: 1675; X86-NEXT: pushl $64 1676; X86-NEXT: pushl $.L.str 1677; X86-NEXT: pushl {{[0-9]+}}(%esp) 1678; X86-NEXT: calll memcmp 1679; X86-NEXT: addl $12, %esp 1680; X86-NEXT: testl %eax, %eax 1681; X86-NEXT: sete %al 1682; X86-NEXT: retl 1683 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i32 64) nounwind 1684 %c = icmp eq i32 %m, 0 1685 ret i1 %c 1686} 1687 1688define i32 @length96(ptr %X, ptr %Y) nounwind { 1689; X86-LABEL: length96: 1690; X86: # %bb.0: 1691; X86-NEXT: pushl $96 1692; X86-NEXT: pushl {{[0-9]+}}(%esp) 1693; X86-NEXT: pushl {{[0-9]+}}(%esp) 1694; X86-NEXT: calll memcmp 1695; X86-NEXT: addl $12, %esp 1696; X86-NEXT: retl 1697 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 96) nounwind 1698 ret i32 %m 1699} 1700 1701define i1 @length96_eq(ptr %x, ptr %y) nounwind { 1702; X86-LABEL: length96_eq: 1703; X86: # %bb.0: 1704; X86-NEXT: pushl $96 1705; X86-NEXT: pushl {{[0-9]+}}(%esp) 1706; X86-NEXT: pushl {{[0-9]+}}(%esp) 1707; X86-NEXT: calll memcmp 1708; X86-NEXT: addl $12, %esp 1709; X86-NEXT: testl %eax, %eax 1710; X86-NEXT: setne %al 1711; X86-NEXT: retl 1712 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 96) nounwind 1713 %cmp = icmp ne i32 %call, 0 1714 ret i1 %cmp 1715} 1716 1717define i1 @length96_lt(ptr %x, ptr %y) nounwind { 1718; X86-LABEL: length96_lt: 1719; X86: # %bb.0: 1720; X86-NEXT: pushl $96 1721; X86-NEXT: pushl {{[0-9]+}}(%esp) 1722; X86-NEXT: pushl {{[0-9]+}}(%esp) 1723; X86-NEXT: calll memcmp 1724; X86-NEXT: addl $12, %esp 1725; X86-NEXT: shrl $31, %eax 1726; X86-NEXT: # kill: def $al killed $al killed $eax 1727; X86-NEXT: retl 1728 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 96) nounwind 1729 %cmp = icmp slt i32 %call, 0 1730 ret i1 %cmp 1731} 1732 1733define i1 @length96_gt(ptr %x, ptr %y) nounwind { 1734; X86-LABEL: length96_gt: 1735; X86: # %bb.0: 1736; X86-NEXT: pushl $96 1737; X86-NEXT: pushl {{[0-9]+}}(%esp) 1738; X86-NEXT: pushl {{[0-9]+}}(%esp) 1739; X86-NEXT: calll memcmp 1740; X86-NEXT: addl $12, %esp 1741; X86-NEXT: testl %eax, %eax 1742; X86-NEXT: setg %al 1743; X86-NEXT: retl 1744 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 96) nounwind 1745 %cmp = icmp sgt i32 %call, 0 1746 ret i1 %cmp 1747} 1748 1749define i1 @length96_eq_const(ptr %X) nounwind { 1750; X86-LABEL: length96_eq_const: 1751; X86: # %bb.0: 1752; X86-NEXT: pushl $96 1753; X86-NEXT: pushl $.L.str 1754; X86-NEXT: pushl {{[0-9]+}}(%esp) 1755; X86-NEXT: calll memcmp 1756; X86-NEXT: addl $12, %esp 1757; X86-NEXT: testl %eax, %eax 1758; X86-NEXT: sete %al 1759; X86-NEXT: retl 1760 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i32 96) nounwind 1761 %c = icmp eq i32 %m, 0 1762 ret i1 %c 1763} 1764 1765define i32 @length127(ptr %X, ptr %Y) nounwind { 1766; X86-LABEL: length127: 1767; X86: # %bb.0: 1768; X86-NEXT: pushl $127 1769; X86-NEXT: pushl {{[0-9]+}}(%esp) 1770; X86-NEXT: pushl {{[0-9]+}}(%esp) 1771; X86-NEXT: calll memcmp 1772; X86-NEXT: addl $12, %esp 1773; X86-NEXT: retl 1774 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 127) nounwind 1775 ret i32 %m 1776} 1777 1778define i1 @length127_eq(ptr %x, ptr %y) nounwind { 1779; X86-LABEL: length127_eq: 1780; X86: # %bb.0: 1781; X86-NEXT: pushl $127 1782; X86-NEXT: pushl {{[0-9]+}}(%esp) 1783; X86-NEXT: pushl {{[0-9]+}}(%esp) 1784; X86-NEXT: calll memcmp 1785; X86-NEXT: addl $12, %esp 1786; X86-NEXT: testl %eax, %eax 1787; X86-NEXT: setne %al 1788; X86-NEXT: retl 1789 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 127) nounwind 1790 %cmp = icmp ne i32 %call, 0 1791 ret i1 %cmp 1792} 1793 1794define i1 @length127_lt(ptr %x, ptr %y) nounwind { 1795; X86-LABEL: length127_lt: 1796; X86: # %bb.0: 1797; X86-NEXT: pushl $127 1798; X86-NEXT: pushl {{[0-9]+}}(%esp) 1799; X86-NEXT: pushl {{[0-9]+}}(%esp) 1800; X86-NEXT: calll memcmp 1801; X86-NEXT: addl $12, %esp 1802; X86-NEXT: shrl $31, %eax 1803; X86-NEXT: # kill: def $al killed $al killed $eax 1804; X86-NEXT: retl 1805 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 127) nounwind 1806 %cmp = icmp slt i32 %call, 0 1807 ret i1 %cmp 1808} 1809 1810define i1 @length127_gt(ptr %x, ptr %y) nounwind { 1811; X86-LABEL: length127_gt: 1812; X86: # %bb.0: 1813; X86-NEXT: pushl $127 1814; X86-NEXT: pushl {{[0-9]+}}(%esp) 1815; X86-NEXT: pushl {{[0-9]+}}(%esp) 1816; X86-NEXT: calll memcmp 1817; X86-NEXT: addl $12, %esp 1818; X86-NEXT: testl %eax, %eax 1819; X86-NEXT: setg %al 1820; X86-NEXT: retl 1821 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 127) nounwind 1822 %cmp = icmp sgt i32 %call, 0 1823 ret i1 %cmp 1824} 1825 1826define i1 @length127_eq_const(ptr %X) nounwind { 1827; X86-LABEL: length127_eq_const: 1828; X86: # %bb.0: 1829; X86-NEXT: pushl $127 1830; X86-NEXT: pushl $.L.str 1831; X86-NEXT: pushl {{[0-9]+}}(%esp) 1832; X86-NEXT: calll memcmp 1833; X86-NEXT: addl $12, %esp 1834; X86-NEXT: testl %eax, %eax 1835; X86-NEXT: sete %al 1836; X86-NEXT: retl 1837 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i32 127) nounwind 1838 %c = icmp eq i32 %m, 0 1839 ret i1 %c 1840} 1841 1842define i32 @length128(ptr %X, ptr %Y) nounwind { 1843; X86-LABEL: length128: 1844; X86: # %bb.0: 1845; X86-NEXT: pushl $128 1846; X86-NEXT: pushl {{[0-9]+}}(%esp) 1847; X86-NEXT: pushl {{[0-9]+}}(%esp) 1848; X86-NEXT: calll memcmp 1849; X86-NEXT: addl $12, %esp 1850; X86-NEXT: retl 1851 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 128) nounwind 1852 ret i32 %m 1853} 1854 1855define i1 @length128_eq(ptr %x, ptr %y) nounwind { 1856; X86-LABEL: length128_eq: 1857; X86: # %bb.0: 1858; X86-NEXT: pushl $128 1859; X86-NEXT: pushl {{[0-9]+}}(%esp) 1860; X86-NEXT: pushl {{[0-9]+}}(%esp) 1861; X86-NEXT: calll memcmp 1862; X86-NEXT: addl $12, %esp 1863; X86-NEXT: testl %eax, %eax 1864; X86-NEXT: setne %al 1865; X86-NEXT: retl 1866 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 128) nounwind 1867 %cmp = icmp ne i32 %call, 0 1868 ret i1 %cmp 1869} 1870 1871define i1 @length128_lt(ptr %x, ptr %y) nounwind { 1872; X86-LABEL: length128_lt: 1873; X86: # %bb.0: 1874; X86-NEXT: pushl $128 1875; X86-NEXT: pushl {{[0-9]+}}(%esp) 1876; X86-NEXT: pushl {{[0-9]+}}(%esp) 1877; X86-NEXT: calll memcmp 1878; X86-NEXT: addl $12, %esp 1879; X86-NEXT: shrl $31, %eax 1880; X86-NEXT: # kill: def $al killed $al killed $eax 1881; X86-NEXT: retl 1882 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 128) nounwind 1883 %cmp = icmp slt i32 %call, 0 1884 ret i1 %cmp 1885} 1886 1887define i1 @length128_gt(ptr %x, ptr %y) nounwind { 1888; X86-LABEL: length128_gt: 1889; X86: # %bb.0: 1890; X86-NEXT: pushl $128 1891; X86-NEXT: pushl {{[0-9]+}}(%esp) 1892; X86-NEXT: pushl {{[0-9]+}}(%esp) 1893; X86-NEXT: calll memcmp 1894; X86-NEXT: addl $12, %esp 1895; X86-NEXT: testl %eax, %eax 1896; X86-NEXT: setg %al 1897; X86-NEXT: retl 1898 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 128) nounwind 1899 %cmp = icmp sgt i32 %call, 0 1900 ret i1 %cmp 1901} 1902 1903define i1 @length128_eq_const(ptr %X) nounwind { 1904; X86-LABEL: length128_eq_const: 1905; X86: # %bb.0: 1906; X86-NEXT: pushl $128 1907; X86-NEXT: pushl $.L.str 1908; X86-NEXT: pushl {{[0-9]+}}(%esp) 1909; X86-NEXT: calll memcmp 1910; X86-NEXT: addl $12, %esp 1911; X86-NEXT: testl %eax, %eax 1912; X86-NEXT: sete %al 1913; X86-NEXT: retl 1914 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i32 128) nounwind 1915 %c = icmp eq i32 %m, 0 1916 ret i1 %c 1917} 1918 1919define i32 @length192(ptr %X, ptr %Y) nounwind { 1920; X86-LABEL: length192: 1921; X86: # %bb.0: 1922; X86-NEXT: pushl $192 1923; X86-NEXT: pushl {{[0-9]+}}(%esp) 1924; X86-NEXT: pushl {{[0-9]+}}(%esp) 1925; X86-NEXT: calll memcmp 1926; X86-NEXT: addl $12, %esp 1927; X86-NEXT: retl 1928 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 192) nounwind 1929 ret i32 %m 1930} 1931 1932define i1 @length192_eq(ptr %x, ptr %y) nounwind { 1933; X86-LABEL: length192_eq: 1934; X86: # %bb.0: 1935; X86-NEXT: pushl $192 1936; X86-NEXT: pushl {{[0-9]+}}(%esp) 1937; X86-NEXT: pushl {{[0-9]+}}(%esp) 1938; X86-NEXT: calll memcmp 1939; X86-NEXT: addl $12, %esp 1940; X86-NEXT: testl %eax, %eax 1941; X86-NEXT: setne %al 1942; X86-NEXT: retl 1943 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 192) nounwind 1944 %cmp = icmp ne i32 %call, 0 1945 ret i1 %cmp 1946} 1947 1948define i1 @length192_lt(ptr %x, ptr %y) nounwind { 1949; X86-LABEL: length192_lt: 1950; X86: # %bb.0: 1951; X86-NEXT: pushl $192 1952; X86-NEXT: pushl {{[0-9]+}}(%esp) 1953; X86-NEXT: pushl {{[0-9]+}}(%esp) 1954; X86-NEXT: calll memcmp 1955; X86-NEXT: addl $12, %esp 1956; X86-NEXT: shrl $31, %eax 1957; X86-NEXT: # kill: def $al killed $al killed $eax 1958; X86-NEXT: retl 1959 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 192) nounwind 1960 %cmp = icmp slt i32 %call, 0 1961 ret i1 %cmp 1962} 1963 1964define i1 @length192_gt(ptr %x, ptr %y) nounwind { 1965; X86-LABEL: length192_gt: 1966; X86: # %bb.0: 1967; X86-NEXT: pushl $192 1968; X86-NEXT: pushl {{[0-9]+}}(%esp) 1969; X86-NEXT: pushl {{[0-9]+}}(%esp) 1970; X86-NEXT: calll memcmp 1971; X86-NEXT: addl $12, %esp 1972; X86-NEXT: testl %eax, %eax 1973; X86-NEXT: setg %al 1974; X86-NEXT: retl 1975 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 192) nounwind 1976 %cmp = icmp sgt i32 %call, 0 1977 ret i1 %cmp 1978} 1979 1980define i1 @length192_eq_const(ptr %X) nounwind { 1981; X86-LABEL: length192_eq_const: 1982; X86: # %bb.0: 1983; X86-NEXT: pushl $192 1984; X86-NEXT: pushl $.L.str 1985; X86-NEXT: pushl {{[0-9]+}}(%esp) 1986; X86-NEXT: calll memcmp 1987; X86-NEXT: addl $12, %esp 1988; X86-NEXT: testl %eax, %eax 1989; X86-NEXT: sete %al 1990; X86-NEXT: retl 1991 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i32 192) nounwind 1992 %c = icmp eq i32 %m, 0 1993 ret i1 %c 1994} 1995 1996define i32 @length255(ptr %X, ptr %Y) nounwind { 1997; X86-LABEL: length255: 1998; X86: # %bb.0: 1999; X86-NEXT: pushl $255 2000; X86-NEXT: pushl {{[0-9]+}}(%esp) 2001; X86-NEXT: pushl {{[0-9]+}}(%esp) 2002; X86-NEXT: calll memcmp 2003; X86-NEXT: addl $12, %esp 2004; X86-NEXT: retl 2005 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 255) nounwind 2006 ret i32 %m 2007} 2008 2009define i1 @length255_eq(ptr %x, ptr %y) nounwind { 2010; X86-LABEL: length255_eq: 2011; X86: # %bb.0: 2012; X86-NEXT: pushl $255 2013; X86-NEXT: pushl {{[0-9]+}}(%esp) 2014; X86-NEXT: pushl {{[0-9]+}}(%esp) 2015; X86-NEXT: calll memcmp 2016; X86-NEXT: addl $12, %esp 2017; X86-NEXT: testl %eax, %eax 2018; X86-NEXT: setne %al 2019; X86-NEXT: retl 2020 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 255) nounwind 2021 %cmp = icmp ne i32 %call, 0 2022 ret i1 %cmp 2023} 2024 2025define i1 @length255_lt(ptr %x, ptr %y) nounwind { 2026; X86-LABEL: length255_lt: 2027; X86: # %bb.0: 2028; X86-NEXT: pushl $255 2029; X86-NEXT: pushl {{[0-9]+}}(%esp) 2030; X86-NEXT: pushl {{[0-9]+}}(%esp) 2031; X86-NEXT: calll memcmp 2032; X86-NEXT: addl $12, %esp 2033; X86-NEXT: shrl $31, %eax 2034; X86-NEXT: # kill: def $al killed $al killed $eax 2035; X86-NEXT: retl 2036 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 255) nounwind 2037 %cmp = icmp slt i32 %call, 0 2038 ret i1 %cmp 2039} 2040 2041define i1 @length255_gt(ptr %x, ptr %y) nounwind { 2042; X86-LABEL: length255_gt: 2043; X86: # %bb.0: 2044; X86-NEXT: pushl $255 2045; X86-NEXT: pushl {{[0-9]+}}(%esp) 2046; X86-NEXT: pushl {{[0-9]+}}(%esp) 2047; X86-NEXT: calll memcmp 2048; X86-NEXT: addl $12, %esp 2049; X86-NEXT: testl %eax, %eax 2050; X86-NEXT: setg %al 2051; X86-NEXT: retl 2052 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 255) nounwind 2053 %cmp = icmp sgt i32 %call, 0 2054 ret i1 %cmp 2055} 2056 2057define i1 @length255_eq_const(ptr %X) nounwind { 2058; X86-LABEL: length255_eq_const: 2059; X86: # %bb.0: 2060; X86-NEXT: pushl $255 2061; X86-NEXT: pushl $.L.str 2062; X86-NEXT: pushl {{[0-9]+}}(%esp) 2063; X86-NEXT: calll memcmp 2064; X86-NEXT: addl $12, %esp 2065; X86-NEXT: testl %eax, %eax 2066; X86-NEXT: sete %al 2067; X86-NEXT: retl 2068 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i32 255) nounwind 2069 %c = icmp eq i32 %m, 0 2070 ret i1 %c 2071} 2072 2073define i32 @length256(ptr %X, ptr %Y) nounwind { 2074; X86-LABEL: length256: 2075; X86: # %bb.0: 2076; X86-NEXT: pushl $256 # imm = 0x100 2077; X86-NEXT: pushl {{[0-9]+}}(%esp) 2078; X86-NEXT: pushl {{[0-9]+}}(%esp) 2079; X86-NEXT: calll memcmp 2080; X86-NEXT: addl $12, %esp 2081; X86-NEXT: retl 2082 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 256) nounwind 2083 ret i32 %m 2084} 2085 2086define i1 @length256_eq(ptr %x, ptr %y) nounwind { 2087; X86-LABEL: length256_eq: 2088; X86: # %bb.0: 2089; X86-NEXT: pushl $256 # imm = 0x100 2090; X86-NEXT: pushl {{[0-9]+}}(%esp) 2091; X86-NEXT: pushl {{[0-9]+}}(%esp) 2092; X86-NEXT: calll memcmp 2093; X86-NEXT: addl $12, %esp 2094; X86-NEXT: testl %eax, %eax 2095; X86-NEXT: setne %al 2096; X86-NEXT: retl 2097 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 256) nounwind 2098 %cmp = icmp ne i32 %call, 0 2099 ret i1 %cmp 2100} 2101 2102define i1 @length256_lt(ptr %x, ptr %y) nounwind { 2103; X86-LABEL: length256_lt: 2104; X86: # %bb.0: 2105; X86-NEXT: pushl $256 # imm = 0x100 2106; X86-NEXT: pushl {{[0-9]+}}(%esp) 2107; X86-NEXT: pushl {{[0-9]+}}(%esp) 2108; X86-NEXT: calll memcmp 2109; X86-NEXT: addl $12, %esp 2110; X86-NEXT: shrl $31, %eax 2111; X86-NEXT: # kill: def $al killed $al killed $eax 2112; X86-NEXT: retl 2113 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 256) nounwind 2114 %cmp = icmp slt i32 %call, 0 2115 ret i1 %cmp 2116} 2117 2118define i1 @length256_gt(ptr %x, ptr %y) nounwind { 2119; X86-LABEL: length256_gt: 2120; X86: # %bb.0: 2121; X86-NEXT: pushl $256 # imm = 0x100 2122; X86-NEXT: pushl {{[0-9]+}}(%esp) 2123; X86-NEXT: pushl {{[0-9]+}}(%esp) 2124; X86-NEXT: calll memcmp 2125; X86-NEXT: addl $12, %esp 2126; X86-NEXT: testl %eax, %eax 2127; X86-NEXT: setg %al 2128; X86-NEXT: retl 2129 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 256) nounwind 2130 %cmp = icmp sgt i32 %call, 0 2131 ret i1 %cmp 2132} 2133 2134define i1 @length256_eq_const(ptr %X) nounwind { 2135; X86-LABEL: length256_eq_const: 2136; X86: # %bb.0: 2137; X86-NEXT: pushl $256 # imm = 0x100 2138; X86-NEXT: pushl $.L.str 2139; X86-NEXT: pushl {{[0-9]+}}(%esp) 2140; X86-NEXT: calll memcmp 2141; X86-NEXT: addl $12, %esp 2142; X86-NEXT: testl %eax, %eax 2143; X86-NEXT: sete %al 2144; X86-NEXT: retl 2145 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i32 256) nounwind 2146 %c = icmp eq i32 %m, 0 2147 ret i1 %c 2148} 2149 2150define i32 @length384(ptr %X, ptr %Y) nounwind { 2151; X86-LABEL: length384: 2152; X86: # %bb.0: 2153; X86-NEXT: pushl $384 # imm = 0x180 2154; X86-NEXT: pushl {{[0-9]+}}(%esp) 2155; X86-NEXT: pushl {{[0-9]+}}(%esp) 2156; X86-NEXT: calll memcmp 2157; X86-NEXT: addl $12, %esp 2158; X86-NEXT: retl 2159 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 384) nounwind 2160 ret i32 %m 2161} 2162 2163define i1 @length384_eq(ptr %x, ptr %y) nounwind { 2164; X86-LABEL: length384_eq: 2165; X86: # %bb.0: 2166; X86-NEXT: pushl $384 # imm = 0x180 2167; X86-NEXT: pushl {{[0-9]+}}(%esp) 2168; X86-NEXT: pushl {{[0-9]+}}(%esp) 2169; X86-NEXT: calll memcmp 2170; X86-NEXT: addl $12, %esp 2171; X86-NEXT: testl %eax, %eax 2172; X86-NEXT: setne %al 2173; X86-NEXT: retl 2174 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 384) nounwind 2175 %cmp = icmp ne i32 %call, 0 2176 ret i1 %cmp 2177} 2178 2179define i1 @length384_lt(ptr %x, ptr %y) nounwind { 2180; X86-LABEL: length384_lt: 2181; X86: # %bb.0: 2182; X86-NEXT: pushl $384 # imm = 0x180 2183; X86-NEXT: pushl {{[0-9]+}}(%esp) 2184; X86-NEXT: pushl {{[0-9]+}}(%esp) 2185; X86-NEXT: calll memcmp 2186; X86-NEXT: addl $12, %esp 2187; X86-NEXT: shrl $31, %eax 2188; X86-NEXT: # kill: def $al killed $al killed $eax 2189; X86-NEXT: retl 2190 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 384) nounwind 2191 %cmp = icmp slt i32 %call, 0 2192 ret i1 %cmp 2193} 2194 2195define i1 @length384_gt(ptr %x, ptr %y) nounwind { 2196; X86-LABEL: length384_gt: 2197; X86: # %bb.0: 2198; X86-NEXT: pushl $384 # imm = 0x180 2199; X86-NEXT: pushl {{[0-9]+}}(%esp) 2200; X86-NEXT: pushl {{[0-9]+}}(%esp) 2201; X86-NEXT: calll memcmp 2202; X86-NEXT: addl $12, %esp 2203; X86-NEXT: testl %eax, %eax 2204; X86-NEXT: setg %al 2205; X86-NEXT: retl 2206 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 384) nounwind 2207 %cmp = icmp sgt i32 %call, 0 2208 ret i1 %cmp 2209} 2210 2211define i1 @length384_eq_const(ptr %X) nounwind { 2212; X86-LABEL: length384_eq_const: 2213; X86: # %bb.0: 2214; X86-NEXT: pushl $384 # imm = 0x180 2215; X86-NEXT: pushl $.L.str 2216; X86-NEXT: pushl {{[0-9]+}}(%esp) 2217; X86-NEXT: calll memcmp 2218; X86-NEXT: addl $12, %esp 2219; X86-NEXT: testl %eax, %eax 2220; X86-NEXT: sete %al 2221; X86-NEXT: retl 2222 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i32 384) nounwind 2223 %c = icmp eq i32 %m, 0 2224 ret i1 %c 2225} 2226 2227define i32 @length511(ptr %X, ptr %Y) nounwind { 2228; X86-LABEL: length511: 2229; X86: # %bb.0: 2230; X86-NEXT: pushl $511 # imm = 0x1FF 2231; X86-NEXT: pushl {{[0-9]+}}(%esp) 2232; X86-NEXT: pushl {{[0-9]+}}(%esp) 2233; X86-NEXT: calll memcmp 2234; X86-NEXT: addl $12, %esp 2235; X86-NEXT: retl 2236 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 511) nounwind 2237 ret i32 %m 2238} 2239 2240define i1 @length511_eq(ptr %x, ptr %y) nounwind { 2241; X86-LABEL: length511_eq: 2242; X86: # %bb.0: 2243; X86-NEXT: pushl $511 # imm = 0x1FF 2244; X86-NEXT: pushl {{[0-9]+}}(%esp) 2245; X86-NEXT: pushl {{[0-9]+}}(%esp) 2246; X86-NEXT: calll memcmp 2247; X86-NEXT: addl $12, %esp 2248; X86-NEXT: testl %eax, %eax 2249; X86-NEXT: setne %al 2250; X86-NEXT: retl 2251 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 511) nounwind 2252 %cmp = icmp ne i32 %call, 0 2253 ret i1 %cmp 2254} 2255 2256define i1 @length511_lt(ptr %x, ptr %y) nounwind { 2257; X86-LABEL: length511_lt: 2258; X86: # %bb.0: 2259; X86-NEXT: pushl $511 # imm = 0x1FF 2260; X86-NEXT: pushl {{[0-9]+}}(%esp) 2261; X86-NEXT: pushl {{[0-9]+}}(%esp) 2262; X86-NEXT: calll memcmp 2263; X86-NEXT: addl $12, %esp 2264; X86-NEXT: shrl $31, %eax 2265; X86-NEXT: # kill: def $al killed $al killed $eax 2266; X86-NEXT: retl 2267 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 511) nounwind 2268 %cmp = icmp slt i32 %call, 0 2269 ret i1 %cmp 2270} 2271 2272define i1 @length511_gt(ptr %x, ptr %y) nounwind { 2273; X86-LABEL: length511_gt: 2274; X86: # %bb.0: 2275; X86-NEXT: pushl $511 # imm = 0x1FF 2276; X86-NEXT: pushl {{[0-9]+}}(%esp) 2277; X86-NEXT: pushl {{[0-9]+}}(%esp) 2278; X86-NEXT: calll memcmp 2279; X86-NEXT: addl $12, %esp 2280; X86-NEXT: testl %eax, %eax 2281; X86-NEXT: setg %al 2282; X86-NEXT: retl 2283 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 511) nounwind 2284 %cmp = icmp sgt i32 %call, 0 2285 ret i1 %cmp 2286} 2287 2288define i1 @length511_eq_const(ptr %X) nounwind { 2289; X86-LABEL: length511_eq_const: 2290; X86: # %bb.0: 2291; X86-NEXT: pushl $511 # imm = 0x1FF 2292; X86-NEXT: pushl $.L.str 2293; X86-NEXT: pushl {{[0-9]+}}(%esp) 2294; X86-NEXT: calll memcmp 2295; X86-NEXT: addl $12, %esp 2296; X86-NEXT: testl %eax, %eax 2297; X86-NEXT: sete %al 2298; X86-NEXT: retl 2299 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i32 511) nounwind 2300 %c = icmp eq i32 %m, 0 2301 ret i1 %c 2302} 2303 2304define i32 @length512(ptr %X, ptr %Y) nounwind { 2305; X86-LABEL: length512: 2306; X86: # %bb.0: 2307; X86-NEXT: pushl $512 # imm = 0x200 2308; X86-NEXT: pushl {{[0-9]+}}(%esp) 2309; X86-NEXT: pushl {{[0-9]+}}(%esp) 2310; X86-NEXT: calll memcmp 2311; X86-NEXT: addl $12, %esp 2312; X86-NEXT: retl 2313 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 512) nounwind 2314 ret i32 %m 2315} 2316 2317define i1 @length512_eq(ptr %x, ptr %y) nounwind { 2318; X86-LABEL: length512_eq: 2319; X86: # %bb.0: 2320; X86-NEXT: pushl $512 # imm = 0x200 2321; X86-NEXT: pushl {{[0-9]+}}(%esp) 2322; X86-NEXT: pushl {{[0-9]+}}(%esp) 2323; X86-NEXT: calll memcmp 2324; X86-NEXT: addl $12, %esp 2325; X86-NEXT: testl %eax, %eax 2326; X86-NEXT: setne %al 2327; X86-NEXT: retl 2328 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 512) nounwind 2329 %cmp = icmp ne i32 %call, 0 2330 ret i1 %cmp 2331} 2332 2333define i1 @length512_lt(ptr %x, ptr %y) nounwind { 2334; X86-LABEL: length512_lt: 2335; X86: # %bb.0: 2336; X86-NEXT: pushl $512 # imm = 0x200 2337; X86-NEXT: pushl {{[0-9]+}}(%esp) 2338; X86-NEXT: pushl {{[0-9]+}}(%esp) 2339; X86-NEXT: calll memcmp 2340; X86-NEXT: addl $12, %esp 2341; X86-NEXT: shrl $31, %eax 2342; X86-NEXT: # kill: def $al killed $al killed $eax 2343; X86-NEXT: retl 2344 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 512) nounwind 2345 %cmp = icmp slt i32 %call, 0 2346 ret i1 %cmp 2347} 2348 2349define i1 @length512_gt(ptr %x, ptr %y) nounwind { 2350; X86-LABEL: length512_gt: 2351; X86: # %bb.0: 2352; X86-NEXT: pushl $512 # imm = 0x200 2353; X86-NEXT: pushl {{[0-9]+}}(%esp) 2354; X86-NEXT: pushl {{[0-9]+}}(%esp) 2355; X86-NEXT: calll memcmp 2356; X86-NEXT: addl $12, %esp 2357; X86-NEXT: testl %eax, %eax 2358; X86-NEXT: setg %al 2359; X86-NEXT: retl 2360 %call = tail call i32 @memcmp(ptr %x, ptr %y, i32 512) nounwind 2361 %cmp = icmp sgt i32 %call, 0 2362 ret i1 %cmp 2363} 2364 2365define i1 @length512_eq_const(ptr %X) nounwind { 2366; X86-LABEL: length512_eq_const: 2367; X86: # %bb.0: 2368; X86-NEXT: pushl $512 # imm = 0x200 2369; X86-NEXT: pushl $.L.str 2370; X86-NEXT: pushl {{[0-9]+}}(%esp) 2371; X86-NEXT: calll memcmp 2372; X86-NEXT: addl $12, %esp 2373; X86-NEXT: testl %eax, %eax 2374; X86-NEXT: sete %al 2375; X86-NEXT: retl 2376 %m = tail call i32 @memcmp(ptr %X, ptr @.str, i32 512) nounwind 2377 %c = icmp eq i32 %m, 0 2378 ret i1 %c 2379} 2380 2381; This checks that we do not do stupid things with huge sizes. 2382define i32 @huge_length(ptr %X, ptr %Y) nounwind { 2383; X86-LABEL: huge_length: 2384; X86: # %bb.0: 2385; X86-NEXT: pushl $-1 2386; X86-NEXT: pushl {{[0-9]+}}(%esp) 2387; X86-NEXT: pushl {{[0-9]+}}(%esp) 2388; X86-NEXT: calll memcmp 2389; X86-NEXT: addl $12, %esp 2390; X86-NEXT: retl 2391 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 9223372036854775807) nounwind 2392 ret i32 %m 2393} 2394 2395define i1 @huge_length_eq(ptr %X, ptr %Y) nounwind { 2396; X86-LABEL: huge_length_eq: 2397; X86: # %bb.0: 2398; X86-NEXT: pushl $-1 2399; X86-NEXT: pushl {{[0-9]+}}(%esp) 2400; X86-NEXT: pushl {{[0-9]+}}(%esp) 2401; X86-NEXT: calll memcmp 2402; X86-NEXT: addl $12, %esp 2403; X86-NEXT: testl %eax, %eax 2404; X86-NEXT: sete %al 2405; X86-NEXT: retl 2406 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 9223372036854775807) nounwind 2407 %c = icmp eq i32 %m, 0 2408 ret i1 %c 2409} 2410 2411; This checks non-constant sizes. 2412define i32 @nonconst_length(ptr %X, ptr %Y, i32 %size) nounwind { 2413; X86-LABEL: nonconst_length: 2414; X86: # %bb.0: 2415; X86-NEXT: jmp memcmp # TAILCALL 2416 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 %size) nounwind 2417 ret i32 %m 2418} 2419 2420define i1 @nonconst_length_eq(ptr %X, ptr %Y, i32 %size) nounwind { 2421; X86-LABEL: nonconst_length_eq: 2422; X86: # %bb.0: 2423; X86-NEXT: pushl {{[0-9]+}}(%esp) 2424; X86-NEXT: pushl {{[0-9]+}}(%esp) 2425; X86-NEXT: pushl {{[0-9]+}}(%esp) 2426; X86-NEXT: calll memcmp 2427; X86-NEXT: addl $12, %esp 2428; X86-NEXT: testl %eax, %eax 2429; X86-NEXT: sete %al 2430; X86-NEXT: retl 2431 %m = tail call i32 @memcmp(ptr %X, ptr %Y, i32 %size) nounwind 2432 %c = icmp eq i32 %m, 0 2433 ret i1 %c 2434} 2435