brintos

brintos / llvm-project-archived public Read only

0
0
Text · 28.0 KiB · b45d01e Raw
818 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=+sse,sse2                  < %s | FileCheck %s --check-prefixes=X86,X86-SSE2,X86-BMI13; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=+sse,sse2,+bmi             < %s | FileCheck %s --check-prefixes=X86,X86-SSE2,X86-BMI14; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=+sse,sse2,+bmi,+bmi2       < %s | FileCheck %s --check-prefixes=X86,X86-SSE2,X86-BMI25; RUN: llc -mtriple=i686-unknown-linux-gnu -mattr=+sse,sse2,+bmi,+bmi2,+avx2 < %s | FileCheck %s --check-prefixes=X86,X86-BMI2,AVX26; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=+sse,sse2                  < %s | FileCheck %s --check-prefixes=X64,X64-SSE2,X64-BMI17; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=+sse,sse2,+bmi             < %s | FileCheck %s --check-prefixes=X64,X64-SSE2,X64-BMI18; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=+sse,sse2,+bmi,+bmi2       < %s | FileCheck %s --check-prefixes=X64,X64-SSE2,X64-BMI29; RUN: llc -mtriple=x86_64-unknown-linux-gnu -mattr=+sse,sse2,+bmi,+bmi2,+avx2 < %s | FileCheck %s --check-prefixes=X64,X64-BMI2,AVX210 11; We are looking for the following pattern here:12;   (X & (C << Y)) ==/!= 013; It may be optimal to hoist the constant:14;   ((X l>> Y) & C) ==/!= 015 16;------------------------------------------------------------------------------;17; A few scalar test18;------------------------------------------------------------------------------;19 20; i8 scalar21 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:    movzbl {{[0-9]+}}(%esp), %ecx26; X86-NEXT:    movzbl {{[0-9]+}}(%esp), %eax27; X86-NEXT:    shrb %cl, %al28; X86-NEXT:    testb $-128, %al29; X86-NEXT:    sete %al30; X86-NEXT:    retl31;32; X64-LABEL: scalar_i8_signbit_eq:33; X64:       # %bb.0:34; X64-NEXT:    movl %esi, %ecx35; X64-NEXT:    # kill: def $cl killed $cl killed $ecx36; X64-NEXT:    shrb %cl, %dil37; X64-NEXT:    testb $-128, %dil38; X64-NEXT:    sete %al39; X64-NEXT:    retq40  %t0 = shl i8 128, %y41  %t1 = and i8 %t0, %x42  %res = icmp eq i8 %t1, 043  ret i1 %res44}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), %eax50; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx51; X86-NEXT:    btl %eax, %ecx52; X86-NEXT:    setae %al53; X86-NEXT:    retl54;55; X64-LABEL: scalar_i8_lowestbit_eq:56; X64:       # %bb.0:57; X64-NEXT:    btl %esi, %edi58; X64-NEXT:    setae %al59; X64-NEXT:    retq60  %t0 = shl i8 1, %y61  %t1 = and i8 %t0, %x62  %res = icmp eq i8 %t1, 063  ret i1 %res64}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:    movzbl {{[0-9]+}}(%esp), %ecx70; X86-NEXT:    movzbl {{[0-9]+}}(%esp), %eax71; X86-NEXT:    shrb %cl, %al72; X86-NEXT:    testb $24, %al73; X86-NEXT:    sete %al74; X86-NEXT:    retl75;76; X64-LABEL: scalar_i8_bitsinmiddle_eq:77; X64:       # %bb.0:78; X64-NEXT:    movl %esi, %ecx79; X64-NEXT:    # kill: def $cl killed $cl killed $ecx80; X64-NEXT:    shrb %cl, %dil81; X64-NEXT:    testb $24, %dil82; X64-NEXT:    sete %al83; X64-NEXT:    retq84  %t0 = shl i8 24, %y85  %t1 = and i8 %t0, %x86  %res = icmp eq i8 %t1, 087  ret i1 %res88}89 90; i16 scalar91 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:    movzbl {{[0-9]+}}(%esp), %ecx96; X86-BMI1-NEXT:    movzwl {{[0-9]+}}(%esp), %eax97; X86-BMI1-NEXT:    shrl %cl, %eax98; X86-BMI1-NEXT:    testl $32768, %eax # imm = 0x800099; X86-BMI1-NEXT:    sete %al100; X86-BMI1-NEXT:    retl101;102; X86-BMI2-LABEL: scalar_i16_signbit_eq:103; X86-BMI2:       # %bb.0:104; X86-BMI2-NEXT:    movzwl {{[0-9]+}}(%esp), %eax105; X86-BMI2-NEXT:    movzbl {{[0-9]+}}(%esp), %ecx106; X86-BMI2-NEXT:    shrxl %ecx, %eax, %eax107; X86-BMI2-NEXT:    testl $32768, %eax # imm = 0x8000108; X86-BMI2-NEXT:    sete %al109; X86-BMI2-NEXT:    retl110;111; X64-BMI1-LABEL: scalar_i16_signbit_eq:112; X64-BMI1:       # %bb.0:113; X64-BMI1-NEXT:    movl %esi, %ecx114; X64-BMI1-NEXT:    movzwl %di, %eax115; X64-BMI1-NEXT:    # kill: def $cl killed $cl killed $ecx116; X64-BMI1-NEXT:    shrl %cl, %eax117; X64-BMI1-NEXT:    testl $32768, %eax # imm = 0x8000118; X64-BMI1-NEXT:    sete %al119; X64-BMI1-NEXT:    retq120;121; X64-BMI2-LABEL: scalar_i16_signbit_eq:122; X64-BMI2:       # %bb.0:123; X64-BMI2-NEXT:    movzwl %di, %eax124; X64-BMI2-NEXT:    shrxl %esi, %eax, %eax125; X64-BMI2-NEXT:    testl $32768, %eax # imm = 0x8000126; X64-BMI2-NEXT:    sete %al127; X64-BMI2-NEXT:    retq128  %t0 = shl i16 32768, %y129  %t1 = and i16 %t0, %x130  %res = icmp eq i16 %t1, 0131  ret i1 %res132}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), %eax138; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx139; X86-NEXT:    btl %eax, %ecx140; X86-NEXT:    setae %al141; X86-NEXT:    retl142;143; X64-LABEL: scalar_i16_lowestbit_eq:144; X64:       # %bb.0:145; X64-NEXT:    btl %esi, %edi146; X64-NEXT:    setae %al147; X64-NEXT:    retq148  %t0 = shl i16 1, %y149  %t1 = and i16 %t0, %x150  %res = icmp eq i16 %t1, 0151  ret i1 %res152}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:    movzbl {{[0-9]+}}(%esp), %ecx158; X86-BMI1-NEXT:    movzwl {{[0-9]+}}(%esp), %eax159; X86-BMI1-NEXT:    shrl %cl, %eax160; X86-BMI1-NEXT:    testl $4080, %eax # imm = 0xFF0161; X86-BMI1-NEXT:    sete %al162; X86-BMI1-NEXT:    retl163;164; X86-BMI2-LABEL: scalar_i16_bitsinmiddle_eq:165; X86-BMI2:       # %bb.0:166; X86-BMI2-NEXT:    movzwl {{[0-9]+}}(%esp), %eax167; X86-BMI2-NEXT:    movzbl {{[0-9]+}}(%esp), %ecx168; X86-BMI2-NEXT:    shrxl %ecx, %eax, %eax169; X86-BMI2-NEXT:    testl $4080, %eax # imm = 0xFF0170; X86-BMI2-NEXT:    sete %al171; X86-BMI2-NEXT:    retl172;173; X64-BMI1-LABEL: scalar_i16_bitsinmiddle_eq:174; X64-BMI1:       # %bb.0:175; X64-BMI1-NEXT:    movl %esi, %ecx176; X64-BMI1-NEXT:    movzwl %di, %eax177; X64-BMI1-NEXT:    # kill: def $cl killed $cl killed $ecx178; X64-BMI1-NEXT:    shrl %cl, %eax179; X64-BMI1-NEXT:    testl $4080, %eax # imm = 0xFF0180; X64-BMI1-NEXT:    sete %al181; X64-BMI1-NEXT:    retq182;183; X64-BMI2-LABEL: scalar_i16_bitsinmiddle_eq:184; X64-BMI2:       # %bb.0:185; X64-BMI2-NEXT:    movzwl %di, %eax186; X64-BMI2-NEXT:    shrxl %esi, %eax, %eax187; X64-BMI2-NEXT:    testl $4080, %eax # imm = 0xFF0188; X64-BMI2-NEXT:    sete %al189; X64-BMI2-NEXT:    retq190  %t0 = shl i16 4080, %y191  %t1 = and i16 %t0, %x192  %res = icmp eq i16 %t1, 0193  ret i1 %res194}195 196; i32 scalar197 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:    movzbl {{[0-9]+}}(%esp), %ecx202; X86-BMI1-NEXT:    movl {{[0-9]+}}(%esp), %eax203; X86-BMI1-NEXT:    shrl %cl, %eax204; X86-BMI1-NEXT:    testl $-2147483648, %eax # imm = 0x80000000205; X86-BMI1-NEXT:    sete %al206; X86-BMI1-NEXT:    retl207;208; X86-BMI2-LABEL: scalar_i32_signbit_eq:209; X86-BMI2:       # %bb.0:210; X86-BMI2-NEXT:    movzbl {{[0-9]+}}(%esp), %eax211; X86-BMI2-NEXT:    shrxl %eax, {{[0-9]+}}(%esp), %eax212; X86-BMI2-NEXT:    testl $-2147483648, %eax # imm = 0x80000000213; X86-BMI2-NEXT:    sete %al214; X86-BMI2-NEXT:    retl215;216; X64-BMI1-LABEL: scalar_i32_signbit_eq:217; X64-BMI1:       # %bb.0:218; X64-BMI1-NEXT:    movl %esi, %ecx219; X64-BMI1-NEXT:    # kill: def $cl killed $cl killed $ecx220; X64-BMI1-NEXT:    shrl %cl, %edi221; X64-BMI1-NEXT:    testl $-2147483648, %edi # imm = 0x80000000222; X64-BMI1-NEXT:    sete %al223; X64-BMI1-NEXT:    retq224;225; X64-BMI2-LABEL: scalar_i32_signbit_eq:226; X64-BMI2:       # %bb.0:227; X64-BMI2-NEXT:    shrxl %esi, %edi, %eax228; X64-BMI2-NEXT:    testl $-2147483648, %eax # imm = 0x80000000229; X64-BMI2-NEXT:    sete %al230; X64-BMI2-NEXT:    retq231  %t0 = shl i32 2147483648, %y232  %t1 = and i32 %t0, %x233  %res = icmp eq i32 %t1, 0234  ret i1 %res235}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), %eax241; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx242; X86-NEXT:    btl %ecx, %eax243; X86-NEXT:    setae %al244; X86-NEXT:    retl245;246; X64-LABEL: scalar_i32_lowestbit_eq:247; X64:       # %bb.0:248; X64-NEXT:    btl %esi, %edi249; X64-NEXT:    setae %al250; X64-NEXT:    retq251  %t0 = shl i32 1, %y252  %t1 = and i32 %t0, %x253  %res = icmp eq i32 %t1, 0254  ret i1 %res255}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:    movzbl {{[0-9]+}}(%esp), %ecx261; X86-BMI1-NEXT:    movl {{[0-9]+}}(%esp), %eax262; X86-BMI1-NEXT:    shrl %cl, %eax263; X86-BMI1-NEXT:    testl $16776960, %eax # imm = 0xFFFF00264; X86-BMI1-NEXT:    sete %al265; X86-BMI1-NEXT:    retl266;267; X86-BMI2-LABEL: scalar_i32_bitsinmiddle_eq:268; X86-BMI2:       # %bb.0:269; X86-BMI2-NEXT:    movzbl {{[0-9]+}}(%esp), %eax270; X86-BMI2-NEXT:    shrxl %eax, {{[0-9]+}}(%esp), %eax271; X86-BMI2-NEXT:    testl $16776960, %eax # imm = 0xFFFF00272; X86-BMI2-NEXT:    sete %al273; X86-BMI2-NEXT:    retl274;275; X64-BMI1-LABEL: scalar_i32_bitsinmiddle_eq:276; X64-BMI1:       # %bb.0:277; X64-BMI1-NEXT:    movl %esi, %ecx278; X64-BMI1-NEXT:    # kill: def $cl killed $cl killed $ecx279; X64-BMI1-NEXT:    shrl %cl, %edi280; X64-BMI1-NEXT:    testl $16776960, %edi # imm = 0xFFFF00281; X64-BMI1-NEXT:    sete %al282; X64-BMI1-NEXT:    retq283;284; X64-BMI2-LABEL: scalar_i32_bitsinmiddle_eq:285; X64-BMI2:       # %bb.0:286; X64-BMI2-NEXT:    shrxl %esi, %edi, %eax287; X64-BMI2-NEXT:    testl $16776960, %eax # imm = 0xFFFF00288; X64-BMI2-NEXT:    sete %al289; X64-BMI2-NEXT:    retq290  %t0 = shl i32 16776960, %y291  %t1 = and i32 %t0, %x292  %res = icmp eq i32 %t1, 0293  ret i1 %res294}295 296; i64 scalar297 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:    movzbl {{[0-9]+}}(%esp), %ecx302; X86-BMI1-NEXT:    movl {{[0-9]+}}(%esp), %eax303; X86-BMI1-NEXT:    shrl %cl, %eax304; X86-BMI1-NEXT:    xorl %edx, %edx305; X86-BMI1-NEXT:    testb $32, %cl306; X86-BMI1-NEXT:    cmovel %eax, %edx307; X86-BMI1-NEXT:    testl $-2147483648, %edx # imm = 0x80000000308; X86-BMI1-NEXT:    sete %al309; X86-BMI1-NEXT:    retl310;311; X86-BMI2-LABEL: scalar_i64_signbit_eq:312; X86-BMI2:       # %bb.0:313; X86-BMI2-NEXT:    movzbl {{[0-9]+}}(%esp), %eax314; X86-BMI2-NEXT:    shrxl %eax, {{[0-9]+}}(%esp), %ecx315; X86-BMI2-NEXT:    xorl %edx, %edx316; X86-BMI2-NEXT:    testb $32, %al317; X86-BMI2-NEXT:    cmovel %ecx, %edx318; X86-BMI2-NEXT:    testl $-2147483648, %edx # imm = 0x80000000319; X86-BMI2-NEXT:    sete %al320; X86-BMI2-NEXT:    retl321;322; X64-BMI1-LABEL: scalar_i64_signbit_eq:323; X64-BMI1:       # %bb.0:324; X64-BMI1-NEXT:    movq %rsi, %rcx325; X64-BMI1-NEXT:    # kill: def $cl killed $cl killed $rcx326; X64-BMI1-NEXT:    shrq %cl, %rdi327; X64-BMI1-NEXT:    btq $63, %rdi328; X64-BMI1-NEXT:    setae %al329; X64-BMI1-NEXT:    retq330;331; X64-BMI2-LABEL: scalar_i64_signbit_eq:332; X64-BMI2:       # %bb.0:333; X64-BMI2-NEXT:    shrxq %rsi, %rdi, %rax334; X64-BMI2-NEXT:    btq $63, %rax335; X64-BMI2-NEXT:    setae %al336; X64-BMI2-NEXT:    retq337  %t0 = shl i64 9223372036854775808, %y338  %t1 = and i64 %t0, %x339  %res = icmp eq i64 %t1, 0340  ret i1 %res341}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 %esi347; X86-BMI1-NEXT:    movzbl {{[0-9]+}}(%esp), %ecx348; X86-BMI1-NEXT:    movl $1, %eax349; X86-BMI1-NEXT:    xorl %esi, %esi350; X86-BMI1-NEXT:    xorl %edx, %edx351; X86-BMI1-NEXT:    shldl %cl, %eax, %edx352; X86-BMI1-NEXT:    shll %cl, %eax353; X86-BMI1-NEXT:    testb $32, %cl354; X86-BMI1-NEXT:    cmovnel %eax, %edx355; X86-BMI1-NEXT:    cmovnel %esi, %eax356; X86-BMI1-NEXT:    andl {{[0-9]+}}(%esp), %edx357; X86-BMI1-NEXT:    andl {{[0-9]+}}(%esp), %eax358; X86-BMI1-NEXT:    orl %edx, %eax359; X86-BMI1-NEXT:    sete %al360; X86-BMI1-NEXT:    popl %esi361; X86-BMI1-NEXT:    retl362;363; X86-BMI2-LABEL: scalar_i64_lowestbit_eq:364; X86-BMI2:       # %bb.0:365; X86-BMI2-NEXT:    pushl %esi366; X86-BMI2-NEXT:    movzbl {{[0-9]+}}(%esp), %ecx367; X86-BMI2-NEXT:    movl $1, %edx368; X86-BMI2-NEXT:    xorl %esi, %esi369; X86-BMI2-NEXT:    xorl %eax, %eax370; X86-BMI2-NEXT:    shldl %cl, %edx, %eax371; X86-BMI2-NEXT:    shlxl %ecx, %edx, %edx372; X86-BMI2-NEXT:    testb $32, %cl373; X86-BMI2-NEXT:    cmovnel %edx, %eax374; X86-BMI2-NEXT:    cmovnel %esi, %edx375; X86-BMI2-NEXT:    andl {{[0-9]+}}(%esp), %eax376; X86-BMI2-NEXT:    andl {{[0-9]+}}(%esp), %edx377; X86-BMI2-NEXT:    orl %eax, %edx378; X86-BMI2-NEXT:    sete %al379; X86-BMI2-NEXT:    popl %esi380; X86-BMI2-NEXT:    retl381;382; X64-LABEL: scalar_i64_lowestbit_eq:383; X64:       # %bb.0:384; X64-NEXT:    btq %rsi, %rdi385; X64-NEXT:    setae %al386; X64-NEXT:    retq387  %t0 = shl i64 1, %y388  %t1 = and i64 %t0, %x389  %res = icmp eq i64 %t1, 0390  ret i1 %res391}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 %esi397; X86-BMI1-NEXT:    movzbl {{[0-9]+}}(%esp), %ecx398; X86-BMI1-NEXT:    movl {{[0-9]+}}(%esp), %eax399; X86-BMI1-NEXT:    movl {{[0-9]+}}(%esp), %edx400; X86-BMI1-NEXT:    movl %edx, %esi401; X86-BMI1-NEXT:    shrl %cl, %esi402; X86-BMI1-NEXT:    shrdl %cl, %edx, %eax403; X86-BMI1-NEXT:    xorl %edx, %edx404; X86-BMI1-NEXT:    testb $32, %cl405; X86-BMI1-NEXT:    cmovnel %esi, %eax406; X86-BMI1-NEXT:    cmovel %esi, %edx407; X86-BMI1-NEXT:    andl $-65536, %eax # imm = 0xFFFF0000408; X86-BMI1-NEXT:    movzwl %dx, %ecx409; X86-BMI1-NEXT:    orl %eax, %ecx410; X86-BMI1-NEXT:    sete %al411; X86-BMI1-NEXT:    popl %esi412; X86-BMI1-NEXT:    retl413;414; X86-BMI2-LABEL: scalar_i64_bitsinmiddle_eq:415; X86-BMI2:       # %bb.0:416; X86-BMI2-NEXT:    pushl %esi417; X86-BMI2-NEXT:    movzbl {{[0-9]+}}(%esp), %ecx418; X86-BMI2-NEXT:    movl {{[0-9]+}}(%esp), %eax419; X86-BMI2-NEXT:    movl {{[0-9]+}}(%esp), %edx420; X86-BMI2-NEXT:    shrdl %cl, %edx, %eax421; X86-BMI2-NEXT:    shrxl %ecx, %edx, %edx422; X86-BMI2-NEXT:    xorl %esi, %esi423; X86-BMI2-NEXT:    testb $32, %cl424; X86-BMI2-NEXT:    cmovnel %edx, %eax425; X86-BMI2-NEXT:    cmovel %edx, %esi426; X86-BMI2-NEXT:    andl $-65536, %eax # imm = 0xFFFF0000427; X86-BMI2-NEXT:    movzwl %si, %ecx428; X86-BMI2-NEXT:    orl %eax, %ecx429; X86-BMI2-NEXT:    sete %al430; X86-BMI2-NEXT:    popl %esi431; X86-BMI2-NEXT:    retl432;433; X64-BMI1-LABEL: scalar_i64_bitsinmiddle_eq:434; X64-BMI1:       # %bb.0:435; X64-BMI1-NEXT:    movq %rsi, %rcx436; X64-BMI1-NEXT:    # kill: def $cl killed $cl killed $rcx437; X64-BMI1-NEXT:    shrq %cl, %rdi438; X64-BMI1-NEXT:    shrq $16, %rdi439; X64-BMI1-NEXT:    testl %edi, %edi440; X64-BMI1-NEXT:    sete %al441; X64-BMI1-NEXT:    retq442;443; X64-BMI2-LABEL: scalar_i64_bitsinmiddle_eq:444; X64-BMI2:       # %bb.0:445; X64-BMI2-NEXT:    shrxq %rsi, %rdi, %rax446; X64-BMI2-NEXT:    shrq $16, %rax447; X64-BMI2-NEXT:    testl %eax, %eax448; X64-BMI2-NEXT:    sete %al449; X64-BMI2-NEXT:    retq450  %t0 = shl i64 281474976645120, %y451  %t1 = and i64 %t0, %x452  %res = icmp eq i64 %t1, 0453  ret i1 %res454}455 456;------------------------------------------------------------------------------;457; A few trivial vector tests458;------------------------------------------------------------------------------;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, %xmm1464; X86-SSE2-NEXT:    paddd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm1465; X86-SSE2-NEXT:    cvttps2dq %xmm1, %xmm1466; X86-SSE2-NEXT:    pand %xmm1, %xmm0467; X86-SSE2-NEXT:    pxor %xmm1, %xmm1468; X86-SSE2-NEXT:    pcmpeqd %xmm1, %xmm0469; X86-SSE2-NEXT:    retl470;471; AVX2-LABEL: vec_4xi32_splat_eq:472; AVX2:       # %bb.0:473; AVX2-NEXT:    vpbroadcastd {{.*#+}} xmm2 = [1,1,1,1]474; AVX2-NEXT:    vpxor %xmm3, %xmm3, %xmm3475; AVX2-NEXT:    vpsrlvd %xmm1, %xmm0, %xmm0476; AVX2-NEXT:    vpand %xmm2, %xmm0, %xmm0477; AVX2-NEXT:    vpcmpeqd %xmm3, %xmm0, %xmm0478; AVX2-NEXT:    ret{{[l|q]}}479;480; X64-SSE2-LABEL: vec_4xi32_splat_eq:481; X64-SSE2:       # %bb.0:482; X64-SSE2-NEXT:    pslld $23, %xmm1483; X64-SSE2-NEXT:    paddd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1484; X64-SSE2-NEXT:    cvttps2dq %xmm1, %xmm1485; X64-SSE2-NEXT:    pand %xmm1, %xmm0486; X64-SSE2-NEXT:    pxor %xmm1, %xmm1487; X64-SSE2-NEXT:    pcmpeqd %xmm1, %xmm0488; X64-SSE2-NEXT:    retq489  %t0 = shl <4 x i32> <i32 1, i32 1, i32 1, i32 1>, %y490  %t1 = and <4 x i32> %t0, %x491  %res = icmp eq <4 x i32> %t1, <i32 0, i32 0, i32 0, i32 0>492  ret <4 x i1> %res493}494 495define <4 x i1> @vec_4xi32_nonsplat_eq(<4 x i32> %x, <4 x i32> %y) nounwind {496; X86-SSE2-LABEL: vec_4xi32_nonsplat_eq:497; X86-SSE2:       # %bb.0:498; X86-SSE2-NEXT:    pslld $23, %xmm1499; X86-SSE2-NEXT:    paddd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm1500; X86-SSE2-NEXT:    cvttps2dq %xmm1, %xmm1501; X86-SSE2-NEXT:    pshufd {{.*#+}} xmm2 = xmm1[1,1,3,3]502; X86-SSE2-NEXT:    pmuludq {{\.?LCPI[0-9]+_[0-9]+}}, %xmm1 # [0,1,16776960,2147483648]503; X86-SSE2-NEXT:    pshufd {{.*#+}} xmm1 = xmm1[0,2,2,3]504; X86-SSE2-NEXT:    pmuludq {{\.?LCPI[0-9]+_[0-9]+}}, %xmm2 # [1,u,2147483648,u]505; X86-SSE2-NEXT:    pshufd {{.*#+}} xmm2 = xmm2[0,2,2,3]506; X86-SSE2-NEXT:    punpckldq {{.*#+}} xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]507; X86-SSE2-NEXT:    pand %xmm1, %xmm0508; X86-SSE2-NEXT:    pxor %xmm1, %xmm1509; X86-SSE2-NEXT:    pcmpeqd %xmm1, %xmm0510; X86-SSE2-NEXT:    retl511;512; AVX2-LABEL: vec_4xi32_nonsplat_eq:513; AVX2:       # %bb.0:514; AVX2-NEXT:    vmovdqa {{.*#+}} xmm2 = [0,1,16776960,2147483648]515; AVX2-NEXT:    vpsllvd %xmm1, %xmm2, %xmm1516; AVX2-NEXT:    vpand %xmm0, %xmm1, %xmm0517; AVX2-NEXT:    vpxor %xmm1, %xmm1, %xmm1518; AVX2-NEXT:    vpcmpeqd %xmm1, %xmm0, %xmm0519; AVX2-NEXT:    ret{{[l|q]}}520;521; X64-SSE2-LABEL: vec_4xi32_nonsplat_eq:522; X64-SSE2:       # %bb.0:523; X64-SSE2-NEXT:    pslld $23, %xmm1524; X64-SSE2-NEXT:    paddd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1525; X64-SSE2-NEXT:    cvttps2dq %xmm1, %xmm1526; X64-SSE2-NEXT:    pshufd {{.*#+}} xmm2 = xmm1[1,1,3,3]527; X64-SSE2-NEXT:    pmuludq {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1 # [0,1,16776960,2147483648]528; X64-SSE2-NEXT:    pshufd {{.*#+}} xmm1 = xmm1[0,2,2,3]529; X64-SSE2-NEXT:    pmuludq {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm2 # [1,u,2147483648,u]530; X64-SSE2-NEXT:    pshufd {{.*#+}} xmm2 = xmm2[0,2,2,3]531; X64-SSE2-NEXT:    punpckldq {{.*#+}} xmm1 = xmm1[0],xmm2[0],xmm1[1],xmm2[1]532; X64-SSE2-NEXT:    pand %xmm1, %xmm0533; X64-SSE2-NEXT:    pxor %xmm1, %xmm1534; X64-SSE2-NEXT:    pcmpeqd %xmm1, %xmm0535; X64-SSE2-NEXT:    retq536  %t0 = shl <4 x i32> <i32 0, i32 1, i32 16776960, i32 2147483648>, %y537  %t1 = and <4 x i32> %t0, %x538  %res = icmp eq <4 x i32> %t1, <i32 0, i32 0, i32 0, i32 0>539  ret <4 x i1> %res540}541 542define <4 x i1> @vec_4xi32_nonsplat_undef0_eq(<4 x i32> %x, <4 x i32> %y) nounwind {543; X86-SSE2-LABEL: vec_4xi32_nonsplat_undef0_eq:544; X86-SSE2:       # %bb.0:545; X86-SSE2-NEXT:    movl $1, %eax546; X86-SSE2-NEXT:    movd %eax, %xmm2547; X86-SSE2-NEXT:    pslld $23, %xmm1548; X86-SSE2-NEXT:    paddd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm1549; X86-SSE2-NEXT:    cvttps2dq %xmm1, %xmm1550; X86-SSE2-NEXT:    pmuludq %xmm1, %xmm2551; X86-SSE2-NEXT:    pshufd {{.*#+}} xmm2 = xmm2[0,2,2,3]552; X86-SSE2-NEXT:    pshufd {{.*#+}} xmm1 = xmm1[1,3,2,3]553; X86-SSE2-NEXT:    punpckldq {{.*#+}} xmm2 = xmm2[0],xmm1[0],xmm2[1],xmm1[1]554; X86-SSE2-NEXT:    pand %xmm2, %xmm0555; X86-SSE2-NEXT:    pxor %xmm1, %xmm1556; X86-SSE2-NEXT:    pcmpeqd %xmm1, %xmm0557; X86-SSE2-NEXT:    retl558;559; AVX2-LABEL: vec_4xi32_nonsplat_undef0_eq:560; AVX2:       # %bb.0:561; AVX2-NEXT:    vpbroadcastd {{.*#+}} xmm2 = [1,1,1,1]562; AVX2-NEXT:    vpxor %xmm3, %xmm3, %xmm3563; AVX2-NEXT:    vpsrlvd %xmm1, %xmm0, %xmm0564; AVX2-NEXT:    vpand %xmm2, %xmm0, %xmm0565; AVX2-NEXT:    vpcmpeqd %xmm3, %xmm0, %xmm0566; AVX2-NEXT:    ret{{[l|q]}}567;568; X64-SSE2-LABEL: vec_4xi32_nonsplat_undef0_eq:569; X64-SSE2:       # %bb.0:570; X64-SSE2-NEXT:    movl $1, %eax571; X64-SSE2-NEXT:    movd %eax, %xmm2572; X64-SSE2-NEXT:    pslld $23, %xmm1573; X64-SSE2-NEXT:    paddd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1574; X64-SSE2-NEXT:    cvttps2dq %xmm1, %xmm1575; X64-SSE2-NEXT:    pmuludq %xmm1, %xmm2576; X64-SSE2-NEXT:    pshufd {{.*#+}} xmm2 = xmm2[0,2,2,3]577; X64-SSE2-NEXT:    pshufd {{.*#+}} xmm1 = xmm1[1,3,2,3]578; X64-SSE2-NEXT:    punpckldq {{.*#+}} xmm2 = xmm2[0],xmm1[0],xmm2[1],xmm1[1]579; X64-SSE2-NEXT:    pand %xmm2, %xmm0580; X64-SSE2-NEXT:    pxor %xmm1, %xmm1581; X64-SSE2-NEXT:    pcmpeqd %xmm1, %xmm0582; X64-SSE2-NEXT:    retq583  %t0 = shl <4 x i32> <i32 1, i32 1, i32 undef, i32 1>, %y584  %t1 = and <4 x i32> %t0, %x585  %res = icmp eq <4 x i32> %t1, <i32 0, i32 0, i32 0, i32 0>586  ret <4 x i1> %res587}588define <4 x i1> @vec_4xi32_nonsplat_undef1_eq(<4 x i32> %x, <4 x i32> %y) nounwind {589; X86-SSE2-LABEL: vec_4xi32_nonsplat_undef1_eq:590; X86-SSE2:       # %bb.0:591; X86-SSE2-NEXT:    pslld $23, %xmm1592; X86-SSE2-NEXT:    paddd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm1593; X86-SSE2-NEXT:    cvttps2dq %xmm1, %xmm1594; X86-SSE2-NEXT:    pand %xmm1, %xmm0595; X86-SSE2-NEXT:    pxor %xmm1, %xmm1596; X86-SSE2-NEXT:    pcmpeqd %xmm1, %xmm0597; X86-SSE2-NEXT:    retl598;599; AVX2-LABEL: vec_4xi32_nonsplat_undef1_eq:600; AVX2:       # %bb.0:601; AVX2-NEXT:    vpbroadcastd {{.*#+}} xmm2 = [1,1,1,1]602; AVX2-NEXT:    vpsllvd %xmm1, %xmm2, %xmm1603; AVX2-NEXT:    vpand %xmm0, %xmm1, %xmm0604; AVX2-NEXT:    vpxor %xmm1, %xmm1, %xmm1605; AVX2-NEXT:    vpcmpeqd %xmm1, %xmm0, %xmm0606; AVX2-NEXT:    ret{{[l|q]}}607;608; X64-SSE2-LABEL: vec_4xi32_nonsplat_undef1_eq:609; X64-SSE2:       # %bb.0:610; X64-SSE2-NEXT:    pslld $23, %xmm1611; X64-SSE2-NEXT:    paddd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1612; X64-SSE2-NEXT:    cvttps2dq %xmm1, %xmm1613; X64-SSE2-NEXT:    pand %xmm1, %xmm0614; X64-SSE2-NEXT:    pxor %xmm1, %xmm1615; X64-SSE2-NEXT:    pcmpeqd %xmm1, %xmm0616; X64-SSE2-NEXT:    retq617  %t0 = shl <4 x i32> <i32 1, i32 1, i32 1, i32 1>, %y618  %t1 = and <4 x i32> %t0, %x619  %res = icmp eq <4 x i32> %t1, <i32 0, i32 0, i32 undef, i32 0>620  ret <4 x i1> %res621}622define <4 x i1> @vec_4xi32_nonsplat_undef2_eq(<4 x i32> %x, <4 x i32> %y) nounwind {623; X86-SSE2-LABEL: vec_4xi32_nonsplat_undef2_eq:624; X86-SSE2:       # %bb.0:625; X86-SSE2-NEXT:    movl $1, %eax626; X86-SSE2-NEXT:    movd %eax, %xmm2627; X86-SSE2-NEXT:    pslld $23, %xmm1628; X86-SSE2-NEXT:    paddd {{\.?LCPI[0-9]+_[0-9]+}}, %xmm1629; X86-SSE2-NEXT:    cvttps2dq %xmm1, %xmm1630; X86-SSE2-NEXT:    pmuludq %xmm1, %xmm2631; X86-SSE2-NEXT:    pshufd {{.*#+}} xmm2 = xmm2[0,2,2,3]632; X86-SSE2-NEXT:    pshufd {{.*#+}} xmm1 = xmm1[1,3,2,3]633; X86-SSE2-NEXT:    punpckldq {{.*#+}} xmm2 = xmm2[0],xmm1[0],xmm2[1],xmm1[1]634; X86-SSE2-NEXT:    pand %xmm2, %xmm0635; X86-SSE2-NEXT:    pxor %xmm1, %xmm1636; X86-SSE2-NEXT:    pcmpeqd %xmm1, %xmm0637; X86-SSE2-NEXT:    retl638;639; AVX2-LABEL: vec_4xi32_nonsplat_undef2_eq:640; AVX2:       # %bb.0:641; AVX2-NEXT:    vpbroadcastd {{.*#+}} xmm2 = [1,1,1,1]642; AVX2-NEXT:    vpsllvd %xmm1, %xmm2, %xmm1643; AVX2-NEXT:    vpand %xmm0, %xmm1, %xmm0644; AVX2-NEXT:    vpxor %xmm1, %xmm1, %xmm1645; AVX2-NEXT:    vpcmpeqd %xmm1, %xmm0, %xmm0646; AVX2-NEXT:    ret{{[l|q]}}647;648; X64-SSE2-LABEL: vec_4xi32_nonsplat_undef2_eq:649; X64-SSE2:       # %bb.0:650; X64-SSE2-NEXT:    movl $1, %eax651; X64-SSE2-NEXT:    movd %eax, %xmm2652; X64-SSE2-NEXT:    pslld $23, %xmm1653; X64-SSE2-NEXT:    paddd {{\.?LCPI[0-9]+_[0-9]+}}(%rip), %xmm1654; X64-SSE2-NEXT:    cvttps2dq %xmm1, %xmm1655; X64-SSE2-NEXT:    pmuludq %xmm1, %xmm2656; X64-SSE2-NEXT:    pshufd {{.*#+}} xmm2 = xmm2[0,2,2,3]657; X64-SSE2-NEXT:    pshufd {{.*#+}} xmm1 = xmm1[1,3,2,3]658; X64-SSE2-NEXT:    punpckldq {{.*#+}} xmm2 = xmm2[0],xmm1[0],xmm2[1],xmm1[1]659; X64-SSE2-NEXT:    pand %xmm2, %xmm0660; X64-SSE2-NEXT:    pxor %xmm1, %xmm1661; X64-SSE2-NEXT:    pcmpeqd %xmm1, %xmm0662; X64-SSE2-NEXT:    retq663  %t0 = shl <4 x i32> <i32 1, i32 1, i32 undef, i32 1>, %y664  %t1 = and <4 x i32> %t0, %x665  %res = icmp eq <4 x i32> %t1, <i32 0, i32 0, i32 undef, i32 0>666  ret <4 x i1> %res667}668 669;------------------------------------------------------------------------------;670; A special tests671;------------------------------------------------------------------------------;672 673define i1 @scalar_i8_signbit_ne(i8 %x, i8 %y) nounwind {674; X86-LABEL: scalar_i8_signbit_ne:675; X86:       # %bb.0:676; X86-NEXT:    movzbl {{[0-9]+}}(%esp), %ecx677; X86-NEXT:    movzbl {{[0-9]+}}(%esp), %eax678; X86-NEXT:    shrb %cl, %al679; X86-NEXT:    shrb $7, %al680; X86-NEXT:    retl681;682; X64-LABEL: scalar_i8_signbit_ne:683; X64:       # %bb.0:684; X64-NEXT:    movl %esi, %ecx685; X64-NEXT:    movl %edi, %eax686; X64-NEXT:    # kill: def $cl killed $cl killed $ecx687; X64-NEXT:    shrb %cl, %al688; X64-NEXT:    shrb $7, %al689; X64-NEXT:    # kill: def $al killed $al killed $eax690; X64-NEXT:    retq691  %t0 = shl i8 128, %y692  %t1 = and i8 %t0, %x693  %res = icmp ne i8 %t1, 0 ;  we are perfectly happy with 'ne' predicate694  ret i1 %res695}696 697;------------------------------------------------------------------------------;698; What if X is a constant too?699;------------------------------------------------------------------------------;700 701define i1 @scalar_i32_x_is_const_eq(i32 %y) nounwind {702; X86-BMI1-LABEL: scalar_i32_x_is_const_eq:703; X86-BMI1:       # %bb.0:704; X86-BMI1-NEXT:    movzbl {{[0-9]+}}(%esp), %ecx705; X86-BMI1-NEXT:    movl $-1437226411, %eax # imm = 0xAA55AA55706; X86-BMI1-NEXT:    shll %cl, %eax707; X86-BMI1-NEXT:    testb $1, %al708; X86-BMI1-NEXT:    sete %al709; X86-BMI1-NEXT:    retl710;711; X86-BMI2-LABEL: scalar_i32_x_is_const_eq:712; X86-BMI2:       # %bb.0:713; X86-BMI2-NEXT:    movzbl {{[0-9]+}}(%esp), %eax714; X86-BMI2-NEXT:    movl $-1437226411, %ecx # imm = 0xAA55AA55715; X86-BMI2-NEXT:    shlxl %eax, %ecx, %eax716; X86-BMI2-NEXT:    testb $1, %al717; X86-BMI2-NEXT:    sete %al718; X86-BMI2-NEXT:    retl719;720; X64-BMI1-LABEL: scalar_i32_x_is_const_eq:721; X64-BMI1:       # %bb.0:722; X64-BMI1-NEXT:    movl %edi, %ecx723; X64-BMI1-NEXT:    movl $-1437226411, %eax # imm = 0xAA55AA55724; X64-BMI1-NEXT:    # kill: def $cl killed $cl killed $ecx725; X64-BMI1-NEXT:    shll %cl, %eax726; X64-BMI1-NEXT:    testb $1, %al727; X64-BMI1-NEXT:    sete %al728; X64-BMI1-NEXT:    retq729;730; X64-BMI2-LABEL: scalar_i32_x_is_const_eq:731; X64-BMI2:       # %bb.0:732; X64-BMI2-NEXT:    movl $-1437226411, %eax # imm = 0xAA55AA55733; X64-BMI2-NEXT:    shlxl %edi, %eax, %eax734; X64-BMI2-NEXT:    testb $1, %al735; X64-BMI2-NEXT:    sete %al736; X64-BMI2-NEXT:    retq737  %t0 = shl i32 2857740885, %y738  %t1 = and i32 %t0, 1739  %res = icmp eq i32 %t1, 0740  ret i1 %res741}742define i1 @scalar_i32_x_is_const2_eq(i32 %y) nounwind {743; X86-LABEL: scalar_i32_x_is_const2_eq:744; X86:       # %bb.0:745; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax746; X86-NEXT:    movl $-1437226411, %ecx # imm = 0xAA55AA55747; X86-NEXT:    btl %eax, %ecx748; X86-NEXT:    setae %al749; X86-NEXT:    retl750;751; X64-LABEL: scalar_i32_x_is_const2_eq:752; X64:       # %bb.0:753; X64-NEXT:    movl $-1437226411, %eax # imm = 0xAA55AA55754; X64-NEXT:    btl %edi, %eax755; X64-NEXT:    setae %al756; X64-NEXT:    retq757  %t0 = shl i32 1, %y758  %t1 = and i32 %t0, 2857740885759  %res = icmp eq i32 %t1, 0760  ret i1 %res761}762 763;------------------------------------------------------------------------------;764; A few negative tests765;------------------------------------------------------------------------------;766 767define i1 @negative_scalar_i8_bitsinmiddle_slt(i8 %x, i8 %y) nounwind {768; X86-LABEL: negative_scalar_i8_bitsinmiddle_slt:769; X86:       # %bb.0:770; X86-NEXT:    movzbl {{[0-9]+}}(%esp), %ecx771; X86-NEXT:    movb $24, %al772; X86-NEXT:    shlb %cl, %al773; X86-NEXT:    andb {{[0-9]+}}(%esp), %al774; X86-NEXT:    shrb $7, %al775; X86-NEXT:    retl776;777; X64-LABEL: negative_scalar_i8_bitsinmiddle_slt:778; X64:       # %bb.0:779; X64-NEXT:    movl %esi, %ecx780; X64-NEXT:    movb $24, %al781; X64-NEXT:    # kill: def $cl killed $cl killed $ecx782; X64-NEXT:    shlb %cl, %al783; X64-NEXT:    andb %dil, %al784; X64-NEXT:    shrb $7, %al785; X64-NEXT:    retq786  %t0 = shl i8 24, %y787  %t1 = and i8 %t0, %x788  %res = icmp slt i8 %t1, 0789  ret i1 %res790}791 792define i1 @scalar_i8_signbit_eq_with_nonzero(i8 %x, i8 %y) nounwind {793; X86-LABEL: scalar_i8_signbit_eq_with_nonzero:794; X86:       # %bb.0:795; X86-NEXT:    movzbl {{[0-9]+}}(%esp), %ecx796; X86-NEXT:    movb $-128, %al797; X86-NEXT:    shlb %cl, %al798; X86-NEXT:    andb {{[0-9]+}}(%esp), %al799; X86-NEXT:    cmpb $1, %al800; X86-NEXT:    sete %al801; X86-NEXT:    retl802;803; X64-LABEL: scalar_i8_signbit_eq_with_nonzero:804; X64:       # %bb.0:805; X64-NEXT:    movl %esi, %ecx806; X64-NEXT:    movb $-128, %al807; X64-NEXT:    # kill: def $cl killed $cl killed $ecx808; X64-NEXT:    shlb %cl, %al809; X64-NEXT:    andb %dil, %al810; X64-NEXT:    cmpb $1, %al811; X64-NEXT:    sete %al812; X64-NEXT:    retq813  %t0 = shl i8 128, %y814  %t1 = and i8 %t0, %x815  %res = icmp eq i8 %t1, 1 ; should be comparing with 0816  ret i1 %res817}818