brintos

brintos / llvm-project-archived public Read only

0
0
Text · 20.0 KiB · 31a7f11 Raw
671 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=-popcnt | FileCheck %s --check-prefixes=X86,X86-NOPOPCNT3; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=-popcnt | FileCheck %s --check-prefixes=X64,X64-NOPOPCNT4; RUN: llc < %s -mtriple=i686-unknown-unknown -mattr=+popcnt | FileCheck %s --check-prefixes=X86,X86-POPCNT5; RUN: llc < %s -mtriple=x86_64-unknown-unknown -mattr=+popcnt | FileCheck %s --check-prefixes=X64,X64-POPCNT6 7define i4 @parity_4(i4 %x) {8; X86-LABEL: parity_4:9; X86:       # %bb.0:10; X86-NEXT:    testb $15, {{[0-9]+}}(%esp)11; X86-NEXT:    setnp %al12; X86-NEXT:    retl13;14; X64-LABEL: parity_4:15; X64:       # %bb.0:16; X64-NEXT:    testb $15, %dil17; X64-NEXT:    setnp %al18; X64-NEXT:    retq19  %1 = tail call i4 @llvm.ctpop.i4(i4 %x)20  %2 = and i4 %1, 121  ret i4 %222}23 24define i8 @parity_8(i8 %x) {25; X86-LABEL: parity_8:26; X86:       # %bb.0:27; X86-NEXT:    cmpb $0, {{[0-9]+}}(%esp)28; X86-NEXT:    setnp %al29; X86-NEXT:    retl30;31; X64-LABEL: parity_8:32; X64:       # %bb.0:33; X64-NEXT:    testb %dil, %dil34; X64-NEXT:    setnp %al35; X64-NEXT:    retq36  %1 = tail call i8 @llvm.ctpop.i8(i8 %x)37  %2 = and i8 %1, 138  ret i8 %239}40 41define i16 @parity_16(i16 %x) {42; X86-NOPOPCNT-LABEL: parity_16:43; X86-NOPOPCNT:       # %bb.0:44; X86-NOPOPCNT-NEXT:    movl {{[0-9]+}}(%esp), %ecx45; X86-NOPOPCNT-NEXT:    xorl %eax, %eax46; X86-NOPOPCNT-NEXT:    xorb %ch, %cl47; X86-NOPOPCNT-NEXT:    setnp %al48; X86-NOPOPCNT-NEXT:    # kill: def $ax killed $ax killed $eax49; X86-NOPOPCNT-NEXT:    retl50;51; X64-NOPOPCNT-LABEL: parity_16:52; X64-NOPOPCNT:       # %bb.0:53; X64-NOPOPCNT-NEXT:    movl %edi, %ecx54; X64-NOPOPCNT-NEXT:    xorl %eax, %eax55; X64-NOPOPCNT-NEXT:    xorb %ch, %cl56; X64-NOPOPCNT-NEXT:    setnp %al57; X64-NOPOPCNT-NEXT:    # kill: def $ax killed $ax killed $eax58; X64-NOPOPCNT-NEXT:    retq59;60; X86-POPCNT-LABEL: parity_16:61; X86-POPCNT:       # %bb.0:62; X86-POPCNT-NEXT:    movzwl {{[0-9]+}}(%esp), %eax63; X86-POPCNT-NEXT:    popcntl %eax, %eax64; X86-POPCNT-NEXT:    andl $1, %eax65; X86-POPCNT-NEXT:    # kill: def $ax killed $ax killed $eax66; X86-POPCNT-NEXT:    retl67;68; X64-POPCNT-LABEL: parity_16:69; X64-POPCNT:       # %bb.0:70; X64-POPCNT-NEXT:    movzwl %di, %eax71; X64-POPCNT-NEXT:    popcntl %eax, %eax72; X64-POPCNT-NEXT:    andl $1, %eax73; X64-POPCNT-NEXT:    # kill: def $ax killed $ax killed $eax74; X64-POPCNT-NEXT:    retq75  %1 = tail call i16 @llvm.ctpop.i16(i16 %x)76  %2 = and i16 %1, 177  ret i16 %278}79 80define i16 @parity_16_load(ptr %x) {81; X86-NOPOPCNT-LABEL: parity_16_load:82; X86-NOPOPCNT:       # %bb.0:83; X86-NOPOPCNT-NEXT:    movl {{[0-9]+}}(%esp), %eax84; X86-NOPOPCNT-NEXT:    movzwl (%eax), %ecx85; X86-NOPOPCNT-NEXT:    xorl %eax, %eax86; X86-NOPOPCNT-NEXT:    xorb %ch, %cl87; X86-NOPOPCNT-NEXT:    setnp %al88; X86-NOPOPCNT-NEXT:    # kill: def $ax killed $ax killed $eax89; X86-NOPOPCNT-NEXT:    retl90;91; X64-NOPOPCNT-LABEL: parity_16_load:92; X64-NOPOPCNT:       # %bb.0:93; X64-NOPOPCNT-NEXT:    movzwl (%rdi), %ecx94; X64-NOPOPCNT-NEXT:    xorl %eax, %eax95; X64-NOPOPCNT-NEXT:    xorb %ch, %cl96; X64-NOPOPCNT-NEXT:    setnp %al97; X64-NOPOPCNT-NEXT:    # kill: def $ax killed $ax killed $eax98; X64-NOPOPCNT-NEXT:    retq99;100; X86-POPCNT-LABEL: parity_16_load:101; X86-POPCNT:       # %bb.0:102; X86-POPCNT-NEXT:    movl {{[0-9]+}}(%esp), %eax103; X86-POPCNT-NEXT:    movzwl (%eax), %eax104; X86-POPCNT-NEXT:    popcntl %eax, %eax105; X86-POPCNT-NEXT:    andl $1, %eax106; X86-POPCNT-NEXT:    # kill: def $ax killed $ax killed $eax107; X86-POPCNT-NEXT:    retl108;109; X64-POPCNT-LABEL: parity_16_load:110; X64-POPCNT:       # %bb.0:111; X64-POPCNT-NEXT:    movzwl (%rdi), %eax112; X64-POPCNT-NEXT:    popcntl %eax, %eax113; X64-POPCNT-NEXT:    andl $1, %eax114; X64-POPCNT-NEXT:    # kill: def $ax killed $ax killed $eax115; X64-POPCNT-NEXT:    retq116  %1 = load i16, ptr %x117  %2 = tail call i16 @llvm.ctpop.i16(i16 %1)118  %3 = and i16 %2, 1119  ret i16 %3120}121 122define i17 @parity_17(i17 %x) {123; X86-NOPOPCNT-LABEL: parity_17:124; X86-NOPOPCNT:       # %bb.0:125; X86-NOPOPCNT-NEXT:    movl {{[0-9]+}}(%esp), %ecx126; X86-NOPOPCNT-NEXT:    movl %ecx, %eax127; X86-NOPOPCNT-NEXT:    andl $131071, %eax # imm = 0x1FFFF128; X86-NOPOPCNT-NEXT:    movl %eax, %edx129; X86-NOPOPCNT-NEXT:    shrl $16, %edx130; X86-NOPOPCNT-NEXT:    xorl %eax, %edx131; X86-NOPOPCNT-NEXT:    xorl %eax, %eax132; X86-NOPOPCNT-NEXT:    xorb %dl, %ch133; X86-NOPOPCNT-NEXT:    setnp %al134; X86-NOPOPCNT-NEXT:    retl135;136; X64-NOPOPCNT-LABEL: parity_17:137; X64-NOPOPCNT:       # %bb.0:138; X64-NOPOPCNT-NEXT:    movl %edi, %eax139; X64-NOPOPCNT-NEXT:    andl $131071, %eax # imm = 0x1FFFF140; X64-NOPOPCNT-NEXT:    movl %eax, %ecx141; X64-NOPOPCNT-NEXT:    shrl $16, %ecx142; X64-NOPOPCNT-NEXT:    xorl %eax, %ecx143; X64-NOPOPCNT-NEXT:    shrl $8, %edi144; X64-NOPOPCNT-NEXT:    xorl %eax, %eax145; X64-NOPOPCNT-NEXT:    xorb %cl, %dil146; X64-NOPOPCNT-NEXT:    setnp %al147; X64-NOPOPCNT-NEXT:    retq148;149; X86-POPCNT-LABEL: parity_17:150; X86-POPCNT:       # %bb.0:151; X86-POPCNT-NEXT:    movl $131071, %eax # imm = 0x1FFFF152; X86-POPCNT-NEXT:    andl {{[0-9]+}}(%esp), %eax153; X86-POPCNT-NEXT:    popcntl %eax, %eax154; X86-POPCNT-NEXT:    andl $1, %eax155; X86-POPCNT-NEXT:    retl156;157; X64-POPCNT-LABEL: parity_17:158; X64-POPCNT:       # %bb.0:159; X64-POPCNT-NEXT:    andl $131071, %edi # imm = 0x1FFFF160; X64-POPCNT-NEXT:    popcntl %edi, %eax161; X64-POPCNT-NEXT:    andl $1, %eax162; X64-POPCNT-NEXT:    retq163  %1 = tail call i17 @llvm.ctpop.i17(i17 %x)164  %2 = and i17 %1, 1165  ret i17 %2166}167 168define i32 @parity_32(i32 %x) {169; X86-NOPOPCNT-LABEL: parity_32:170; X86-NOPOPCNT:       # %bb.0:171; X86-NOPOPCNT-NEXT:    movl {{[0-9]+}}(%esp), %eax172; X86-NOPOPCNT-NEXT:    movl %eax, %ecx173; X86-NOPOPCNT-NEXT:    shrl $16, %ecx174; X86-NOPOPCNT-NEXT:    xorl %eax, %ecx175; X86-NOPOPCNT-NEXT:    xorl %eax, %eax176; X86-NOPOPCNT-NEXT:    xorb %ch, %cl177; X86-NOPOPCNT-NEXT:    setnp %al178; X86-NOPOPCNT-NEXT:    retl179;180; X64-NOPOPCNT-LABEL: parity_32:181; X64-NOPOPCNT:       # %bb.0:182; X64-NOPOPCNT-NEXT:    movl %edi, %ecx183; X64-NOPOPCNT-NEXT:    shrl $16, %ecx184; X64-NOPOPCNT-NEXT:    xorl %edi, %ecx185; X64-NOPOPCNT-NEXT:    xorl %eax, %eax186; X64-NOPOPCNT-NEXT:    xorb %ch, %cl187; X64-NOPOPCNT-NEXT:    setnp %al188; X64-NOPOPCNT-NEXT:    retq189;190; X86-POPCNT-LABEL: parity_32:191; X86-POPCNT:       # %bb.0:192; X86-POPCNT-NEXT:    popcntl {{[0-9]+}}(%esp), %eax193; X86-POPCNT-NEXT:    andl $1, %eax194; X86-POPCNT-NEXT:    retl195;196; X64-POPCNT-LABEL: parity_32:197; X64-POPCNT:       # %bb.0:198; X64-POPCNT-NEXT:    popcntl %edi, %eax199; X64-POPCNT-NEXT:    andl $1, %eax200; X64-POPCNT-NEXT:    retq201  %1 = tail call i32 @llvm.ctpop.i32(i32 %x)202  %2 = and i32 %1, 1203  ret i32 %2204}205 206define i64 @parity_64(i64 %x) {207; X86-NOPOPCNT-LABEL: parity_64:208; X86-NOPOPCNT:       # %bb.0:209; X86-NOPOPCNT-NEXT:    movl {{[0-9]+}}(%esp), %eax210; X86-NOPOPCNT-NEXT:    xorl {{[0-9]+}}(%esp), %eax211; X86-NOPOPCNT-NEXT:    movl %eax, %ecx212; X86-NOPOPCNT-NEXT:    shrl $16, %ecx213; X86-NOPOPCNT-NEXT:    xorl %eax, %ecx214; X86-NOPOPCNT-NEXT:    xorl %eax, %eax215; X86-NOPOPCNT-NEXT:    xorb %ch, %cl216; X86-NOPOPCNT-NEXT:    setnp %al217; X86-NOPOPCNT-NEXT:    xorl %edx, %edx218; X86-NOPOPCNT-NEXT:    retl219;220; X64-NOPOPCNT-LABEL: parity_64:221; X64-NOPOPCNT:       # %bb.0:222; X64-NOPOPCNT-NEXT:    movl %edi, %eax223; X64-NOPOPCNT-NEXT:    shrq $32, %rdi224; X64-NOPOPCNT-NEXT:    xorl %eax, %edi225; X64-NOPOPCNT-NEXT:    movl %edi, %ecx226; X64-NOPOPCNT-NEXT:    shrl $16, %ecx227; X64-NOPOPCNT-NEXT:    xorl %edi, %ecx228; X64-NOPOPCNT-NEXT:    xorl %eax, %eax229; X64-NOPOPCNT-NEXT:    xorb %ch, %cl230; X64-NOPOPCNT-NEXT:    setnp %al231; X64-NOPOPCNT-NEXT:    retq232;233; X86-POPCNT-LABEL: parity_64:234; X86-POPCNT:       # %bb.0:235; X86-POPCNT-NEXT:    movl {{[0-9]+}}(%esp), %eax236; X86-POPCNT-NEXT:    xorl {{[0-9]+}}(%esp), %eax237; X86-POPCNT-NEXT:    popcntl %eax, %eax238; X86-POPCNT-NEXT:    andl $1, %eax239; X86-POPCNT-NEXT:    xorl %edx, %edx240; X86-POPCNT-NEXT:    retl241;242; X64-POPCNT-LABEL: parity_64:243; X64-POPCNT:       # %bb.0:244; X64-POPCNT-NEXT:    popcntq %rdi, %rax245; X64-POPCNT-NEXT:    andl $1, %eax246; X64-POPCNT-NEXT:    retq247  %1 = tail call i64 @llvm.ctpop.i64(i64 %x)248  %2 = and i64 %1, 1249  ret i64 %2250}251 252define i32 @parity_64_trunc(i64 %x) {253; X86-NOPOPCNT-LABEL: parity_64_trunc:254; X86-NOPOPCNT:       # %bb.0:255; X86-NOPOPCNT-NEXT:    movl {{[0-9]+}}(%esp), %eax256; X86-NOPOPCNT-NEXT:    xorl {{[0-9]+}}(%esp), %eax257; X86-NOPOPCNT-NEXT:    movl %eax, %ecx258; X86-NOPOPCNT-NEXT:    shrl $16, %ecx259; X86-NOPOPCNT-NEXT:    xorl %eax, %ecx260; X86-NOPOPCNT-NEXT:    xorl %eax, %eax261; X86-NOPOPCNT-NEXT:    xorb %ch, %cl262; X86-NOPOPCNT-NEXT:    setnp %al263; X86-NOPOPCNT-NEXT:    retl264;265; X64-NOPOPCNT-LABEL: parity_64_trunc:266; X64-NOPOPCNT:       # %bb.0:267; X64-NOPOPCNT-NEXT:    movl %edi, %eax268; X64-NOPOPCNT-NEXT:    shrq $32, %rdi269; X64-NOPOPCNT-NEXT:    xorl %eax, %edi270; X64-NOPOPCNT-NEXT:    movl %edi, %ecx271; X64-NOPOPCNT-NEXT:    shrl $16, %ecx272; X64-NOPOPCNT-NEXT:    xorl %edi, %ecx273; X64-NOPOPCNT-NEXT:    xorl %eax, %eax274; X64-NOPOPCNT-NEXT:    xorb %ch, %cl275; X64-NOPOPCNT-NEXT:    setnp %al276; X64-NOPOPCNT-NEXT:    retq277;278; X86-POPCNT-LABEL: parity_64_trunc:279; X86-POPCNT:       # %bb.0:280; X86-POPCNT-NEXT:    movl {{[0-9]+}}(%esp), %eax281; X86-POPCNT-NEXT:    xorl {{[0-9]+}}(%esp), %eax282; X86-POPCNT-NEXT:    popcntl %eax, %eax283; X86-POPCNT-NEXT:    andl $1, %eax284; X86-POPCNT-NEXT:    retl285;286; X64-POPCNT-LABEL: parity_64_trunc:287; X64-POPCNT:       # %bb.0:288; X64-POPCNT-NEXT:    popcntq %rdi, %rax289; X64-POPCNT-NEXT:    andl $1, %eax290; X64-POPCNT-NEXT:    # kill: def $eax killed $eax killed $rax291; X64-POPCNT-NEXT:    retq292  %1 = tail call i64 @llvm.ctpop.i64(i64 %x)293  %2 = trunc i64 %1 to i32294  %3 = and i32 %2, 1295  ret i32 %3296}297 298define i8 @parity_32_trunc(i32 %x) {299; X86-NOPOPCNT-LABEL: parity_32_trunc:300; X86-NOPOPCNT:       # %bb.0:301; X86-NOPOPCNT-NEXT:    movl {{[0-9]+}}(%esp), %eax302; X86-NOPOPCNT-NEXT:    movl %eax, %ecx303; X86-NOPOPCNT-NEXT:    shrl $16, %ecx304; X86-NOPOPCNT-NEXT:    xorl %eax, %ecx305; X86-NOPOPCNT-NEXT:    xorb %ch, %cl306; X86-NOPOPCNT-NEXT:    setnp %al307; X86-NOPOPCNT-NEXT:    retl308;309; X64-NOPOPCNT-LABEL: parity_32_trunc:310; X64-NOPOPCNT:       # %bb.0:311; X64-NOPOPCNT-NEXT:    movl %edi, %eax312; X64-NOPOPCNT-NEXT:    shrl $16, %eax313; X64-NOPOPCNT-NEXT:    xorl %edi, %eax314; X64-NOPOPCNT-NEXT:    xorb %ah, %al315; X64-NOPOPCNT-NEXT:    setnp %al316; X64-NOPOPCNT-NEXT:    retq317;318; X86-POPCNT-LABEL: parity_32_trunc:319; X86-POPCNT:       # %bb.0:320; X86-POPCNT-NEXT:    popcntl {{[0-9]+}}(%esp), %eax321; X86-POPCNT-NEXT:    andl $1, %eax322; X86-POPCNT-NEXT:    # kill: def $al killed $al killed $eax323; X86-POPCNT-NEXT:    retl324;325; X64-POPCNT-LABEL: parity_32_trunc:326; X64-POPCNT:       # %bb.0:327; X64-POPCNT-NEXT:    popcntl %edi, %eax328; X64-POPCNT-NEXT:    andl $1, %eax329; X64-POPCNT-NEXT:    # kill: def $al killed $al killed $eax330; X64-POPCNT-NEXT:    retq331  %1 = tail call i32 @llvm.ctpop.i32(i32 %x)332  %2 = trunc i32 %1 to i8333  %3 = and i8 %2, 1334  ret i8 %3335}336 337define i16 @parity_16_zexti8(i8 %x) {338; X86-LABEL: parity_16_zexti8:339; X86:       # %bb.0:340; X86-NEXT:    xorl %eax, %eax341; X86-NEXT:    cmpb $0, {{[0-9]+}}(%esp)342; X86-NEXT:    setnp %al343; X86-NEXT:    # kill: def $ax killed $ax killed $eax344; X86-NEXT:    retl345;346; X64-LABEL: parity_16_zexti8:347; X64:       # %bb.0:348; X64-NEXT:    xorl %eax, %eax349; X64-NEXT:    testb %dil, %dil350; X64-NEXT:    setnp %al351; X64-NEXT:    # kill: def $ax killed $ax killed $eax352; X64-NEXT:    retq353  %a = zext i8 %x to i16354  %b = tail call i16 @llvm.ctpop.i16(i16 %a)355  %c = and i16 %b, 1356  ret i16 %c357}358 359define i16 @parity_16_mask255(i16 %x) {360; X86-LABEL: parity_16_mask255:361; X86:       # %bb.0:362; X86-NEXT:    xorl %eax, %eax363; X86-NEXT:    cmpb $0, {{[0-9]+}}(%esp)364; X86-NEXT:    setnp %al365; X86-NEXT:    # kill: def $ax killed $ax killed $eax366; X86-NEXT:    retl367;368; X64-LABEL: parity_16_mask255:369; X64:       # %bb.0:370; X64-NEXT:    xorl %eax, %eax371; X64-NEXT:    testb %dil, %dil372; X64-NEXT:    setnp %al373; X64-NEXT:    # kill: def $ax killed $ax killed $eax374; X64-NEXT:    retq375  %a = and i16 %x, 255376  %b = tail call i16 @llvm.ctpop.i16(i16 %a)377  %c = and i16 %b, 1378  ret i16 %c379}380 381define i16 @parity_16_mask15(i16 %x) {382; X86-LABEL: parity_16_mask15:383; X86:       # %bb.0:384; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %ecx385; X86-NEXT:    xorl %eax, %eax386; X86-NEXT:    testb $15, %cl387; X86-NEXT:    setnp %al388; X86-NEXT:    # kill: def $ax killed $ax killed $eax389; X86-NEXT:    retl390;391; X64-LABEL: parity_16_mask15:392; X64:       # %bb.0:393; X64-NEXT:    xorl %eax, %eax394; X64-NEXT:    testb $15, %dil395; X64-NEXT:    setnp %al396; X64-NEXT:    # kill: def $ax killed $ax killed $eax397; X64-NEXT:    retq398  %a = and i16 %x, 15399  %b = tail call i16 @llvm.ctpop.i16(i16 %a)400  %c = and i16 %b, 1401  ret i16 %c402}403 404define i16 @parity_16_shift(i16 %0) {405; X86-NOPOPCNT-LABEL: parity_16_shift:406; X86-NOPOPCNT:       # %bb.0:407; X86-NOPOPCNT-NEXT:    movl {{[0-9]+}}(%esp), %ecx408; X86-NOPOPCNT-NEXT:    xorl %eax, %eax409; X86-NOPOPCNT-NEXT:    xorb %ch, %cl410; X86-NOPOPCNT-NEXT:    setnp %al411; X86-NOPOPCNT-NEXT:    addl %eax, %eax412; X86-NOPOPCNT-NEXT:    # kill: def $ax killed $ax killed $eax413; X86-NOPOPCNT-NEXT:    retl414;415; X64-NOPOPCNT-LABEL: parity_16_shift:416; X64-NOPOPCNT:       # %bb.0:417; X64-NOPOPCNT-NEXT:    movl %edi, %ecx418; X64-NOPOPCNT-NEXT:    xorl %eax, %eax419; X64-NOPOPCNT-NEXT:    xorb %ch, %cl420; X64-NOPOPCNT-NEXT:    setnp %al421; X64-NOPOPCNT-NEXT:    addl %eax, %eax422; X64-NOPOPCNT-NEXT:    # kill: def $ax killed $ax killed $eax423; X64-NOPOPCNT-NEXT:    retq424;425; X86-POPCNT-LABEL: parity_16_shift:426; X86-POPCNT:       # %bb.0:427; X86-POPCNT-NEXT:    movzwl {{[0-9]+}}(%esp), %eax428; X86-POPCNT-NEXT:    popcntl %eax, %eax429; X86-POPCNT-NEXT:    andl $1, %eax430; X86-POPCNT-NEXT:    addl %eax, %eax431; X86-POPCNT-NEXT:    # kill: def $ax killed $ax killed $eax432; X86-POPCNT-NEXT:    retl433;434; X64-POPCNT-LABEL: parity_16_shift:435; X64-POPCNT:       # %bb.0:436; X64-POPCNT-NEXT:    movzwl %di, %eax437; X64-POPCNT-NEXT:    popcntl %eax, %eax438; X64-POPCNT-NEXT:    andl $1, %eax439; X64-POPCNT-NEXT:    addl %eax, %eax440; X64-POPCNT-NEXT:    # kill: def $ax killed $ax killed $eax441; X64-POPCNT-NEXT:    retq442  %2 = tail call i16 @llvm.ctpop.i16(i16 %0)443  %3 = shl nuw nsw i16 %2, 1444  %4 = and i16 %3, 2445  ret i16 %4446}447 448define i32 @parity_32_zexti8(i8 %x) {449; X86-LABEL: parity_32_zexti8:450; X86:       # %bb.0:451; X86-NEXT:    xorl %eax, %eax452; X86-NEXT:    cmpb $0, {{[0-9]+}}(%esp)453; X86-NEXT:    setnp %al454; X86-NEXT:    retl455;456; X64-LABEL: parity_32_zexti8:457; X64:       # %bb.0:458; X64-NEXT:    xorl %eax, %eax459; X64-NEXT:    testb %dil, %dil460; X64-NEXT:    setnp %al461; X64-NEXT:    retq462  %a = zext i8 %x to i32463  %b = tail call i32 @llvm.ctpop.i32(i32 %a)464  %c = and i32 %b, 1465  ret i32 %c466}467 468define i32 @parity_32_mask255(i32 %x) {469; X86-LABEL: parity_32_mask255:470; X86:       # %bb.0:471; X86-NEXT:    xorl %eax, %eax472; X86-NEXT:    cmpb $0, {{[0-9]+}}(%esp)473; X86-NEXT:    setnp %al474; X86-NEXT:    retl475;476; X64-LABEL: parity_32_mask255:477; X64:       # %bb.0:478; X64-NEXT:    xorl %eax, %eax479; X64-NEXT:    testb %dil, %dil480; X64-NEXT:    setnp %al481; X64-NEXT:    retq482  %a = and i32 %x, 255483  %b = tail call i32 @llvm.ctpop.i32(i32 %a)484  %c = and i32 %b, 1485  ret i32 %c486}487 488define i32 @parity_32_mask15(i32 %x) {489; X86-LABEL: parity_32_mask15:490; X86:       # %bb.0:491; X86-NEXT:    xorl %eax, %eax492; X86-NEXT:    testb $15, {{[0-9]+}}(%esp)493; X86-NEXT:    setnp %al494; X86-NEXT:    retl495;496; X64-LABEL: parity_32_mask15:497; X64:       # %bb.0:498; X64-NEXT:    xorl %eax, %eax499; X64-NEXT:    testb $15, %dil500; X64-NEXT:    setnp %al501; X64-NEXT:    retq502  %a = and i32 %x, 15503  %b = tail call i32 @llvm.ctpop.i32(i32 %a)504  %c = and i32 %b, 1505  ret i32 %c506}507 508define i32 @parity_32_shift(i32 %0) {509; X86-NOPOPCNT-LABEL: parity_32_shift:510; X86-NOPOPCNT:       # %bb.0:511; X86-NOPOPCNT-NEXT:    movl {{[0-9]+}}(%esp), %eax512; X86-NOPOPCNT-NEXT:    movl %eax, %ecx513; X86-NOPOPCNT-NEXT:    shrl $16, %ecx514; X86-NOPOPCNT-NEXT:    xorl %eax, %ecx515; X86-NOPOPCNT-NEXT:    xorl %eax, %eax516; X86-NOPOPCNT-NEXT:    xorb %ch, %cl517; X86-NOPOPCNT-NEXT:    setnp %al518; X86-NOPOPCNT-NEXT:    addl %eax, %eax519; X86-NOPOPCNT-NEXT:    retl520;521; X64-NOPOPCNT-LABEL: parity_32_shift:522; X64-NOPOPCNT:       # %bb.0:523; X64-NOPOPCNT-NEXT:    movl %edi, %ecx524; X64-NOPOPCNT-NEXT:    shrl $16, %ecx525; X64-NOPOPCNT-NEXT:    xorl %edi, %ecx526; X64-NOPOPCNT-NEXT:    xorl %eax, %eax527; X64-NOPOPCNT-NEXT:    xorb %ch, %cl528; X64-NOPOPCNT-NEXT:    setnp %al529; X64-NOPOPCNT-NEXT:    addl %eax, %eax530; X64-NOPOPCNT-NEXT:    retq531;532; X86-POPCNT-LABEL: parity_32_shift:533; X86-POPCNT:       # %bb.0:534; X86-POPCNT-NEXT:    popcntl {{[0-9]+}}(%esp), %eax535; X86-POPCNT-NEXT:    andl $1, %eax536; X86-POPCNT-NEXT:    addl %eax, %eax537; X86-POPCNT-NEXT:    retl538;539; X64-POPCNT-LABEL: parity_32_shift:540; X64-POPCNT:       # %bb.0:541; X64-POPCNT-NEXT:    popcntl %edi, %eax542; X64-POPCNT-NEXT:    andl $1, %eax543; X64-POPCNT-NEXT:    addl %eax, %eax544; X64-POPCNT-NEXT:    retq545  %2 = tail call i32 @llvm.ctpop.i32(i32 %0)546  %3 = shl nuw nsw i32 %2, 1547  %4 = and i32 %3, 2548  ret i32 %4549}550 551define i64 @parity_64_zexti8(i8 %x) {552; X86-LABEL: parity_64_zexti8:553; X86:       # %bb.0:554; X86-NEXT:    xorl %eax, %eax555; X86-NEXT:    cmpb $0, {{[0-9]+}}(%esp)556; X86-NEXT:    setnp %al557; X86-NEXT:    xorl %edx, %edx558; X86-NEXT:    retl559;560; X64-LABEL: parity_64_zexti8:561; X64:       # %bb.0:562; X64-NEXT:    xorl %eax, %eax563; X64-NEXT:    testb %dil, %dil564; X64-NEXT:    setnp %al565; X64-NEXT:    retq566  %a = zext i8 %x to i64567  %b = tail call i64 @llvm.ctpop.i64(i64 %a)568  %c = and i64 %b, 1569  ret i64 %c570}571 572define i64 @parity_64_mask255(i64 %x) {573; X86-LABEL: parity_64_mask255:574; X86:       # %bb.0:575; X86-NEXT:    xorl %eax, %eax576; X86-NEXT:    cmpb $0, {{[0-9]+}}(%esp)577; X86-NEXT:    setnp %al578; X86-NEXT:    xorl %edx, %edx579; X86-NEXT:    retl580;581; X64-LABEL: parity_64_mask255:582; X64:       # %bb.0:583; X64-NEXT:    xorl %eax, %eax584; X64-NEXT:    testb %dil, %dil585; X64-NEXT:    setnp %al586; X64-NEXT:    retq587  %a = and i64 %x, 255588  %b = tail call i64 @llvm.ctpop.i64(i64 %a)589  %c = and i64 %b, 1590  ret i64 %c591}592 593define i64 @parity_64_mask15(i64 %x) {594; X86-LABEL: parity_64_mask15:595; X86:       # %bb.0:596; X86-NEXT:    xorl %eax, %eax597; X86-NEXT:    testb $15, {{[0-9]+}}(%esp)598; X86-NEXT:    setnp %al599; X86-NEXT:    xorl %edx, %edx600; X86-NEXT:    retl601;602; X64-LABEL: parity_64_mask15:603; X64:       # %bb.0:604; X64-NEXT:    xorl %eax, %eax605; X64-NEXT:    testb $15, %dil606; X64-NEXT:    setnp %al607; X64-NEXT:    retq608  %a = and i64 %x, 15609  %b = tail call i64 @llvm.ctpop.i64(i64 %a)610  %c = and i64 %b, 1611  ret i64 %c612}613 614define i64 @parity_64_shift(i64 %0) {615; X86-NOPOPCNT-LABEL: parity_64_shift:616; X86-NOPOPCNT:       # %bb.0:617; X86-NOPOPCNT-NEXT:    movl {{[0-9]+}}(%esp), %eax618; X86-NOPOPCNT-NEXT:    xorl {{[0-9]+}}(%esp), %eax619; X86-NOPOPCNT-NEXT:    movl %eax, %ecx620; X86-NOPOPCNT-NEXT:    shrl $16, %ecx621; X86-NOPOPCNT-NEXT:    xorl %eax, %ecx622; X86-NOPOPCNT-NEXT:    xorl %eax, %eax623; X86-NOPOPCNT-NEXT:    xorb %ch, %cl624; X86-NOPOPCNT-NEXT:    setnp %al625; X86-NOPOPCNT-NEXT:    addl %eax, %eax626; X86-NOPOPCNT-NEXT:    xorl %edx, %edx627; X86-NOPOPCNT-NEXT:    retl628;629; X64-NOPOPCNT-LABEL: parity_64_shift:630; X64-NOPOPCNT:       # %bb.0:631; X64-NOPOPCNT-NEXT:    movl %edi, %eax632; X64-NOPOPCNT-NEXT:    shrq $32, %rdi633; X64-NOPOPCNT-NEXT:    xorl %eax, %edi634; X64-NOPOPCNT-NEXT:    movl %edi, %ecx635; X64-NOPOPCNT-NEXT:    shrl $16, %ecx636; X64-NOPOPCNT-NEXT:    xorl %edi, %ecx637; X64-NOPOPCNT-NEXT:    xorl %eax, %eax638; X64-NOPOPCNT-NEXT:    xorb %ch, %cl639; X64-NOPOPCNT-NEXT:    setnp %al640; X64-NOPOPCNT-NEXT:    addl %eax, %eax641; X64-NOPOPCNT-NEXT:    retq642;643; X86-POPCNT-LABEL: parity_64_shift:644; X86-POPCNT:       # %bb.0:645; X86-POPCNT-NEXT:    movl {{[0-9]+}}(%esp), %eax646; X86-POPCNT-NEXT:    xorl {{[0-9]+}}(%esp), %eax647; X86-POPCNT-NEXT:    popcntl %eax, %eax648; X86-POPCNT-NEXT:    andl $1, %eax649; X86-POPCNT-NEXT:    addl %eax, %eax650; X86-POPCNT-NEXT:    xorl %edx, %edx651; X86-POPCNT-NEXT:    retl652;653; X64-POPCNT-LABEL: parity_64_shift:654; X64-POPCNT:       # %bb.0:655; X64-POPCNT-NEXT:    popcntq %rdi, %rax656; X64-POPCNT-NEXT:    andl $1, %eax657; X64-POPCNT-NEXT:    addl %eax, %eax658; X64-POPCNT-NEXT:    retq659  %2 = tail call i64 @llvm.ctpop.i64(i64 %0)660  %3 = shl nuw nsw i64 %2, 1661  %4 = and i64 %3, 2662  ret i64 %4663}664 665declare i4 @llvm.ctpop.i4(i4 %x)666declare i8 @llvm.ctpop.i8(i8 %x)667declare i16 @llvm.ctpop.i16(i16 %x)668declare i17 @llvm.ctpop.i17(i17 %x)669declare i32 @llvm.ctpop.i32(i32 %x)670declare i64 @llvm.ctpop.i64(i64 %x)671