1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py 2; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=+sse,sse2 < %s | FileCheck %s --check-prefixes=CHECK,X86,V0123,X86-V0123,SSE2,X86-SSE2,BMI1,X86-BMI1,V0,X86-V0 3; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=+sse,sse2,+bmi < %s | FileCheck %s --check-prefixes=CHECK,X86,V0123,X86-V0123,SSE2,X86-SSE2,BMI1,X86-BMI1,V1,X86-V1 4; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=+sse,sse2,+bmi,+bmi2 < %s | FileCheck %s --check-prefixes=CHECK,X86,V0123,X86-V0123,SSE2,X86-SSE2,BMI2,X86-BMI2,V2,X86-V2 5; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=+sse,sse2,+bmi,+bmi2,+avx2 < %s | FileCheck %s --check-prefixes=CHECK,X86,V0123,X86-V0123,BMI2,X86-BMI2,AVX2,X86-AVX2 6; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=+sse,sse2 < %s | FileCheck %s --check-prefixes=CHECK,X64,V0123,X64-V0123,SSE2,X64-SSE2,BMI1,X64-BMI1,V0,X64-V0 7; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=+sse,sse2,+bmi < %s | FileCheck %s --check-prefixes=CHECK,X64,V0123,X64-V0123,SSE2,X64-SSE2,BMI1,X64-BMI1,V1,X64-V1 8; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=+sse,sse2,+bmi,+bmi2 < %s | FileCheck %s --check-prefixes=CHECK,X64,V0123,X64-V0123,SSE2,X64-SSE2,BMI2,X64-BMI2,V2,X64-V2 9; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=+sse,sse2,+bmi,+bmi2,+avx2 < %s | FileCheck %s --check-prefixes=CHECK,X64,V0123,X64-V0123,BMI2,X64-BMI2,AVX2,X64-AVX2 10 11; We are looking for the following pattern here: 12; (X & (C << Y)) ==/!= 0 13; It may be optimal to hoist the constant: 14; ((X l>> Y) & C) ==/!= 0 15 16;------------------------------------------------------------------------------; 17; A few scalar test 18;------------------------------------------------------------------------------; 19 20; i8 scalar 21 22define i1 @scalar_i8_signbit_eq(i8 %x, i8 %y) nounwind { 23; X86-LABEL: scalar_i8_signbit_eq: 24; X86: # %bb.0: 25; X86-NEXT: movb {{[0-9]+}}(%esp), %cl 26; X86-NEXT: movb {{[0-9]+}}(%esp), %al 27; X86-NEXT: shrb %cl, %al 28; X86-NEXT: testb $-128, %al 29; X86-NEXT: sete %al 30; X86-NEXT: retl 31; 32; X64-LABEL: scalar_i8_signbit_eq: 33; X64: # %bb.0: 34; X64-NEXT: movl %esi, %ecx 35; X64-NEXT: # kill: def $cl killed $cl killed $ecx 36; X64-NEXT: shrb %cl, %dil 37; X64-NEXT: testb $-128, %dil 38; X64-NEXT: sete %al 39; X64-NEXT: retq 40 %t0 = shl i8 128, %y 41 %t1 = and i8 %t0, %x 42 %res = icmp eq i8 %t1, 0 43 ret i1 %res 44} 45 46define i1 @scalar_i8_lowestbit_eq(i8 %x, i8 %y) nounwind { 47; X86-LABEL: scalar_i8_lowestbit_eq: 48; X86: # %bb.0: 49; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 50; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx 51; X86-NEXT: btl %eax, %ecx 52; X86-NEXT: setae %al 53; X86-NEXT: retl 54; 55; X64-LABEL: scalar_i8_lowestbit_eq: 56; X64: # %bb.0: 57; X64-NEXT: btl %esi, %edi 58; X64-NEXT: setae %al 59; X64-NEXT: retq 60 %t0 = shl i8 1, %y 61 %t1 = and i8 %t0, %x 62 %res = icmp eq i8 %t1, 0 63 ret i1 %res 64} 65 66define i1 @scalar_i8_bitsinmiddle_eq(i8 %x, i8 %y) nounwind { 67; X86-LABEL: scalar_i8_bitsinmiddle_eq: 68; X86: # %bb.0: 69; X86-NEXT: movb {{[0-9]+}}(%esp), %cl 70; X86-NEXT: movb {{[0-9]+}}(%esp), %al 71; X86-NEXT: shrb %cl, %al 72; X86-NEXT: testb $24, %al 73; X86-NEXT: sete %al 74; X86-NEXT: retl 75; 76; X64-LABEL: scalar_i8_bitsinmiddle_eq: 77; X64: # %bb.0: 78; X64-NEXT: movl %esi, %ecx 79; X64-NEXT: # kill: def $cl killed $cl killed $ecx 80; X64-NEXT: shrb %cl, %dil 81; X64-NEXT: testb $24, %dil 82; X64-NEXT: sete %al 83; X64-NEXT: retq 84 %t0 = shl i8 24, %y 85 %t1 = and i8 %t0, %x 86 %res = icmp eq i8 %t1, 0 87 ret i1 %res 88} 89 90; i16 scalar 91 92define i1 @scalar_i16_signbit_eq(i16 %x, i16 %y) nounwind { 93; X86-BMI1-LABEL: scalar_i16_signbit_eq: 94; X86-BMI1: # %bb.0: 95; X86-BMI1-NEXT: movb {{[0-9]+}}(%esp), %cl 96; X86-BMI1-NEXT: movzwl {{[0-9]+}}(%esp), %eax 97; X86-BMI1-NEXT: shrl %cl, %eax 98; X86-BMI1-NEXT: testl $32768, %eax # imm = 0x8000 99; X86-BMI1-NEXT: sete %al 100; X86-BMI1-NEXT: retl 101; 102; X86-BMI2-LABEL: scalar_i16_signbit_eq: 103; X86-BMI2: # %bb.0: 104; X86-BMI2-NEXT: movzwl {{[0-9]+}}(%esp), %eax 105; X86-BMI2-NEXT: movb {{[0-9]+}}(%esp), %cl 106; X86-BMI2-NEXT: shrxl %ecx, %eax, %eax 107; X86-BMI2-NEXT: testl $32768, %eax # imm = 0x8000 108; X86-BMI2-NEXT: sete %al 109; X86-BMI2-NEXT: retl 110; 111; X64-BMI1-LABEL: scalar_i16_signbit_eq: 112; X64-BMI1: # %bb.0: 113; X64-BMI1-NEXT: movl %esi, %ecx 114; X64-BMI1-NEXT: movzwl %di, %eax 115; X64-BMI1-NEXT: # kill: def $cl killed $cl killed $ecx 116; X64-BMI1-NEXT: shrl %cl, %eax 117; X64-BMI1-NEXT: testl $32768, %eax # imm = 0x8000 118; X64-BMI1-NEXT: sete %al 119; X64-BMI1-NEXT: retq 120; 121; X64-BMI2-LABEL: scalar_i16_signbit_eq: 122; X64-BMI2: # %bb.0: 123; X64-BMI2-NEXT: movzwl %di, %eax 124; X64-BMI2-NEXT: shrxl %esi, %eax, %eax 125; X64-BMI2-NEXT: testl $32768, %eax # imm = 0x8000 126; X64-BMI2-NEXT: sete %al 127; X64-BMI2-NEXT: retq 128 %t0 = shl i16 32768, %y 129 %t1 = and i16 %t0, %x 130 %res = icmp eq i16 %t1, 0 131 ret i1 %res 132} 133 134define i1 @scalar_i16_lowestbit_eq(i16 %x, i16 %y) nounwind { 135; X86-LABEL: scalar_i16_lowestbit_eq: 136; X86: # %bb.0: 137; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 138; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx 139; X86-NEXT: btl %eax, %ecx 140; X86-NEXT: setae %al 141; X86-NEXT: retl 142; 143; X64-LABEL: scalar_i16_lowestbit_eq: 144; X64: # %bb.0: 145; X64-NEXT: btl %esi, %edi 146; X64-NEXT: setae %al 147; X64-NEXT: retq 148 %t0 = shl i16 1, %y 149 %t1 = and i16 %t0, %x 150 %res = icmp eq i16 %t1, 0 151 ret i1 %res 152} 153 154define i1 @scalar_i16_bitsinmiddle_eq(i16 %x, i16 %y) nounwind { 155; X86-BMI1-LABEL: scalar_i16_bitsinmiddle_eq: 156; X86-BMI1: # %bb.0: 157; X86-BMI1-NEXT: movb {{[0-9]+}}(%esp), %cl 158; X86-BMI1-NEXT: movzwl {{[0-9]+}}(%esp), %eax 159; X86-BMI1-NEXT: shrl %cl, %eax 160; X86-BMI1-NEXT: testl $4080, %eax # imm = 0xFF0 161; X86-BMI1-NEXT: sete %al 162; X86-BMI1-NEXT: retl 163; 164; X86-BMI2-LABEL: scalar_i16_bitsinmiddle_eq: 165; X86-BMI2: # %bb.0: 166; X86-BMI2-NEXT: movzwl {{[0-9]+}}(%esp), %eax 167; X86-BMI2-NEXT: movb {{[0-9]+}}(%esp), %cl 168; X86-BMI2-NEXT: shrxl %ecx, %eax, %eax 169; X86-BMI2-NEXT: testl $4080, %eax # imm = 0xFF0 170; X86-BMI2-NEXT: sete %al 171; X86-BMI2-NEXT: retl 172; 173; X64-BMI1-LABEL: scalar_i16_bitsinmiddle_eq: 174; X64-BMI1: # %bb.0: 175; X64-BMI1-NEXT: movl %esi, %ecx 176; X64-BMI1-NEXT: movzwl %di, %eax 177; X64-BMI1-NEXT: # kill: def $cl killed $cl killed $ecx 178; X64-BMI1-NEXT: shrl %cl, %eax 179; X64-BMI1-NEXT: testl $4080, %eax # imm = 0xFF0 180; X64-BMI1-NEXT: sete %al 181; X64-BMI1-NEXT: retq 182; 183; X64-BMI2-LABEL: scalar_i16_bitsinmiddle_eq: 184; X64-BMI2: # %bb.0: 185; X64-BMI2-NEXT: movzwl %di, %eax 186; X64-BMI2-NEXT: shrxl %esi, %eax, %eax 187; X64-BMI2-NEXT: testl $4080, %eax # imm = 0xFF0 188; X64-BMI2-NEXT: sete %al 189; X64-BMI2-NEXT: retq 190 %t0 = shl i16 4080, %y 191 %t1 = and i16 %t0, %x 192 %res = icmp eq i16 %t1, 0 193 ret i1 %res 194} 195 196; i32 scalar 197 198define i1 @scalar_i32_signbit_eq(i32 %x, i32 %y) nounwind { 199; X86-BMI1-LABEL: scalar_i32_signbit_eq: 200; X86-BMI1: # %bb.0: 201; X86-BMI1-NEXT: movb {{[0-9]+}}(%esp), %cl 202; X86-BMI1-NEXT: movl {{[0-9]+}}(%esp), %eax 203; X86-BMI1-NEXT: shrl %cl, %eax 204; X86-BMI1-NEXT: testl $-2147483648, %eax # imm = 0x80000000 205; X86-BMI1-NEXT: sete %al 206; X86-BMI1-NEXT: retl 207; 208; X86-BMI2-LABEL: scalar_i32_signbit_eq: 209; X86-BMI2: # %bb.0: 210; X86-BMI2-NEXT: movb {{[0-9]+}}(%esp), %al 211; X86-BMI2-NEXT: shrxl %eax, {{[0-9]+}}(%esp), %eax 212; X86-BMI2-NEXT: testl $-2147483648, %eax # imm = 0x80000000 213; X86-BMI2-NEXT: sete %al 214; X86-BMI2-NEXT: retl 215; 216; X64-BMI1-LABEL: scalar_i32_signbit_eq: 217; X64-BMI1: # %bb.0: 218; X64-BMI1-NEXT: movl %esi, %ecx 219; X64-BMI1-NEXT: # kill: def $cl killed $cl killed $ecx 220; X64-BMI1-NEXT: shrl %cl, %edi 221; X64-BMI1-NEXT: testl $-2147483648, %edi # imm = 0x80000000 222; X64-BMI1-NEXT: sete %al 223; X64-BMI1-NEXT: retq 224; 225; X64-BMI2-LABEL: scalar_i32_signbit_eq: 226; X64-BMI2: # %bb.0: 227; X64-BMI2-NEXT: shrxl %esi, %edi, %eax 228; X64-BMI2-NEXT: testl $-2147483648, %eax # imm = 0x80000000 229; X64-BMI2-NEXT: sete %al 230; X64-BMI2-NEXT: retq 231 %t0 = shl i32 2147483648, %y 232 %t1 = and i32 %t0, %x 233 %res = icmp eq i32 %t1, 0 234 ret i1 %res 235} 236 237define i1 @scalar_i32_lowestbit_eq(i32 %x, i32 %y) nounwind { 238; X86-LABEL: scalar_i32_lowestbit_eq: 239; X86: # %bb.0: 240; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 241; X86-NEXT: movl {{[0-9]+}}(%esp), %ecx 242; X86-NEXT: btl %ecx, %eax 243; X86-NEXT: setae %al 244; X86-NEXT: retl 245; 246; X64-LABEL: scalar_i32_lowestbit_eq: 247; X64: # %bb.0: 248; X64-NEXT: btl %esi, %edi 249; X64-NEXT: setae %al 250; X64-NEXT: retq 251 %t0 = shl i32 1, %y 252 %t1 = and i32 %t0, %x 253 %res = icmp eq i32 %t1, 0 254 ret i1 %res 255} 256 257define i1 @scalar_i32_bitsinmiddle_eq(i32 %x, i32 %y) nounwind { 258; X86-BMI1-LABEL: scalar_i32_bitsinmiddle_eq: 259; X86-BMI1: # %bb.0: 260; X86-BMI1-NEXT: movb {{[0-9]+}}(%esp), %cl 261; X86-BMI1-NEXT: movl {{[0-9]+}}(%esp), %eax 262; X86-BMI1-NEXT: shrl %cl, %eax 263; X86-BMI1-NEXT: testl $16776960, %eax # imm = 0xFFFF00 264; X86-BMI1-NEXT: sete %al 265; X86-BMI1-NEXT: retl 266; 267; X86-BMI2-LABEL: scalar_i32_bitsinmiddle_eq: 268; X86-BMI2: # %bb.0: 269; X86-BMI2-NEXT: movb {{[0-9]+}}(%esp), %al 270; X86-BMI2-NEXT: shrxl %eax, {{[0-9]+}}(%esp), %eax 271; X86-BMI2-NEXT: testl $16776960, %eax # imm = 0xFFFF00 272; X86-BMI2-NEXT: sete %al 273; X86-BMI2-NEXT: retl 274; 275; X64-BMI1-LABEL: scalar_i32_bitsinmiddle_eq: 276; X64-BMI1: # %bb.0: 277; X64-BMI1-NEXT: movl %esi, %ecx 278; X64-BMI1-NEXT: # kill: def $cl killed $cl killed $ecx 279; X64-BMI1-NEXT: shrl %cl, %edi 280; X64-BMI1-NEXT: testl $16776960, %edi # imm = 0xFFFF00 281; X64-BMI1-NEXT: sete %al 282; X64-BMI1-NEXT: retq 283; 284; X64-BMI2-LABEL: scalar_i32_bitsinmiddle_eq: 285; X64-BMI2: # %bb.0: 286; X64-BMI2-NEXT: shrxl %esi, %edi, %eax 287; X64-BMI2-NEXT: testl $16776960, %eax # imm = 0xFFFF00 288; X64-BMI2-NEXT: sete %al 289; X64-BMI2-NEXT: retq 290 %t0 = shl i32 16776960, %y 291 %t1 = and i32 %t0, %x 292 %res = icmp eq i32 %t1, 0 293 ret i1 %res 294} 295 296; i64 scalar 297 298define i1 @scalar_i64_signbit_eq(i64 %x, i64 %y) nounwind { 299; X86-BMI1-LABEL: scalar_i64_signbit_eq: 300; X86-BMI1: # %bb.0: 301; X86-BMI1-NEXT: movb {{[0-9]+}}(%esp), %cl 302; X86-BMI1-NEXT: movl {{[0-9]+}}(%esp), %eax 303; X86-BMI1-NEXT: shrl %cl, %eax 304; X86-BMI1-NEXT: xorl %edx, %edx 305; X86-BMI1-NEXT: testb $32, %cl 306; X86-BMI1-NEXT: cmovel %eax, %edx 307; X86-BMI1-NEXT: testl $-2147483648, %edx # imm = 0x80000000 308; X86-BMI1-NEXT: sete %al 309; X86-BMI1-NEXT: retl 310; 311; X86-BMI2-LABEL: scalar_i64_signbit_eq: 312; X86-BMI2: # %bb.0: 313; X86-BMI2-NEXT: movb {{[0-9]+}}(%esp), %al 314; X86-BMI2-NEXT: shrxl %eax, {{[0-9]+}}(%esp), %ecx 315; X86-BMI2-NEXT: xorl %edx, %edx 316; X86-BMI2-NEXT: testb $32, %al 317; X86-BMI2-NEXT: cmovel %ecx, %edx 318; X86-BMI2-NEXT: testl $-2147483648, %edx # imm = 0x80000000 319; X86-BMI2-NEXT: sete %al 320; X86-BMI2-NEXT: retl 321; 322; X64-BMI1-LABEL: scalar_i64_signbit_eq: 323; X64-BMI1: # %bb.0: 324; X64-BMI1-NEXT: movq %rsi, %rcx 325; X64-BMI1-NEXT: # kill: def $cl killed $cl killed $rcx 326; X64-BMI1-NEXT: shrq %cl, %rdi 327; X64-BMI1-NEXT: btq $63, %rdi 328; X64-BMI1-NEXT: setae %al 329; X64-BMI1-NEXT: retq 330; 331; X64-BMI2-LABEL: scalar_i64_signbit_eq: 332; X64-BMI2: # %bb.0: 333; X64-BMI2-NEXT: shrxq %rsi, %rdi, %rax 334; X64-BMI2-NEXT: btq $63, %rax 335; X64-BMI2-NEXT: setae %al 336; X64-BMI2-NEXT: retq 337 %t0 = shl i64 9223372036854775808, %y 338 %t1 = and i64 %t0, %x 339 %res = icmp eq i64 %t1, 0 340 ret i1 %res 341} 342 343define i1 @scalar_i64_lowestbit_eq(i64 %x, i64 %y) nounwind { 344; X86-BMI1-LABEL: scalar_i64_lowestbit_eq: 345; X86-BMI1: # %bb.0: 346; X86-BMI1-NEXT: pushl %esi 347; X86-BMI1-NEXT: movb {{[0-9]+}}(%esp), %cl 348; X86-BMI1-NEXT: movl $1, %eax 349; X86-BMI1-NEXT: xorl %edx, %edx 350; X86-BMI1-NEXT: xorl %esi, %esi 351; X86-BMI1-NEXT: shldl %cl, %eax, %esi 352; X86-BMI1-NEXT: shll %cl, %eax 353; X86-BMI1-NEXT: testb $32, %cl 354; X86-BMI1-NEXT: cmovnel %eax, %esi 355; X86-BMI1-NEXT: cmovnel %edx, %eax 356; X86-BMI1-NEXT: andl {{[0-9]+}}(%esp), %esi 357; X86-BMI1-NEXT: andl {{[0-9]+}}(%esp), %eax 358; X86-BMI1-NEXT: orl %esi, %eax 359; X86-BMI1-NEXT: sete %al 360; X86-BMI1-NEXT: popl %esi 361; X86-BMI1-NEXT: retl 362; 363; X86-BMI2-LABEL: scalar_i64_lowestbit_eq: 364; X86-BMI2: # %bb.0: 365; X86-BMI2-NEXT: pushl %esi 366; X86-BMI2-NEXT: movb {{[0-9]+}}(%esp), %cl 367; X86-BMI2-NEXT: movl $1, %eax 368; X86-BMI2-NEXT: xorl %edx, %edx 369; X86-BMI2-NEXT: xorl %esi, %esi 370; X86-BMI2-NEXT: shldl %cl, %eax, %esi 371; X86-BMI2-NEXT: shlxl %ecx, %eax, %eax 372; X86-BMI2-NEXT: testb $32, %cl 373; X86-BMI2-NEXT: cmovnel %eax, %esi 374; X86-BMI2-NEXT: cmovnel %edx, %eax 375; X86-BMI2-NEXT: andl {{[0-9]+}}(%esp), %esi 376; X86-BMI2-NEXT: andl {{[0-9]+}}(%esp), %eax 377; X86-BMI2-NEXT: orl %esi, %eax 378; X86-BMI2-NEXT: sete %al 379; X86-BMI2-NEXT: popl %esi 380; X86-BMI2-NEXT: retl 381; 382; X64-LABEL: scalar_i64_lowestbit_eq: 383; X64: # %bb.0: 384; X64-NEXT: btq %rsi, %rdi 385; X64-NEXT: setae %al 386; X64-NEXT: retq 387 %t0 = shl i64 1, %y 388 %t1 = and i64 %t0, %x 389 %res = icmp eq i64 %t1, 0 390 ret i1 %res 391} 392 393define i1 @scalar_i64_bitsinmiddle_eq(i64 %x, i64 %y) nounwind { 394; X86-BMI1-LABEL: scalar_i64_bitsinmiddle_eq: 395; X86-BMI1: # %bb.0: 396; X86-BMI1-NEXT: pushl %esi 397; X86-BMI1-NEXT: movb {{[0-9]+}}(%esp), %cl 398; X86-BMI1-NEXT: movl {{[0-9]+}}(%esp), %eax 399; X86-BMI1-NEXT: movl {{[0-9]+}}(%esp), %edx 400; X86-BMI1-NEXT: movl %edx, %esi 401; X86-BMI1-NEXT: shrl %cl, %esi 402; X86-BMI1-NEXT: shrdl %cl, %edx, %eax 403; X86-BMI1-NEXT: xorl %edx, %edx 404; X86-BMI1-NEXT: testb $32, %cl 405; X86-BMI1-NEXT: cmovnel %esi, %eax 406; X86-BMI1-NEXT: cmovel %esi, %edx 407; X86-BMI1-NEXT: andl $-65536, %eax # imm = 0xFFFF0000 408; X86-BMI1-NEXT: movzwl %dx, %ecx 409; X86-BMI1-NEXT: orl %eax, %ecx 410; X86-BMI1-NEXT: sete %al 411; X86-BMI1-NEXT: popl %esi 412; X86-BMI1-NEXT: retl 413; 414; X86-BMI2-LABEL: scalar_i64_bitsinmiddle_eq: 415; X86-BMI2: # %bb.0: 416; X86-BMI2-NEXT: pushl %esi 417; X86-BMI2-NEXT: movb {{[0-9]+}}(%esp), %cl 418; X86-BMI2-NEXT: movl {{[0-9]+}}(%esp), %eax 419; X86-BMI2-NEXT: movl {{[0-9]+}}(%esp), %edx 420; X86-BMI2-NEXT: shrdl %cl, %edx, %eax 421; X86-BMI2-NEXT: shrxl %ecx, %edx, %edx 422; X86-BMI2-NEXT: xorl %esi, %esi 423; X86-BMI2-NEXT: testb $32, %cl 424; X86-BMI2-NEXT: cmovnel %edx, %eax 425; X86-BMI2-NEXT: cmovel %edx, %esi 426; X86-BMI2-NEXT: andl $-65536, %eax # imm = 0xFFFF0000 427; X86-BMI2-NEXT: movzwl %si, %ecx 428; X86-BMI2-NEXT: orl %eax, %ecx 429; X86-BMI2-NEXT: sete %al 430; X86-BMI2-NEXT: popl %esi 431; X86-BMI2-NEXT: retl 432; 433; X64-BMI1-LABEL: scalar_i64_bitsinmiddle_eq: 434; X64-BMI1: # %bb.0: 435; X64-BMI1-NEXT: movq %rsi, %rcx 436; X64-BMI1-NEXT: # kill: def $cl killed $cl killed $rcx 437; X64-BMI1-NEXT: shrq %cl, %rdi 438; X64-BMI1-NEXT: movabsq $281474976645120, %rax # imm = 0xFFFFFFFF0000 439; X64-BMI1-NEXT: testq %rax, %rdi 440; X64-BMI1-NEXT: sete %al 441; X64-BMI1-NEXT: retq 442; 443; X64-BMI2-LABEL: scalar_i64_bitsinmiddle_eq: 444; X64-BMI2: # %bb.0: 445; X64-BMI2-NEXT: shrxq %rsi, %rdi, %rax 446; X64-BMI2-NEXT: movabsq $281474976645120, %rcx # imm = 0xFFFFFFFF0000 447; X64-BMI2-NEXT: testq %rcx, %rax 448; X64-BMI2-NEXT: sete %al 449; X64-BMI2-NEXT: retq 450 %t0 = shl i64 281474976645120, %y 451 %t1 = and i64 %t0, %x 452 %res = icmp eq i64 %t1, 0 453 ret i1 %res 454} 455 456;------------------------------------------------------------------------------; 457; A few trivial vector tests 458;------------------------------------------------------------------------------; 459 460define <4 x i1> @vec_4xi32_splat_eq(<4 x i32> %x, <4 x i32> %y) nounwind { 461; X86-SSE2-LABEL: vec_4xi32_splat_eq: 462; X86-SSE2: # %bb.0: 463; X86-SSE2-NEXT: pslld $23, %xmm1 464; X86-SSE2-NEXT: paddd {{\.LCPI.*}}, %xmm1 465; X86-SSE2-NEXT: cvttps2dq %xmm1, %xmm1 466; X86-SSE2-NEXT: movdqa {{.*#+}} xmm2 = [1,1,1,1] 467; X86-SSE2-NEXT: pshufd {{.*#+}} xmm3 = xmm1[1,1,3,3] 468; X86-SSE2-NEXT: pmuludq %xmm2, %xmm3 469; X86-SSE2-NEXT: pmuludq %xmm1, %xmm2 470; X86-SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm2[0,2,2,3] 471; X86-SSE2-NEXT: pshufd {{.*#+}} xmm2 = xmm3[0,2,2,3] 472; X86-SSE2-NEXT: punpckldq {{.*#+}} xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1] 473; X86-SSE2-NEXT: pand %xmm1, %xmm0 474; X86-SSE2-NEXT: pxor %xmm1, %xmm1 475; X86-SSE2-NEXT: pcmpeqd %xmm1, %xmm0 476; X86-SSE2-NEXT: retl 477; 478; AVX2-LABEL: vec_4xi32_splat_eq: 479; AVX2: # %bb.0: 480; AVX2-NEXT: vpbroadcastd {{.*#+}} xmm2 = [1,1,1,1] 481; AVX2-NEXT: vpxor %xmm3, %xmm3, %xmm3 482; AVX2-NEXT: vpsrlvd %xmm1, %xmm0, %xmm0 483; AVX2-NEXT: vpand %xmm2, %xmm0, %xmm0 484; AVX2-NEXT: vpcmpeqd %xmm3, %xmm0, %xmm0 485; AVX2-NEXT: ret{{[l|q]}} 486; 487; X64-SSE2-LABEL: vec_4xi32_splat_eq: 488; X64-SSE2: # %bb.0: 489; X64-SSE2-NEXT: pslld $23, %xmm1 490; X64-SSE2-NEXT: paddd {{.*}}(%rip), %xmm1 491; X64-SSE2-NEXT: cvttps2dq %xmm1, %xmm1 492; X64-SSE2-NEXT: movdqa {{.*#+}} xmm2 = [1,1,1,1] 493; X64-SSE2-NEXT: pshufd {{.*#+}} xmm3 = xmm1[1,1,3,3] 494; X64-SSE2-NEXT: pmuludq %xmm2, %xmm3 495; X64-SSE2-NEXT: pmuludq %xmm1, %xmm2 496; X64-SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm2[0,2,2,3] 497; X64-SSE2-NEXT: pshufd {{.*#+}} xmm2 = xmm3[0,2,2,3] 498; X64-SSE2-NEXT: punpckldq {{.*#+}} xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1] 499; X64-SSE2-NEXT: pand %xmm1, %xmm0 500; X64-SSE2-NEXT: pxor %xmm1, %xmm1 501; X64-SSE2-NEXT: pcmpeqd %xmm1, %xmm0 502; X64-SSE2-NEXT: retq 503 %t0 = shl <4 x i32> <i32 1, i32 1, i32 1, i32 1>, %y 504 %t1 = and <4 x i32> %t0, %x 505 %res = icmp eq <4 x i32> %t1, <i32 0, i32 0, i32 0, i32 0> 506 ret <4 x i1> %res 507} 508 509define <4 x i1> @vec_4xi32_nonsplat_eq(<4 x i32> %x, <4 x i32> %y) nounwind { 510; X86-SSE2-LABEL: vec_4xi32_nonsplat_eq: 511; X86-SSE2: # %bb.0: 512; X86-SSE2-NEXT: pslld $23, %xmm1 513; X86-SSE2-NEXT: paddd {{\.LCPI.*}}, %xmm1 514; X86-SSE2-NEXT: cvttps2dq %xmm1, %xmm1 515; X86-SSE2-NEXT: movdqa {{.*#+}} xmm2 = [0,1,16776960,2147483648] 516; X86-SSE2-NEXT: pshufd {{.*#+}} xmm3 = xmm2[1,1,3,3] 517; X86-SSE2-NEXT: pmuludq %xmm1, %xmm2 518; X86-SSE2-NEXT: pshufd {{.*#+}} xmm2 = xmm2[0,2,2,3] 519; X86-SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm1[1,1,3,3] 520; X86-SSE2-NEXT: pmuludq %xmm3, %xmm1 521; X86-SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm1[0,2,2,3] 522; X86-SSE2-NEXT: punpckldq {{.*#+}} xmm2 = xmm2[0],xmm1[0],xmm2[1],xmm1[1] 523; X86-SSE2-NEXT: pand %xmm2, %xmm0 524; X86-SSE2-NEXT: pxor %xmm1, %xmm1 525; X86-SSE2-NEXT: pcmpeqd %xmm1, %xmm0 526; X86-SSE2-NEXT: retl 527; 528; AVX2-LABEL: vec_4xi32_nonsplat_eq: 529; AVX2: # %bb.0: 530; AVX2-NEXT: vmovdqa {{.*#+}} xmm2 = [0,1,16776960,2147483648] 531; AVX2-NEXT: vpsllvd %xmm1, %xmm2, %xmm1 532; AVX2-NEXT: vpand %xmm0, %xmm1, %xmm0 533; AVX2-NEXT: vpxor %xmm1, %xmm1, %xmm1 534; AVX2-NEXT: vpcmpeqd %xmm1, %xmm0, %xmm0 535; AVX2-NEXT: ret{{[l|q]}} 536; 537; X64-SSE2-LABEL: vec_4xi32_nonsplat_eq: 538; X64-SSE2: # %bb.0: 539; X64-SSE2-NEXT: pslld $23, %xmm1 540; X64-SSE2-NEXT: paddd {{.*}}(%rip), %xmm1 541; X64-SSE2-NEXT: cvttps2dq %xmm1, %xmm1 542; X64-SSE2-NEXT: movdqa {{.*#+}} xmm2 = [0,1,16776960,2147483648] 543; X64-SSE2-NEXT: pshufd {{.*#+}} xmm3 = xmm2[1,1,3,3] 544; X64-SSE2-NEXT: pmuludq %xmm1, %xmm2 545; X64-SSE2-NEXT: pshufd {{.*#+}} xmm2 = xmm2[0,2,2,3] 546; X64-SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm1[1,1,3,3] 547; X64-SSE2-NEXT: pmuludq %xmm3, %xmm1 548; X64-SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm1[0,2,2,3] 549; X64-SSE2-NEXT: punpckldq {{.*#+}} xmm2 = xmm2[0],xmm1[0],xmm2[1],xmm1[1] 550; X64-SSE2-NEXT: pand %xmm2, %xmm0 551; X64-SSE2-NEXT: pxor %xmm1, %xmm1 552; X64-SSE2-NEXT: pcmpeqd %xmm1, %xmm0 553; X64-SSE2-NEXT: retq 554 %t0 = shl <4 x i32> <i32 0, i32 1, i32 16776960, i32 2147483648>, %y 555 %t1 = and <4 x i32> %t0, %x 556 %res = icmp eq <4 x i32> %t1, <i32 0, i32 0, i32 0, i32 0> 557 ret <4 x i1> %res 558} 559 560define <4 x i1> @vec_4xi32_nonsplat_undef0_eq(<4 x i32> %x, <4 x i32> %y) nounwind { 561; X86-SSE2-LABEL: vec_4xi32_nonsplat_undef0_eq: 562; X86-SSE2: # %bb.0: 563; X86-SSE2-NEXT: movl $1, %eax 564; X86-SSE2-NEXT: movd %eax, %xmm2 565; X86-SSE2-NEXT: pslld $23, %xmm1 566; X86-SSE2-NEXT: paddd {{\.LCPI.*}}, %xmm1 567; X86-SSE2-NEXT: cvttps2dq %xmm1, %xmm1 568; X86-SSE2-NEXT: pmuludq %xmm1, %xmm2 569; X86-SSE2-NEXT: pshufd {{.*#+}} xmm2 = xmm2[0,2,2,3] 570; X86-SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm1[1,1,3,3] 571; X86-SSE2-NEXT: pmuludq {{\.LCPI.*}}, %xmm1 572; X86-SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm1[0,2,2,3] 573; X86-SSE2-NEXT: punpckldq {{.*#+}} xmm2 = xmm2[0],xmm1[0],xmm2[1],xmm1[1] 574; X86-SSE2-NEXT: pand %xmm2, %xmm0 575; X86-SSE2-NEXT: pxor %xmm1, %xmm1 576; X86-SSE2-NEXT: pcmpeqd %xmm1, %xmm0 577; X86-SSE2-NEXT: retl 578; 579; AVX2-LABEL: vec_4xi32_nonsplat_undef0_eq: 580; AVX2: # %bb.0: 581; AVX2-NEXT: vpbroadcastd {{.*#+}} xmm2 = [1,1,1,1] 582; AVX2-NEXT: vpxor %xmm3, %xmm3, %xmm3 583; AVX2-NEXT: vpsrlvd %xmm1, %xmm0, %xmm0 584; AVX2-NEXT: vpand %xmm2, %xmm0, %xmm0 585; AVX2-NEXT: vpcmpeqd %xmm3, %xmm0, %xmm0 586; AVX2-NEXT: ret{{[l|q]}} 587; 588; X64-SSE2-LABEL: vec_4xi32_nonsplat_undef0_eq: 589; X64-SSE2: # %bb.0: 590; X64-SSE2-NEXT: movl $1, %eax 591; X64-SSE2-NEXT: movd %eax, %xmm2 592; X64-SSE2-NEXT: pslld $23, %xmm1 593; X64-SSE2-NEXT: paddd {{.*}}(%rip), %xmm1 594; X64-SSE2-NEXT: cvttps2dq %xmm1, %xmm1 595; X64-SSE2-NEXT: pmuludq %xmm1, %xmm2 596; X64-SSE2-NEXT: pshufd {{.*#+}} xmm2 = xmm2[0,2,2,3] 597; X64-SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm1[1,1,3,3] 598; X64-SSE2-NEXT: pmuludq {{.*}}(%rip), %xmm1 599; X64-SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm1[0,2,2,3] 600; X64-SSE2-NEXT: punpckldq {{.*#+}} xmm2 = xmm2[0],xmm1[0],xmm2[1],xmm1[1] 601; X64-SSE2-NEXT: pand %xmm2, %xmm0 602; X64-SSE2-NEXT: pxor %xmm1, %xmm1 603; X64-SSE2-NEXT: pcmpeqd %xmm1, %xmm0 604; X64-SSE2-NEXT: retq 605 %t0 = shl <4 x i32> <i32 1, i32 1, i32 undef, i32 1>, %y 606 %t1 = and <4 x i32> %t0, %x 607 %res = icmp eq <4 x i32> %t1, <i32 0, i32 0, i32 0, i32 0> 608 ret <4 x i1> %res 609} 610define <4 x i1> @vec_4xi32_nonsplat_undef1_eq(<4 x i32> %x, <4 x i32> %y) nounwind { 611; X86-SSE2-LABEL: vec_4xi32_nonsplat_undef1_eq: 612; X86-SSE2: # %bb.0: 613; X86-SSE2-NEXT: pslld $23, %xmm1 614; X86-SSE2-NEXT: paddd {{\.LCPI.*}}, %xmm1 615; X86-SSE2-NEXT: cvttps2dq %xmm1, %xmm1 616; X86-SSE2-NEXT: movdqa {{.*#+}} xmm2 = [1,1,1,1] 617; X86-SSE2-NEXT: pshufd {{.*#+}} xmm3 = xmm1[1,1,3,3] 618; X86-SSE2-NEXT: pmuludq %xmm2, %xmm3 619; X86-SSE2-NEXT: pmuludq %xmm1, %xmm2 620; X86-SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm2[0,2,2,3] 621; X86-SSE2-NEXT: pshufd {{.*#+}} xmm2 = xmm3[0,2,2,3] 622; X86-SSE2-NEXT: punpckldq {{.*#+}} xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1] 623; X86-SSE2-NEXT: pand %xmm1, %xmm0 624; X86-SSE2-NEXT: pxor %xmm1, %xmm1 625; X86-SSE2-NEXT: pcmpeqd %xmm1, %xmm0 626; X86-SSE2-NEXT: retl 627; 628; AVX2-LABEL: vec_4xi32_nonsplat_undef1_eq: 629; AVX2: # %bb.0: 630; AVX2-NEXT: vpbroadcastd {{.*#+}} xmm2 = [1,1,1,1] 631; AVX2-NEXT: vpsllvd %xmm1, %xmm2, %xmm1 632; AVX2-NEXT: vpand %xmm0, %xmm1, %xmm0 633; AVX2-NEXT: vpxor %xmm1, %xmm1, %xmm1 634; AVX2-NEXT: vpcmpeqd %xmm1, %xmm0, %xmm0 635; AVX2-NEXT: ret{{[l|q]}} 636; 637; X64-SSE2-LABEL: vec_4xi32_nonsplat_undef1_eq: 638; X64-SSE2: # %bb.0: 639; X64-SSE2-NEXT: pslld $23, %xmm1 640; X64-SSE2-NEXT: paddd {{.*}}(%rip), %xmm1 641; X64-SSE2-NEXT: cvttps2dq %xmm1, %xmm1 642; X64-SSE2-NEXT: movdqa {{.*#+}} xmm2 = [1,1,1,1] 643; X64-SSE2-NEXT: pshufd {{.*#+}} xmm3 = xmm1[1,1,3,3] 644; X64-SSE2-NEXT: pmuludq %xmm2, %xmm3 645; X64-SSE2-NEXT: pmuludq %xmm1, %xmm2 646; X64-SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm2[0,2,2,3] 647; X64-SSE2-NEXT: pshufd {{.*#+}} xmm2 = xmm3[0,2,2,3] 648; X64-SSE2-NEXT: punpckldq {{.*#+}} xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1] 649; X64-SSE2-NEXT: pand %xmm1, %xmm0 650; X64-SSE2-NEXT: pxor %xmm1, %xmm1 651; X64-SSE2-NEXT: pcmpeqd %xmm1, %xmm0 652; X64-SSE2-NEXT: retq 653 %t0 = shl <4 x i32> <i32 1, i32 1, i32 1, i32 1>, %y 654 %t1 = and <4 x i32> %t0, %x 655 %res = icmp eq <4 x i32> %t1, <i32 0, i32 0, i32 undef, i32 0> 656 ret <4 x i1> %res 657} 658define <4 x i1> @vec_4xi32_nonsplat_undef2_eq(<4 x i32> %x, <4 x i32> %y) nounwind { 659; X86-SSE2-LABEL: vec_4xi32_nonsplat_undef2_eq: 660; X86-SSE2: # %bb.0: 661; X86-SSE2-NEXT: movl $1, %eax 662; X86-SSE2-NEXT: movd %eax, %xmm2 663; X86-SSE2-NEXT: pslld $23, %xmm1 664; X86-SSE2-NEXT: paddd {{\.LCPI.*}}, %xmm1 665; X86-SSE2-NEXT: cvttps2dq %xmm1, %xmm1 666; X86-SSE2-NEXT: pmuludq %xmm1, %xmm2 667; X86-SSE2-NEXT: pshufd {{.*#+}} xmm2 = xmm2[0,2,2,3] 668; X86-SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm1[1,1,3,3] 669; X86-SSE2-NEXT: pmuludq {{\.LCPI.*}}, %xmm1 670; X86-SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm1[0,2,2,3] 671; X86-SSE2-NEXT: punpckldq {{.*#+}} xmm2 = xmm2[0],xmm1[0],xmm2[1],xmm1[1] 672; X86-SSE2-NEXT: pand %xmm2, %xmm0 673; X86-SSE2-NEXT: pxor %xmm1, %xmm1 674; X86-SSE2-NEXT: pcmpeqd %xmm1, %xmm0 675; X86-SSE2-NEXT: retl 676; 677; AVX2-LABEL: vec_4xi32_nonsplat_undef2_eq: 678; AVX2: # %bb.0: 679; AVX2-NEXT: vpbroadcastd {{.*#+}} xmm2 = [1,1,1,1] 680; AVX2-NEXT: vpsllvd %xmm1, %xmm2, %xmm1 681; AVX2-NEXT: vpand %xmm0, %xmm1, %xmm0 682; AVX2-NEXT: vpxor %xmm1, %xmm1, %xmm1 683; AVX2-NEXT: vpcmpeqd %xmm1, %xmm0, %xmm0 684; AVX2-NEXT: ret{{[l|q]}} 685; 686; X64-SSE2-LABEL: vec_4xi32_nonsplat_undef2_eq: 687; X64-SSE2: # %bb.0: 688; X64-SSE2-NEXT: movl $1, %eax 689; X64-SSE2-NEXT: movd %eax, %xmm2 690; X64-SSE2-NEXT: pslld $23, %xmm1 691; X64-SSE2-NEXT: paddd {{.*}}(%rip), %xmm1 692; X64-SSE2-NEXT: cvttps2dq %xmm1, %xmm1 693; X64-SSE2-NEXT: pmuludq %xmm1, %xmm2 694; X64-SSE2-NEXT: pshufd {{.*#+}} xmm2 = xmm2[0,2,2,3] 695; X64-SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm1[1,1,3,3] 696; X64-SSE2-NEXT: pmuludq {{.*}}(%rip), %xmm1 697; X64-SSE2-NEXT: pshufd {{.*#+}} xmm1 = xmm1[0,2,2,3] 698; X64-SSE2-NEXT: punpckldq {{.*#+}} xmm2 = xmm2[0],xmm1[0],xmm2[1],xmm1[1] 699; X64-SSE2-NEXT: pand %xmm2, %xmm0 700; X64-SSE2-NEXT: pxor %xmm1, %xmm1 701; X64-SSE2-NEXT: pcmpeqd %xmm1, %xmm0 702; X64-SSE2-NEXT: retq 703 %t0 = shl <4 x i32> <i32 1, i32 1, i32 undef, i32 1>, %y 704 %t1 = and <4 x i32> %t0, %x 705 %res = icmp eq <4 x i32> %t1, <i32 0, i32 0, i32 undef, i32 0> 706 ret <4 x i1> %res 707} 708 709;------------------------------------------------------------------------------; 710; A special tests 711;------------------------------------------------------------------------------; 712 713define i1 @scalar_i8_signbit_ne(i8 %x, i8 %y) nounwind { 714; X86-LABEL: scalar_i8_signbit_ne: 715; X86: # %bb.0: 716; X86-NEXT: movb {{[0-9]+}}(%esp), %cl 717; X86-NEXT: movb {{[0-9]+}}(%esp), %al 718; X86-NEXT: shrb %cl, %al 719; X86-NEXT: shrb $7, %al 720; X86-NEXT: retl 721; 722; X64-LABEL: scalar_i8_signbit_ne: 723; X64: # %bb.0: 724; X64-NEXT: movl %esi, %ecx 725; X64-NEXT: movl %edi, %eax 726; X64-NEXT: # kill: def $cl killed $cl killed $ecx 727; X64-NEXT: shrb %cl, %al 728; X64-NEXT: shrb $7, %al 729; X64-NEXT: # kill: def $al killed $al killed $eax 730; X64-NEXT: retq 731 %t0 = shl i8 128, %y 732 %t1 = and i8 %t0, %x 733 %res = icmp ne i8 %t1, 0 ; we are perfectly happy with 'ne' predicate 734 ret i1 %res 735} 736 737;------------------------------------------------------------------------------; 738; What if X is a constant too? 739;------------------------------------------------------------------------------; 740 741define i1 @scalar_i32_x_is_const_eq(i32 %y) nounwind { 742; X86-BMI1-LABEL: scalar_i32_x_is_const_eq: 743; X86-BMI1: # %bb.0: 744; X86-BMI1-NEXT: movb {{[0-9]+}}(%esp), %cl 745; X86-BMI1-NEXT: movl $-1437226411, %eax # imm = 0xAA55AA55 746; X86-BMI1-NEXT: shll %cl, %eax 747; X86-BMI1-NEXT: testb $1, %al 748; X86-BMI1-NEXT: sete %al 749; X86-BMI1-NEXT: retl 750; 751; X86-BMI2-LABEL: scalar_i32_x_is_const_eq: 752; X86-BMI2: # %bb.0: 753; X86-BMI2-NEXT: movb {{[0-9]+}}(%esp), %al 754; X86-BMI2-NEXT: movl $-1437226411, %ecx # imm = 0xAA55AA55 755; X86-BMI2-NEXT: shlxl %eax, %ecx, %eax 756; X86-BMI2-NEXT: testb $1, %al 757; X86-BMI2-NEXT: sete %al 758; X86-BMI2-NEXT: retl 759; 760; X64-BMI1-LABEL: scalar_i32_x_is_const_eq: 761; X64-BMI1: # %bb.0: 762; X64-BMI1-NEXT: movl %edi, %ecx 763; X64-BMI1-NEXT: movl $-1437226411, %eax # imm = 0xAA55AA55 764; X64-BMI1-NEXT: # kill: def $cl killed $cl killed $ecx 765; X64-BMI1-NEXT: shll %cl, %eax 766; X64-BMI1-NEXT: testb $1, %al 767; X64-BMI1-NEXT: sete %al 768; X64-BMI1-NEXT: retq 769; 770; X64-BMI2-LABEL: scalar_i32_x_is_const_eq: 771; X64-BMI2: # %bb.0: 772; X64-BMI2-NEXT: movl $-1437226411, %eax # imm = 0xAA55AA55 773; X64-BMI2-NEXT: shlxl %edi, %eax, %eax 774; X64-BMI2-NEXT: testb $1, %al 775; X64-BMI2-NEXT: sete %al 776; X64-BMI2-NEXT: retq 777 %t0 = shl i32 2857740885, %y 778 %t1 = and i32 %t0, 1 779 %res = icmp eq i32 %t1, 0 780 ret i1 %res 781} 782define i1 @scalar_i32_x_is_const2_eq(i32 %y) nounwind { 783; X86-LABEL: scalar_i32_x_is_const2_eq: 784; X86: # %bb.0: 785; X86-NEXT: movl {{[0-9]+}}(%esp), %eax 786; X86-NEXT: movl $-1437226411, %ecx # imm = 0xAA55AA55 787; X86-NEXT: btl %eax, %ecx 788; X86-NEXT: setae %al 789; X86-NEXT: retl 790; 791; X64-LABEL: scalar_i32_x_is_const2_eq: 792; X64: # %bb.0: 793; X64-NEXT: movl $-1437226411, %eax # imm = 0xAA55AA55 794; X64-NEXT: btl %edi, %eax 795; X64-NEXT: setae %al 796; X64-NEXT: retq 797 %t0 = shl i32 1, %y 798 %t1 = and i32 %t0, 2857740885 799 %res = icmp eq i32 %t1, 0 800 ret i1 %res 801} 802 803;------------------------------------------------------------------------------; 804; A few negative tests 805;------------------------------------------------------------------------------; 806 807define i1 @negative_scalar_i8_bitsinmiddle_slt(i8 %x, i8 %y) nounwind { 808; X86-LABEL: negative_scalar_i8_bitsinmiddle_slt: 809; X86: # %bb.0: 810; X86-NEXT: movb {{[0-9]+}}(%esp), %cl 811; X86-NEXT: movb $24, %al 812; X86-NEXT: shlb %cl, %al 813; X86-NEXT: andb {{[0-9]+}}(%esp), %al 814; X86-NEXT: shrb $7, %al 815; X86-NEXT: retl 816; 817; X64-LABEL: negative_scalar_i8_bitsinmiddle_slt: 818; X64: # %bb.0: 819; X64-NEXT: movl %esi, %ecx 820; X64-NEXT: movb $24, %al 821; X64-NEXT: # kill: def $cl killed $cl killed $ecx 822; X64-NEXT: shlb %cl, %al 823; X64-NEXT: andb %dil, %al 824; X64-NEXT: shrb $7, %al 825; X64-NEXT: retq 826 %t0 = shl i8 24, %y 827 %t1 = and i8 %t0, %x 828 %res = icmp slt i8 %t1, 0 829 ret i1 %res 830} 831 832define i1 @scalar_i8_signbit_eq_with_nonzero(i8 %x, i8 %y) nounwind { 833; X86-LABEL: scalar_i8_signbit_eq_with_nonzero: 834; X86: # %bb.0: 835; X86-NEXT: movb {{[0-9]+}}(%esp), %cl 836; X86-NEXT: movb $-128, %al 837; X86-NEXT: shlb %cl, %al 838; X86-NEXT: andb {{[0-9]+}}(%esp), %al 839; X86-NEXT: cmpb $1, %al 840; X86-NEXT: sete %al 841; X86-NEXT: retl 842; 843; X64-LABEL: scalar_i8_signbit_eq_with_nonzero: 844; X64: # %bb.0: 845; X64-NEXT: movl %esi, %ecx 846; X64-NEXT: movb $-128, %al 847; X64-NEXT: # kill: def $cl killed $cl killed $ecx 848; X64-NEXT: shlb %cl, %al 849; X64-NEXT: andb %dil, %al 850; X64-NEXT: cmpb $1, %al 851; X64-NEXT: sete %al 852; X64-NEXT: retq 853 %t0 = shl i8 128, %y 854 %t1 = and i8 %t0, %x 855 %res = icmp eq i8 %t1, 1 ; should be comparing with 0 856 ret i1 %res 857} 858