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