brintos

brintos / llvm-project-archived public Read only

0
0
Text · 36.7 KiB · fc573fb Raw
1084 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc < %s -mtriple=i686-- -mattr=-bmi | FileCheck %s --check-prefixes=X86,X86-NOBMI3; RUN: llc < %s -mtriple=i686-- -mattr=+bmi | FileCheck %s --check-prefixes=X86,X86-BMI4; RUN: llc < %s -mtriple=x86_64-- -mattr=-bmi | FileCheck %s --check-prefixes=X64,X64-NOBMI5; RUN: llc < %s -mtriple=x86_64-- -mattr=+bmi | FileCheck %s --check-prefixes=X64,X64-BMI6 7; TODO - PR112425 - attempt to reconstruct andnot patterns through bitwise-agnostic operations8 9declare void @use_i64(i64)10declare void @use_i32(i32)11 12;13; Fold (and X, (rotl (not Y), Z))) -> (and X, (not (rotl Y, Z)))14;15 16define i64 @andnot_rotl_i64(i64 %a0, i64 %a1, i64 %a2) nounwind {17; X86-NOBMI-LABEL: andnot_rotl_i64:18; X86-NOBMI:       # %bb.0:19; X86-NOBMI-NEXT:    pushl %esi20; X86-NOBMI-NEXT:    movl {{[0-9]+}}(%esp), %esi21; X86-NOBMI-NEXT:    movl {{[0-9]+}}(%esp), %eax22; X86-NOBMI-NEXT:    movl {{[0-9]+}}(%esp), %ecx23; X86-NOBMI-NEXT:    testb $32, %cl24; X86-NOBMI-NEXT:    jne .LBB0_125; X86-NOBMI-NEXT:  # %bb.2:26; X86-NOBMI-NEXT:    movl %eax, %edx27; X86-NOBMI-NEXT:    jmp .LBB0_328; X86-NOBMI-NEXT:  .LBB0_1:29; X86-NOBMI-NEXT:    movl %esi, %edx30; X86-NOBMI-NEXT:    movl %eax, %esi31; X86-NOBMI-NEXT:  .LBB0_3:32; X86-NOBMI-NEXT:    movl %esi, %eax33; X86-NOBMI-NEXT:    shldl %cl, %edx, %eax34; X86-NOBMI-NEXT:    notl %eax35; X86-NOBMI-NEXT:    andl {{[0-9]+}}(%esp), %eax36; X86-NOBMI-NEXT:    # kill: def $cl killed $cl killed $ecx37; X86-NOBMI-NEXT:    shldl %cl, %esi, %edx38; X86-NOBMI-NEXT:    notl %edx39; X86-NOBMI-NEXT:    andl {{[0-9]+}}(%esp), %edx40; X86-NOBMI-NEXT:    popl %esi41; X86-NOBMI-NEXT:    retl42;43; X86-BMI-LABEL: andnot_rotl_i64:44; X86-BMI:       # %bb.0:45; X86-BMI-NEXT:    pushl %esi46; X86-BMI-NEXT:    movl {{[0-9]+}}(%esp), %edx47; X86-BMI-NEXT:    movl {{[0-9]+}}(%esp), %eax48; X86-BMI-NEXT:    movl {{[0-9]+}}(%esp), %ecx49; X86-BMI-NEXT:    testb $32, %cl50; X86-BMI-NEXT:    jne .LBB0_151; X86-BMI-NEXT:  # %bb.2:52; X86-BMI-NEXT:    movl %eax, %esi53; X86-BMI-NEXT:    jmp .LBB0_354; X86-BMI-NEXT:  .LBB0_1:55; X86-BMI-NEXT:    movl %edx, %esi56; X86-BMI-NEXT:    movl %eax, %edx57; X86-BMI-NEXT:  .LBB0_3:58; X86-BMI-NEXT:    movl %edx, %eax59; X86-BMI-NEXT:    shldl %cl, %esi, %eax60; X86-BMI-NEXT:    andnl {{[0-9]+}}(%esp), %eax, %eax61; X86-BMI-NEXT:    # kill: def $cl killed $cl killed $ecx62; X86-BMI-NEXT:    shldl %cl, %edx, %esi63; X86-BMI-NEXT:    andnl {{[0-9]+}}(%esp), %esi, %edx64; X86-BMI-NEXT:    popl %esi65; X86-BMI-NEXT:    retl66;67; X64-NOBMI-LABEL: andnot_rotl_i64:68; X64-NOBMI:       # %bb.0:69; X64-NOBMI-NEXT:    movq %rdx, %rcx70; X64-NOBMI-NEXT:    movq %rsi, %rax71; X64-NOBMI-NEXT:    # kill: def $cl killed $cl killed $rcx72; X64-NOBMI-NEXT:    rolq %cl, %rax73; X64-NOBMI-NEXT:    notq %rax74; X64-NOBMI-NEXT:    andq %rdi, %rax75; X64-NOBMI-NEXT:    retq76;77; X64-BMI-LABEL: andnot_rotl_i64:78; X64-BMI:       # %bb.0:79; X64-BMI-NEXT:    movq %rdx, %rcx80; X64-BMI-NEXT:    # kill: def $cl killed $cl killed $rcx81; X64-BMI-NEXT:    rolq %cl, %rsi82; X64-BMI-NEXT:    andnq %rdi, %rsi, %rax83; X64-BMI-NEXT:    retq84  %not = xor i64 %a1, -185  %rot = tail call i64 @llvm.fshl.i64(i64 %not, i64 %not, i64 %a2)86  %and = and i64 %rot, %a087  ret i64 %and88}89 90define i32 @andnot_rotl_i32(i32 %a0, i32 %a1, i32 %a2) nounwind {91; X86-NOBMI-LABEL: andnot_rotl_i32:92; X86-NOBMI:       # %bb.0:93; X86-NOBMI-NEXT:    movzbl {{[0-9]+}}(%esp), %ecx94; X86-NOBMI-NEXT:    movl {{[0-9]+}}(%esp), %eax95; X86-NOBMI-NEXT:    roll %cl, %eax96; X86-NOBMI-NEXT:    notl %eax97; X86-NOBMI-NEXT:    andl {{[0-9]+}}(%esp), %eax98; X86-NOBMI-NEXT:    retl99;100; X86-BMI-LABEL: andnot_rotl_i32:101; X86-BMI:       # %bb.0:102; X86-BMI-NEXT:    movzbl {{[0-9]+}}(%esp), %ecx103; X86-BMI-NEXT:    movl {{[0-9]+}}(%esp), %eax104; X86-BMI-NEXT:    roll %cl, %eax105; X86-BMI-NEXT:    andnl {{[0-9]+}}(%esp), %eax, %eax106; X86-BMI-NEXT:    retl107;108; X64-NOBMI-LABEL: andnot_rotl_i32:109; X64-NOBMI:       # %bb.0:110; X64-NOBMI-NEXT:    movl %edx, %ecx111; X64-NOBMI-NEXT:    movl %esi, %eax112; X64-NOBMI-NEXT:    # kill: def $cl killed $cl killed $ecx113; X64-NOBMI-NEXT:    roll %cl, %eax114; X64-NOBMI-NEXT:    notl %eax115; X64-NOBMI-NEXT:    andl %edi, %eax116; X64-NOBMI-NEXT:    retq117;118; X64-BMI-LABEL: andnot_rotl_i32:119; X64-BMI:       # %bb.0:120; X64-BMI-NEXT:    movl %edx, %ecx121; X64-BMI-NEXT:    # kill: def $cl killed $cl killed $ecx122; X64-BMI-NEXT:    roll %cl, %esi123; X64-BMI-NEXT:    andnl %edi, %esi, %eax124; X64-BMI-NEXT:    retq125  %not = xor i32 %a1, -1126  %rot = tail call i32 @llvm.fshl.i32(i32 %not, i32 %not, i32 %a2)127  %and = and i32 %rot, %a0128  ret i32 %and129}130 131define i16 @andnot_rotl_i16(i16 %a0, i16 %a1, i16 %a2) nounwind {132; X86-LABEL: andnot_rotl_i16:133; X86:       # %bb.0:134; X86-NEXT:    movzbl {{[0-9]+}}(%esp), %ecx135; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %eax136; X86-NEXT:    rolw %cl, %ax137; X86-NEXT:    notl %eax138; X86-NEXT:    andw {{[0-9]+}}(%esp), %ax139; X86-NEXT:    # kill: def $ax killed $ax killed $eax140; X86-NEXT:    retl141;142; X64-NOBMI-LABEL: andnot_rotl_i16:143; X64-NOBMI:       # %bb.0:144; X64-NOBMI-NEXT:    movl %edx, %ecx145; X64-NOBMI-NEXT:    movl %esi, %eax146; X64-NOBMI-NEXT:    # kill: def $cl killed $cl killed $ecx147; X64-NOBMI-NEXT:    rolw %cl, %ax148; X64-NOBMI-NEXT:    notl %eax149; X64-NOBMI-NEXT:    andl %edi, %eax150; X64-NOBMI-NEXT:    # kill: def $ax killed $ax killed $eax151; X64-NOBMI-NEXT:    retq152;153; X64-BMI-LABEL: andnot_rotl_i16:154; X64-BMI:       # %bb.0:155; X64-BMI-NEXT:    movl %edx, %ecx156; X64-BMI-NEXT:    # kill: def $cl killed $cl killed $ecx157; X64-BMI-NEXT:    rolw %cl, %si158; X64-BMI-NEXT:    andnl %edi, %esi, %eax159; X64-BMI-NEXT:    # kill: def $ax killed $ax killed $eax160; X64-BMI-NEXT:    retq161  %not = xor i16 %a1, -1162  %rot = tail call i16 @llvm.fshl.i16(i16 %not, i16 %not, i16 %a2)163  %and = and i16 %rot, %a0164  ret i16 %and165}166 167define i8 @andnot_rotl_i8(i8 %a0, i8 %a1, i8 %a2) nounwind {168; X86-LABEL: andnot_rotl_i8:169; X86:       # %bb.0:170; X86-NEXT:    movzbl {{[0-9]+}}(%esp), %ecx171; X86-NEXT:    movzbl {{[0-9]+}}(%esp), %eax172; X86-NEXT:    rolb %cl, %al173; X86-NEXT:    notb %al174; X86-NEXT:    andb {{[0-9]+}}(%esp), %al175; X86-NEXT:    retl176;177; X64-LABEL: andnot_rotl_i8:178; X64:       # %bb.0:179; X64-NEXT:    movl %edx, %ecx180; X64-NEXT:    movl %esi, %eax181; X64-NEXT:    # kill: def $cl killed $cl killed $ecx182; X64-NEXT:    rolb %cl, %al183; X64-NEXT:    notb %al184; X64-NEXT:    andb %dil, %al185; X64-NEXT:    # kill: def $al killed $al killed $eax186; X64-NEXT:    retq187  %not = xor i8 %a1, -1188  %rot = tail call i8 @llvm.fshl.i8(i8 %not, i8 %not, i8 %a2)189  %and = and i8 %rot, %a0190  ret i8 %and191}192 193define i64 @andnot_rotl_i64_multiuse_rot(i64 %a0, i64 %a1, i64 %a2) nounwind {194; X86-LABEL: andnot_rotl_i64_multiuse_rot:195; X86:       # %bb.0:196; X86-NEXT:    pushl %ebx197; X86-NEXT:    pushl %edi198; X86-NEXT:    pushl %esi199; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx200; X86-NEXT:    movl {{[0-9]+}}(%esp), %esi201; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx202; X86-NEXT:    notl %edx203; X86-NEXT:    notl %esi204; X86-NEXT:    testb $32, %cl205; X86-NEXT:    jne .LBB4_1206; X86-NEXT:  # %bb.2:207; X86-NEXT:    movl %esi, %eax208; X86-NEXT:    jmp .LBB4_3209; X86-NEXT:  .LBB4_1:210; X86-NEXT:    movl %edx, %eax211; X86-NEXT:    movl %esi, %edx212; X86-NEXT:  .LBB4_3:213; X86-NEXT:    movl %edx, %ebx214; X86-NEXT:    shldl %cl, %eax, %ebx215; X86-NEXT:    # kill: def $cl killed $cl killed $ecx216; X86-NEXT:    shldl %cl, %edx, %eax217; X86-NEXT:    movl {{[0-9]+}}(%esp), %esi218; X86-NEXT:    andl %eax, %esi219; X86-NEXT:    movl {{[0-9]+}}(%esp), %edi220; X86-NEXT:    andl %ebx, %edi221; X86-NEXT:    pushl %ebx222; X86-NEXT:    pushl %eax223; X86-NEXT:    calll use_i64@PLT224; X86-NEXT:    addl $8, %esp225; X86-NEXT:    movl %esi, %eax226; X86-NEXT:    movl %edi, %edx227; X86-NEXT:    popl %esi228; X86-NEXT:    popl %edi229; X86-NEXT:    popl %ebx230; X86-NEXT:    retl231;232; X64-LABEL: andnot_rotl_i64_multiuse_rot:233; X64:       # %bb.0:234; X64-NEXT:    pushq %rbx235; X64-NEXT:    movq %rdx, %rcx236; X64-NEXT:    movq %rdi, %rbx237; X64-NEXT:    notq %rsi238; X64-NEXT:    # kill: def $cl killed $cl killed $rcx239; X64-NEXT:    rolq %cl, %rsi240; X64-NEXT:    andq %rsi, %rbx241; X64-NEXT:    movq %rsi, %rdi242; X64-NEXT:    callq use_i64@PLT243; X64-NEXT:    movq %rbx, %rax244; X64-NEXT:    popq %rbx245; X64-NEXT:    retq246  %not = xor i64 %a1, -1247  %rot = tail call i64 @llvm.fshl.i64(i64 %not, i64 %not, i64 %a2)248  %and = and i64 %rot, %a0249  call void @use_i64(i64 %rot)250  ret i64 %and251}252 253;254; Fold (and X, (rotr (not Y), Z))) -> (and X, (not (rotr Y, Z)))255;256 257define i64 @andnot_rotr_i64(i64 %a0, i64 %a1, i64 %a2) nounwind {258; X86-NOBMI-LABEL: andnot_rotr_i64:259; X86-NOBMI:       # %bb.0:260; X86-NOBMI-NEXT:    pushl %esi261; X86-NOBMI-NEXT:    movl {{[0-9]+}}(%esp), %eax262; X86-NOBMI-NEXT:    movl {{[0-9]+}}(%esp), %esi263; X86-NOBMI-NEXT:    movl {{[0-9]+}}(%esp), %ecx264; X86-NOBMI-NEXT:    testb $32, %cl265; X86-NOBMI-NEXT:    je .LBB5_1266; X86-NOBMI-NEXT:  # %bb.2:267; X86-NOBMI-NEXT:    movl %eax, %edx268; X86-NOBMI-NEXT:    jmp .LBB5_3269; X86-NOBMI-NEXT:  .LBB5_1:270; X86-NOBMI-NEXT:    movl %esi, %edx271; X86-NOBMI-NEXT:    movl %eax, %esi272; X86-NOBMI-NEXT:  .LBB5_3:273; X86-NOBMI-NEXT:    movl %esi, %eax274; X86-NOBMI-NEXT:    shrdl %cl, %edx, %eax275; X86-NOBMI-NEXT:    notl %eax276; X86-NOBMI-NEXT:    andl {{[0-9]+}}(%esp), %eax277; X86-NOBMI-NEXT:    # kill: def $cl killed $cl killed $ecx278; X86-NOBMI-NEXT:    shrdl %cl, %esi, %edx279; X86-NOBMI-NEXT:    notl %edx280; X86-NOBMI-NEXT:    andl {{[0-9]+}}(%esp), %edx281; X86-NOBMI-NEXT:    popl %esi282; X86-NOBMI-NEXT:    retl283;284; X86-BMI-LABEL: andnot_rotr_i64:285; X86-BMI:       # %bb.0:286; X86-BMI-NEXT:    pushl %esi287; X86-BMI-NEXT:    movl {{[0-9]+}}(%esp), %eax288; X86-BMI-NEXT:    movl {{[0-9]+}}(%esp), %edx289; X86-BMI-NEXT:    movl {{[0-9]+}}(%esp), %ecx290; X86-BMI-NEXT:    testb $32, %cl291; X86-BMI-NEXT:    je .LBB5_1292; X86-BMI-NEXT:  # %bb.2:293; X86-BMI-NEXT:    movl %eax, %esi294; X86-BMI-NEXT:    jmp .LBB5_3295; X86-BMI-NEXT:  .LBB5_1:296; X86-BMI-NEXT:    movl %edx, %esi297; X86-BMI-NEXT:    movl %eax, %edx298; X86-BMI-NEXT:  .LBB5_3:299; X86-BMI-NEXT:    movl %edx, %eax300; X86-BMI-NEXT:    shrdl %cl, %esi, %eax301; X86-BMI-NEXT:    andnl {{[0-9]+}}(%esp), %eax, %eax302; X86-BMI-NEXT:    # kill: def $cl killed $cl killed $ecx303; X86-BMI-NEXT:    shrdl %cl, %edx, %esi304; X86-BMI-NEXT:    andnl {{[0-9]+}}(%esp), %esi, %edx305; X86-BMI-NEXT:    popl %esi306; X86-BMI-NEXT:    retl307;308; X64-NOBMI-LABEL: andnot_rotr_i64:309; X64-NOBMI:       # %bb.0:310; X64-NOBMI-NEXT:    movq %rdx, %rcx311; X64-NOBMI-NEXT:    movq %rsi, %rax312; X64-NOBMI-NEXT:    # kill: def $cl killed $cl killed $rcx313; X64-NOBMI-NEXT:    rorq %cl, %rax314; X64-NOBMI-NEXT:    notq %rax315; X64-NOBMI-NEXT:    andq %rdi, %rax316; X64-NOBMI-NEXT:    retq317;318; X64-BMI-LABEL: andnot_rotr_i64:319; X64-BMI:       # %bb.0:320; X64-BMI-NEXT:    movq %rdx, %rcx321; X64-BMI-NEXT:    # kill: def $cl killed $cl killed $rcx322; X64-BMI-NEXT:    rorq %cl, %rsi323; X64-BMI-NEXT:    andnq %rdi, %rsi, %rax324; X64-BMI-NEXT:    retq325  %not = xor i64 %a1, -1326  %rot = tail call i64 @llvm.fshr.i64(i64 %not, i64 %not, i64 %a2)327  %and = and i64 %rot, %a0328  ret i64 %and329}330 331define i32 @andnot_rotr_i32(i32 %a0, i32 %a1, i32 %a2) nounwind {332; X86-NOBMI-LABEL: andnot_rotr_i32:333; X86-NOBMI:       # %bb.0:334; X86-NOBMI-NEXT:    movzbl {{[0-9]+}}(%esp), %ecx335; X86-NOBMI-NEXT:    movl {{[0-9]+}}(%esp), %eax336; X86-NOBMI-NEXT:    rorl %cl, %eax337; X86-NOBMI-NEXT:    notl %eax338; X86-NOBMI-NEXT:    andl {{[0-9]+}}(%esp), %eax339; X86-NOBMI-NEXT:    retl340;341; X86-BMI-LABEL: andnot_rotr_i32:342; X86-BMI:       # %bb.0:343; X86-BMI-NEXT:    movzbl {{[0-9]+}}(%esp), %ecx344; X86-BMI-NEXT:    movl {{[0-9]+}}(%esp), %eax345; X86-BMI-NEXT:    rorl %cl, %eax346; X86-BMI-NEXT:    andnl {{[0-9]+}}(%esp), %eax, %eax347; X86-BMI-NEXT:    retl348;349; X64-NOBMI-LABEL: andnot_rotr_i32:350; X64-NOBMI:       # %bb.0:351; X64-NOBMI-NEXT:    movl %edx, %ecx352; X64-NOBMI-NEXT:    movl %esi, %eax353; X64-NOBMI-NEXT:    # kill: def $cl killed $cl killed $ecx354; X64-NOBMI-NEXT:    rorl %cl, %eax355; X64-NOBMI-NEXT:    notl %eax356; X64-NOBMI-NEXT:    andl %edi, %eax357; X64-NOBMI-NEXT:    retq358;359; X64-BMI-LABEL: andnot_rotr_i32:360; X64-BMI:       # %bb.0:361; X64-BMI-NEXT:    movl %edx, %ecx362; X64-BMI-NEXT:    # kill: def $cl killed $cl killed $ecx363; X64-BMI-NEXT:    rorl %cl, %esi364; X64-BMI-NEXT:    andnl %edi, %esi, %eax365; X64-BMI-NEXT:    retq366  %not = xor i32 %a1, -1367  %rot = tail call i32 @llvm.fshr.i32(i32 %not, i32 %not, i32 %a2)368  %and = and i32 %rot, %a0369  ret i32 %and370}371 372define i16 @andnot_rotr_i16(i16 %a0, i16 %a1, i16 %a2) nounwind {373; X86-LABEL: andnot_rotr_i16:374; X86:       # %bb.0:375; X86-NEXT:    movzbl {{[0-9]+}}(%esp), %ecx376; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %eax377; X86-NEXT:    rorw %cl, %ax378; X86-NEXT:    notl %eax379; X86-NEXT:    andw {{[0-9]+}}(%esp), %ax380; X86-NEXT:    # kill: def $ax killed $ax killed $eax381; X86-NEXT:    retl382;383; X64-NOBMI-LABEL: andnot_rotr_i16:384; X64-NOBMI:       # %bb.0:385; X64-NOBMI-NEXT:    movl %edx, %ecx386; X64-NOBMI-NEXT:    movl %esi, %eax387; X64-NOBMI-NEXT:    # kill: def $cl killed $cl killed $ecx388; X64-NOBMI-NEXT:    rorw %cl, %ax389; X64-NOBMI-NEXT:    notl %eax390; X64-NOBMI-NEXT:    andl %edi, %eax391; X64-NOBMI-NEXT:    # kill: def $ax killed $ax killed $eax392; X64-NOBMI-NEXT:    retq393;394; X64-BMI-LABEL: andnot_rotr_i16:395; X64-BMI:       # %bb.0:396; X64-BMI-NEXT:    movl %edx, %ecx397; X64-BMI-NEXT:    # kill: def $cl killed $cl killed $ecx398; X64-BMI-NEXT:    rorw %cl, %si399; X64-BMI-NEXT:    andnl %edi, %esi, %eax400; X64-BMI-NEXT:    # kill: def $ax killed $ax killed $eax401; X64-BMI-NEXT:    retq402  %not = xor i16 %a1, -1403  %rot = tail call i16 @llvm.fshr.i16(i16 %not, i16 %not, i16 %a2)404  %and = and i16 %rot, %a0405  ret i16 %and406}407 408define i8 @andnot_rotr_i8(i8 %a0, i8 %a1, i8 %a2) nounwind {409; X86-LABEL: andnot_rotr_i8:410; X86:       # %bb.0:411; X86-NEXT:    movzbl {{[0-9]+}}(%esp), %ecx412; X86-NEXT:    movzbl {{[0-9]+}}(%esp), %eax413; X86-NEXT:    rorb %cl, %al414; X86-NEXT:    notb %al415; X86-NEXT:    andb {{[0-9]+}}(%esp), %al416; X86-NEXT:    retl417;418; X64-LABEL: andnot_rotr_i8:419; X64:       # %bb.0:420; X64-NEXT:    movl %edx, %ecx421; X64-NEXT:    movl %esi, %eax422; X64-NEXT:    # kill: def $cl killed $cl killed $ecx423; X64-NEXT:    rorb %cl, %al424; X64-NEXT:    notb %al425; X64-NEXT:    andb %dil, %al426; X64-NEXT:    # kill: def $al killed $al killed $eax427; X64-NEXT:    retq428  %not = xor i8 %a1, -1429  %rot = tail call i8 @llvm.fshr.i8(i8 %not, i8 %not, i8 %a2)430  %and = and i8 %rot, %a0431  ret i8 %and432}433 434define i32 @andnot_rotr_i32_multiuse_not(i32 %a0, i32 %a1, i32 %a2) nounwind {435; X86-NOBMI-LABEL: andnot_rotr_i32_multiuse_not:436; X86-NOBMI:       # %bb.0:437; X86-NOBMI-NEXT:    pushl %esi438; X86-NOBMI-NEXT:    movzbl {{[0-9]+}}(%esp), %ecx439; X86-NOBMI-NEXT:    movl {{[0-9]+}}(%esp), %eax440; X86-NOBMI-NEXT:    notl %eax441; X86-NOBMI-NEXT:    movl %eax, %esi442; X86-NOBMI-NEXT:    rorl %cl, %esi443; X86-NOBMI-NEXT:    andl {{[0-9]+}}(%esp), %esi444; X86-NOBMI-NEXT:    pushl %eax445; X86-NOBMI-NEXT:    calll use_i32@PLT446; X86-NOBMI-NEXT:    addl $4, %esp447; X86-NOBMI-NEXT:    movl %esi, %eax448; X86-NOBMI-NEXT:    popl %esi449; X86-NOBMI-NEXT:    retl450;451; X86-BMI-LABEL: andnot_rotr_i32_multiuse_not:452; X86-BMI:       # %bb.0:453; X86-BMI-NEXT:    pushl %esi454; X86-BMI-NEXT:    movzbl {{[0-9]+}}(%esp), %ecx455; X86-BMI-NEXT:    movl {{[0-9]+}}(%esp), %eax456; X86-BMI-NEXT:    movl %eax, %edx457; X86-BMI-NEXT:    notl %edx458; X86-BMI-NEXT:    rorl %cl, %eax459; X86-BMI-NEXT:    andnl {{[0-9]+}}(%esp), %eax, %esi460; X86-BMI-NEXT:    pushl %edx461; X86-BMI-NEXT:    calll use_i32@PLT462; X86-BMI-NEXT:    addl $4, %esp463; X86-BMI-NEXT:    movl %esi, %eax464; X86-BMI-NEXT:    popl %esi465; X86-BMI-NEXT:    retl466;467; X64-NOBMI-LABEL: andnot_rotr_i32_multiuse_not:468; X64-NOBMI:       # %bb.0:469; X64-NOBMI-NEXT:    pushq %rbx470; X64-NOBMI-NEXT:    movl %edx, %ecx471; X64-NOBMI-NEXT:    notl %esi472; X64-NOBMI-NEXT:    movl %esi, %ebx473; X64-NOBMI-NEXT:    # kill: def $cl killed $cl killed $ecx474; X64-NOBMI-NEXT:    rorl %cl, %ebx475; X64-NOBMI-NEXT:    andl %edi, %ebx476; X64-NOBMI-NEXT:    movl %esi, %edi477; X64-NOBMI-NEXT:    callq use_i32@PLT478; X64-NOBMI-NEXT:    movl %ebx, %eax479; X64-NOBMI-NEXT:    popq %rbx480; X64-NOBMI-NEXT:    retq481;482; X64-BMI-LABEL: andnot_rotr_i32_multiuse_not:483; X64-BMI:       # %bb.0:484; X64-BMI-NEXT:    pushq %rbx485; X64-BMI-NEXT:    movl %edx, %ecx486; X64-BMI-NEXT:    movl %esi, %eax487; X64-BMI-NEXT:    notl %eax488; X64-BMI-NEXT:    # kill: def $cl killed $cl killed $ecx489; X64-BMI-NEXT:    rorl %cl, %esi490; X64-BMI-NEXT:    andnl %edi, %esi, %ebx491; X64-BMI-NEXT:    movl %eax, %edi492; X64-BMI-NEXT:    callq use_i32@PLT493; X64-BMI-NEXT:    movl %ebx, %eax494; X64-BMI-NEXT:    popq %rbx495; X64-BMI-NEXT:    retq496  %not = xor i32 %a1, -1497  %rot = tail call i32 @llvm.fshr.i32(i32 %not, i32 %not, i32 %a2)498  %and = and i32 %rot, %a0499  call void @use_i32(i32 %not)500  ret i32 %and501}502 503;504; Fold (and X, (bswap (not Y)))) -> (and X, (not (bswap Y)))505;506 507define i64 @andnot_bswap_i64(i64 %a0, i64 %a1) nounwind {508; X86-NOBMI-LABEL: andnot_bswap_i64:509; X86-NOBMI:       # %bb.0:510; X86-NOBMI-NEXT:    movl {{[0-9]+}}(%esp), %edx511; X86-NOBMI-NEXT:    movl {{[0-9]+}}(%esp), %eax512; X86-NOBMI-NEXT:    bswapl %eax513; X86-NOBMI-NEXT:    notl %eax514; X86-NOBMI-NEXT:    andl {{[0-9]+}}(%esp), %eax515; X86-NOBMI-NEXT:    bswapl %edx516; X86-NOBMI-NEXT:    notl %edx517; X86-NOBMI-NEXT:    andl {{[0-9]+}}(%esp), %edx518; X86-NOBMI-NEXT:    retl519;520; X86-BMI-LABEL: andnot_bswap_i64:521; X86-BMI:       # %bb.0:522; X86-BMI-NEXT:    movl {{[0-9]+}}(%esp), %ecx523; X86-BMI-NEXT:    movl {{[0-9]+}}(%esp), %eax524; X86-BMI-NEXT:    bswapl %eax525; X86-BMI-NEXT:    andnl {{[0-9]+}}(%esp), %eax, %eax526; X86-BMI-NEXT:    bswapl %ecx527; X86-BMI-NEXT:    andnl {{[0-9]+}}(%esp), %ecx, %edx528; X86-BMI-NEXT:    retl529;530; X64-NOBMI-LABEL: andnot_bswap_i64:531; X64-NOBMI:       # %bb.0:532; X64-NOBMI-NEXT:    movq %rsi, %rax533; X64-NOBMI-NEXT:    bswapq %rax534; X64-NOBMI-NEXT:    notq %rax535; X64-NOBMI-NEXT:    andq %rdi, %rax536; X64-NOBMI-NEXT:    retq537;538; X64-BMI-LABEL: andnot_bswap_i64:539; X64-BMI:       # %bb.0:540; X64-BMI-NEXT:    bswapq %rsi541; X64-BMI-NEXT:    andnq %rdi, %rsi, %rax542; X64-BMI-NEXT:    retq543  %not = xor i64 %a1, -1544  %bswap = tail call i64 @llvm.bswap.i64(i64 %not)545  %and = and i64 %bswap, %a0546  ret i64 %and547}548 549define i32 @andnot_bswap_i32(i32 %a0, i32 %a1) nounwind {550; X86-NOBMI-LABEL: andnot_bswap_i32:551; X86-NOBMI:       # %bb.0:552; X86-NOBMI-NEXT:    movl {{[0-9]+}}(%esp), %eax553; X86-NOBMI-NEXT:    bswapl %eax554; X86-NOBMI-NEXT:    notl %eax555; X86-NOBMI-NEXT:    andl {{[0-9]+}}(%esp), %eax556; X86-NOBMI-NEXT:    retl557;558; X86-BMI-LABEL: andnot_bswap_i32:559; X86-BMI:       # %bb.0:560; X86-BMI-NEXT:    movl {{[0-9]+}}(%esp), %eax561; X86-BMI-NEXT:    bswapl %eax562; X86-BMI-NEXT:    andnl {{[0-9]+}}(%esp), %eax, %eax563; X86-BMI-NEXT:    retl564;565; X64-NOBMI-LABEL: andnot_bswap_i32:566; X64-NOBMI:       # %bb.0:567; X64-NOBMI-NEXT:    movl %esi, %eax568; X64-NOBMI-NEXT:    bswapl %eax569; X64-NOBMI-NEXT:    notl %eax570; X64-NOBMI-NEXT:    andl %edi, %eax571; X64-NOBMI-NEXT:    retq572;573; X64-BMI-LABEL: andnot_bswap_i32:574; X64-BMI:       # %bb.0:575; X64-BMI-NEXT:    bswapl %esi576; X64-BMI-NEXT:    andnl %edi, %esi, %eax577; X64-BMI-NEXT:    retq578  %not = xor i32 %a1, -1579  %bswap = tail call i32 @llvm.bswap.i32(i32 %not)580  %and = and i32 %bswap, %a0581  ret i32 %and582}583 584define i16 @andnot_bswap_i16(i16 %a0, i16 %a1) nounwind {585; X86-LABEL: andnot_bswap_i16:586; X86:       # %bb.0:587; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %eax588; X86-NEXT:    rolw $8, %ax589; X86-NEXT:    notl %eax590; X86-NEXT:    andw {{[0-9]+}}(%esp), %ax591; X86-NEXT:    # kill: def $ax killed $ax killed $eax592; X86-NEXT:    retl593;594; X64-NOBMI-LABEL: andnot_bswap_i16:595; X64-NOBMI:       # %bb.0:596; X64-NOBMI-NEXT:    movl %esi, %eax597; X64-NOBMI-NEXT:    rolw $8, %ax598; X64-NOBMI-NEXT:    notl %eax599; X64-NOBMI-NEXT:    andl %edi, %eax600; X64-NOBMI-NEXT:    # kill: def $ax killed $ax killed $eax601; X64-NOBMI-NEXT:    retq602;603; X64-BMI-LABEL: andnot_bswap_i16:604; X64-BMI:       # %bb.0:605; X64-BMI-NEXT:    rolw $8, %si606; X64-BMI-NEXT:    andnl %edi, %esi, %eax607; X64-BMI-NEXT:    # kill: def $ax killed $ax killed $eax608; X64-BMI-NEXT:    retq609  %not = xor i16 %a1, -1610  %bswap = tail call i16 @llvm.bswap.i16(i16 %not)611  %and = and i16 %bswap, %a0612  ret i16 %and613}614 615define i32 @andnot_bswap_i32_multiuse_bswap(i32 %a0, i32 %a1) nounwind {616; X86-LABEL: andnot_bswap_i32_multiuse_bswap:617; X86:       # %bb.0:618; X86-NEXT:    pushl %esi619; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax620; X86-NEXT:    notl %eax621; X86-NEXT:    bswapl %eax622; X86-NEXT:    movl {{[0-9]+}}(%esp), %esi623; X86-NEXT:    andl %eax, %esi624; X86-NEXT:    pushl %eax625; X86-NEXT:    calll use_i32@PLT626; X86-NEXT:    addl $4, %esp627; X86-NEXT:    movl %esi, %eax628; X86-NEXT:    popl %esi629; X86-NEXT:    retl630;631; X64-LABEL: andnot_bswap_i32_multiuse_bswap:632; X64:       # %bb.0:633; X64-NEXT:    pushq %rbx634; X64-NEXT:    movl %edi, %ebx635; X64-NEXT:    notl %esi636; X64-NEXT:    bswapl %esi637; X64-NEXT:    andl %esi, %ebx638; X64-NEXT:    movl %esi, %edi639; X64-NEXT:    callq use_i32@PLT640; X64-NEXT:    movl %ebx, %eax641; X64-NEXT:    popq %rbx642; X64-NEXT:    retq643  %not = xor i32 %a1, -1644  %bswap = tail call i32 @llvm.bswap.i32(i32 %not)645  %and = and i32 %bswap, %a0646  call void @use_i32(i32 %bswap)647  ret i32 %and648}649 650define i32 @andnot_bswap_i32_multiuse_not(i32 %a0, i32 %a1) nounwind {651; X86-NOBMI-LABEL: andnot_bswap_i32_multiuse_not:652; X86-NOBMI:       # %bb.0:653; X86-NOBMI-NEXT:    pushl %esi654; X86-NOBMI-NEXT:    movl {{[0-9]+}}(%esp), %eax655; X86-NOBMI-NEXT:    notl %eax656; X86-NOBMI-NEXT:    movl %eax, %esi657; X86-NOBMI-NEXT:    bswapl %esi658; X86-NOBMI-NEXT:    andl {{[0-9]+}}(%esp), %esi659; X86-NOBMI-NEXT:    pushl %eax660; X86-NOBMI-NEXT:    calll use_i32@PLT661; X86-NOBMI-NEXT:    addl $4, %esp662; X86-NOBMI-NEXT:    movl %esi, %eax663; X86-NOBMI-NEXT:    popl %esi664; X86-NOBMI-NEXT:    retl665;666; X86-BMI-LABEL: andnot_bswap_i32_multiuse_not:667; X86-BMI:       # %bb.0:668; X86-BMI-NEXT:    pushl %esi669; X86-BMI-NEXT:    movl {{[0-9]+}}(%esp), %eax670; X86-BMI-NEXT:    movl %eax, %ecx671; X86-BMI-NEXT:    notl %ecx672; X86-BMI-NEXT:    bswapl %eax673; X86-BMI-NEXT:    andnl {{[0-9]+}}(%esp), %eax, %esi674; X86-BMI-NEXT:    pushl %ecx675; X86-BMI-NEXT:    calll use_i32@PLT676; X86-BMI-NEXT:    addl $4, %esp677; X86-BMI-NEXT:    movl %esi, %eax678; X86-BMI-NEXT:    popl %esi679; X86-BMI-NEXT:    retl680;681; X64-NOBMI-LABEL: andnot_bswap_i32_multiuse_not:682; X64-NOBMI:       # %bb.0:683; X64-NOBMI-NEXT:    pushq %rbx684; X64-NOBMI-NEXT:    notl %esi685; X64-NOBMI-NEXT:    movl %esi, %ebx686; X64-NOBMI-NEXT:    bswapl %ebx687; X64-NOBMI-NEXT:    andl %edi, %ebx688; X64-NOBMI-NEXT:    movl %esi, %edi689; X64-NOBMI-NEXT:    callq use_i32@PLT690; X64-NOBMI-NEXT:    movl %ebx, %eax691; X64-NOBMI-NEXT:    popq %rbx692; X64-NOBMI-NEXT:    retq693;694; X64-BMI-LABEL: andnot_bswap_i32_multiuse_not:695; X64-BMI:       # %bb.0:696; X64-BMI-NEXT:    pushq %rbx697; X64-BMI-NEXT:    movl %esi, %eax698; X64-BMI-NEXT:    notl %eax699; X64-BMI-NEXT:    bswapl %esi700; X64-BMI-NEXT:    andnl %edi, %esi, %ebx701; X64-BMI-NEXT:    movl %eax, %edi702; X64-BMI-NEXT:    callq use_i32@PLT703; X64-BMI-NEXT:    movl %ebx, %eax704; X64-BMI-NEXT:    popq %rbx705; X64-BMI-NEXT:    retq706  %not = xor i32 %a1, -1707  %bswap = tail call i32 @llvm.bswap.i32(i32 %not)708  %and = and i32 %bswap, %a0709  call void @use_i32(i32 %not)710  ret i32 %and711}712 713;714; Fold (and X, (bitreverse (not Y)))) -> (and X, (not (bitreverse Y)))715;716 717define i64 @andnot_bitreverse_i64(i64 %a0, i64 %a1) nounwind {718; X86-NOBMI-LABEL: andnot_bitreverse_i64:719; X86-NOBMI:       # %bb.0:720; X86-NOBMI-NEXT:    movl {{[0-9]+}}(%esp), %ecx721; X86-NOBMI-NEXT:    movl {{[0-9]+}}(%esp), %eax722; X86-NOBMI-NEXT:    bswapl %eax723; X86-NOBMI-NEXT:    movl %eax, %edx724; X86-NOBMI-NEXT:    andl $252645135, %edx # imm = 0xF0F0F0F725; X86-NOBMI-NEXT:    shll $4, %edx726; X86-NOBMI-NEXT:    shrl $4, %eax727; X86-NOBMI-NEXT:    andl $252645135, %eax # imm = 0xF0F0F0F728; X86-NOBMI-NEXT:    orl %edx, %eax729; X86-NOBMI-NEXT:    movl %eax, %edx730; X86-NOBMI-NEXT:    andl $858993459, %edx # imm = 0x33333333731; X86-NOBMI-NEXT:    shrl $2, %eax732; X86-NOBMI-NEXT:    andl $858993459, %eax # imm = 0x33333333733; X86-NOBMI-NEXT:    leal (%eax,%edx,4), %eax734; X86-NOBMI-NEXT:    movl %eax, %edx735; X86-NOBMI-NEXT:    andl $1431655765, %edx # imm = 0x55555555736; X86-NOBMI-NEXT:    shrl %eax737; X86-NOBMI-NEXT:    andl $1431655765, %eax # imm = 0x55555555738; X86-NOBMI-NEXT:    leal (%eax,%edx,2), %eax739; X86-NOBMI-NEXT:    notl %eax740; X86-NOBMI-NEXT:    andl {{[0-9]+}}(%esp), %eax741; X86-NOBMI-NEXT:    bswapl %ecx742; X86-NOBMI-NEXT:    movl %ecx, %edx743; X86-NOBMI-NEXT:    andl $252645135, %edx # imm = 0xF0F0F0F744; X86-NOBMI-NEXT:    shll $4, %edx745; X86-NOBMI-NEXT:    shrl $4, %ecx746; X86-NOBMI-NEXT:    andl $252645135, %ecx # imm = 0xF0F0F0F747; X86-NOBMI-NEXT:    orl %edx, %ecx748; X86-NOBMI-NEXT:    movl %ecx, %edx749; X86-NOBMI-NEXT:    andl $858993459, %edx # imm = 0x33333333750; X86-NOBMI-NEXT:    shrl $2, %ecx751; X86-NOBMI-NEXT:    andl $858993459, %ecx # imm = 0x33333333752; X86-NOBMI-NEXT:    leal (%ecx,%edx,4), %ecx753; X86-NOBMI-NEXT:    movl %ecx, %edx754; X86-NOBMI-NEXT:    andl $1431655765, %edx # imm = 0x55555555755; X86-NOBMI-NEXT:    shrl %ecx756; X86-NOBMI-NEXT:    andl $1431655765, %ecx # imm = 0x55555555757; X86-NOBMI-NEXT:    leal (%ecx,%edx,2), %edx758; X86-NOBMI-NEXT:    notl %edx759; X86-NOBMI-NEXT:    andl {{[0-9]+}}(%esp), %edx760; X86-NOBMI-NEXT:    retl761;762; X86-BMI-LABEL: andnot_bitreverse_i64:763; X86-BMI:       # %bb.0:764; X86-BMI-NEXT:    movl {{[0-9]+}}(%esp), %ecx765; X86-BMI-NEXT:    movl {{[0-9]+}}(%esp), %eax766; X86-BMI-NEXT:    bswapl %eax767; X86-BMI-NEXT:    movl %eax, %edx768; X86-BMI-NEXT:    andl $252645135, %edx # imm = 0xF0F0F0F769; X86-BMI-NEXT:    shll $4, %edx770; X86-BMI-NEXT:    shrl $4, %eax771; X86-BMI-NEXT:    andl $252645135, %eax # imm = 0xF0F0F0F772; X86-BMI-NEXT:    orl %edx, %eax773; X86-BMI-NEXT:    movl %eax, %edx774; X86-BMI-NEXT:    andl $858993459, %edx # imm = 0x33333333775; X86-BMI-NEXT:    shrl $2, %eax776; X86-BMI-NEXT:    andl $858993459, %eax # imm = 0x33333333777; X86-BMI-NEXT:    leal (%eax,%edx,4), %eax778; X86-BMI-NEXT:    movl %eax, %edx779; X86-BMI-NEXT:    andl $1431655765, %edx # imm = 0x55555555780; X86-BMI-NEXT:    shrl %eax781; X86-BMI-NEXT:    andl $1431655765, %eax # imm = 0x55555555782; X86-BMI-NEXT:    leal (%eax,%edx,2), %eax783; X86-BMI-NEXT:    andnl {{[0-9]+}}(%esp), %eax, %eax784; X86-BMI-NEXT:    bswapl %ecx785; X86-BMI-NEXT:    movl %ecx, %edx786; X86-BMI-NEXT:    andl $252645135, %edx # imm = 0xF0F0F0F787; X86-BMI-NEXT:    shll $4, %edx788; X86-BMI-NEXT:    shrl $4, %ecx789; X86-BMI-NEXT:    andl $252645135, %ecx # imm = 0xF0F0F0F790; X86-BMI-NEXT:    orl %edx, %ecx791; X86-BMI-NEXT:    movl %ecx, %edx792; X86-BMI-NEXT:    andl $858993459, %edx # imm = 0x33333333793; X86-BMI-NEXT:    shrl $2, %ecx794; X86-BMI-NEXT:    andl $858993459, %ecx # imm = 0x33333333795; X86-BMI-NEXT:    leal (%ecx,%edx,4), %ecx796; X86-BMI-NEXT:    movl %ecx, %edx797; X86-BMI-NEXT:    andl $1431655765, %edx # imm = 0x55555555798; X86-BMI-NEXT:    shrl %ecx799; X86-BMI-NEXT:    andl $1431655765, %ecx # imm = 0x55555555800; X86-BMI-NEXT:    leal (%ecx,%edx,2), %ecx801; X86-BMI-NEXT:    andnl {{[0-9]+}}(%esp), %ecx, %edx802; X86-BMI-NEXT:    retl803;804; X64-NOBMI-LABEL: andnot_bitreverse_i64:805; X64-NOBMI:       # %bb.0:806; X64-NOBMI-NEXT:    bswapq %rsi807; X64-NOBMI-NEXT:    movq %rsi, %rax808; X64-NOBMI-NEXT:    shrq $4, %rax809; X64-NOBMI-NEXT:    movabsq $1085102592571150095, %rcx # imm = 0xF0F0F0F0F0F0F0F810; X64-NOBMI-NEXT:    andq %rcx, %rax811; X64-NOBMI-NEXT:    andq %rcx, %rsi812; X64-NOBMI-NEXT:    shlq $4, %rsi813; X64-NOBMI-NEXT:    orq %rax, %rsi814; X64-NOBMI-NEXT:    movabsq $3689348814741910323, %rax # imm = 0x3333333333333333815; X64-NOBMI-NEXT:    movq %rsi, %rcx816; X64-NOBMI-NEXT:    andq %rax, %rcx817; X64-NOBMI-NEXT:    shrq $2, %rsi818; X64-NOBMI-NEXT:    andq %rax, %rsi819; X64-NOBMI-NEXT:    leaq (%rsi,%rcx,4), %rax820; X64-NOBMI-NEXT:    movabsq $6148914691236517205, %rcx # imm = 0x5555555555555555821; X64-NOBMI-NEXT:    movq %rax, %rdx822; X64-NOBMI-NEXT:    andq %rcx, %rdx823; X64-NOBMI-NEXT:    shrq %rax824; X64-NOBMI-NEXT:    andq %rcx, %rax825; X64-NOBMI-NEXT:    leaq (%rax,%rdx,2), %rax826; X64-NOBMI-NEXT:    notq %rax827; X64-NOBMI-NEXT:    andq %rdi, %rax828; X64-NOBMI-NEXT:    retq829;830; X64-BMI-LABEL: andnot_bitreverse_i64:831; X64-BMI:       # %bb.0:832; X64-BMI-NEXT:    bswapq %rsi833; X64-BMI-NEXT:    movq %rsi, %rax834; X64-BMI-NEXT:    shrq $4, %rax835; X64-BMI-NEXT:    movabsq $1085102592571150095, %rcx # imm = 0xF0F0F0F0F0F0F0F836; X64-BMI-NEXT:    andq %rcx, %rax837; X64-BMI-NEXT:    andq %rcx, %rsi838; X64-BMI-NEXT:    shlq $4, %rsi839; X64-BMI-NEXT:    orq %rax, %rsi840; X64-BMI-NEXT:    movabsq $3689348814741910323, %rax # imm = 0x3333333333333333841; X64-BMI-NEXT:    movq %rsi, %rcx842; X64-BMI-NEXT:    andq %rax, %rcx843; X64-BMI-NEXT:    shrq $2, %rsi844; X64-BMI-NEXT:    andq %rax, %rsi845; X64-BMI-NEXT:    leaq (%rsi,%rcx,4), %rax846; X64-BMI-NEXT:    movabsq $6148914691236517205, %rcx # imm = 0x5555555555555555847; X64-BMI-NEXT:    movq %rax, %rdx848; X64-BMI-NEXT:    andq %rcx, %rdx849; X64-BMI-NEXT:    shrq %rax850; X64-BMI-NEXT:    andq %rcx, %rax851; X64-BMI-NEXT:    leaq (%rax,%rdx,2), %rax852; X64-BMI-NEXT:    andnq %rdi, %rax, %rax853; X64-BMI-NEXT:    retq854  %not = xor i64 %a1, -1855  %bitrev = tail call i64 @llvm.bitreverse.i64(i64 %not)856  %and = and i64 %bitrev, %a0857  ret i64 %and858}859 860define i32 @andnot_bitreverse_i32(i32 %a0, i32 %a1) nounwind {861; X86-NOBMI-LABEL: andnot_bitreverse_i32:862; X86-NOBMI:       # %bb.0:863; X86-NOBMI-NEXT:    movl {{[0-9]+}}(%esp), %eax864; X86-NOBMI-NEXT:    bswapl %eax865; X86-NOBMI-NEXT:    movl %eax, %ecx866; X86-NOBMI-NEXT:    andl $252645135, %ecx # imm = 0xF0F0F0F867; X86-NOBMI-NEXT:    shll $4, %ecx868; X86-NOBMI-NEXT:    shrl $4, %eax869; X86-NOBMI-NEXT:    andl $252645135, %eax # imm = 0xF0F0F0F870; X86-NOBMI-NEXT:    orl %ecx, %eax871; X86-NOBMI-NEXT:    movl %eax, %ecx872; X86-NOBMI-NEXT:    andl $858993459, %ecx # imm = 0x33333333873; X86-NOBMI-NEXT:    shrl $2, %eax874; X86-NOBMI-NEXT:    andl $858993459, %eax # imm = 0x33333333875; X86-NOBMI-NEXT:    leal (%eax,%ecx,4), %eax876; X86-NOBMI-NEXT:    movl %eax, %ecx877; X86-NOBMI-NEXT:    andl $1431655765, %ecx # imm = 0x55555555878; X86-NOBMI-NEXT:    shrl %eax879; X86-NOBMI-NEXT:    andl $1431655765, %eax # imm = 0x55555555880; X86-NOBMI-NEXT:    leal (%eax,%ecx,2), %eax881; X86-NOBMI-NEXT:    notl %eax882; X86-NOBMI-NEXT:    andl {{[0-9]+}}(%esp), %eax883; X86-NOBMI-NEXT:    retl884;885; X86-BMI-LABEL: andnot_bitreverse_i32:886; X86-BMI:       # %bb.0:887; X86-BMI-NEXT:    movl {{[0-9]+}}(%esp), %eax888; X86-BMI-NEXT:    bswapl %eax889; X86-BMI-NEXT:    movl %eax, %ecx890; X86-BMI-NEXT:    andl $252645135, %ecx # imm = 0xF0F0F0F891; X86-BMI-NEXT:    shll $4, %ecx892; X86-BMI-NEXT:    shrl $4, %eax893; X86-BMI-NEXT:    andl $252645135, %eax # imm = 0xF0F0F0F894; X86-BMI-NEXT:    orl %ecx, %eax895; X86-BMI-NEXT:    movl %eax, %ecx896; X86-BMI-NEXT:    andl $858993459, %ecx # imm = 0x33333333897; X86-BMI-NEXT:    shrl $2, %eax898; X86-BMI-NEXT:    andl $858993459, %eax # imm = 0x33333333899; X86-BMI-NEXT:    leal (%eax,%ecx,4), %eax900; X86-BMI-NEXT:    movl %eax, %ecx901; X86-BMI-NEXT:    andl $1431655765, %ecx # imm = 0x55555555902; X86-BMI-NEXT:    shrl %eax903; X86-BMI-NEXT:    andl $1431655765, %eax # imm = 0x55555555904; X86-BMI-NEXT:    leal (%eax,%ecx,2), %eax905; X86-BMI-NEXT:    andnl {{[0-9]+}}(%esp), %eax, %eax906; X86-BMI-NEXT:    retl907;908; X64-NOBMI-LABEL: andnot_bitreverse_i32:909; X64-NOBMI:       # %bb.0:910; X64-NOBMI-NEXT:    # kill: def $esi killed $esi def $rsi911; X64-NOBMI-NEXT:    bswapl %esi912; X64-NOBMI-NEXT:    movl %esi, %eax913; X64-NOBMI-NEXT:    andl $252645135, %eax # imm = 0xF0F0F0F914; X64-NOBMI-NEXT:    shll $4, %eax915; X64-NOBMI-NEXT:    shrl $4, %esi916; X64-NOBMI-NEXT:    andl $252645135, %esi # imm = 0xF0F0F0F917; X64-NOBMI-NEXT:    orl %eax, %esi918; X64-NOBMI-NEXT:    movl %esi, %eax919; X64-NOBMI-NEXT:    andl $858993459, %eax # imm = 0x33333333920; X64-NOBMI-NEXT:    shrl $2, %esi921; X64-NOBMI-NEXT:    andl $858993459, %esi # imm = 0x33333333922; X64-NOBMI-NEXT:    leal (%rsi,%rax,4), %eax923; X64-NOBMI-NEXT:    movl %eax, %ecx924; X64-NOBMI-NEXT:    andl $1431655765, %ecx # imm = 0x55555555925; X64-NOBMI-NEXT:    shrl %eax926; X64-NOBMI-NEXT:    andl $1431655765, %eax # imm = 0x55555555927; X64-NOBMI-NEXT:    leal (%rax,%rcx,2), %eax928; X64-NOBMI-NEXT:    notl %eax929; X64-NOBMI-NEXT:    andl %edi, %eax930; X64-NOBMI-NEXT:    retq931;932; X64-BMI-LABEL: andnot_bitreverse_i32:933; X64-BMI:       # %bb.0:934; X64-BMI-NEXT:    # kill: def $esi killed $esi def $rsi935; X64-BMI-NEXT:    bswapl %esi936; X64-BMI-NEXT:    movl %esi, %eax937; X64-BMI-NEXT:    andl $252645135, %eax # imm = 0xF0F0F0F938; X64-BMI-NEXT:    shll $4, %eax939; X64-BMI-NEXT:    shrl $4, %esi940; X64-BMI-NEXT:    andl $252645135, %esi # imm = 0xF0F0F0F941; X64-BMI-NEXT:    orl %eax, %esi942; X64-BMI-NEXT:    movl %esi, %eax943; X64-BMI-NEXT:    andl $858993459, %eax # imm = 0x33333333944; X64-BMI-NEXT:    shrl $2, %esi945; X64-BMI-NEXT:    andl $858993459, %esi # imm = 0x33333333946; X64-BMI-NEXT:    leal (%rsi,%rax,4), %eax947; X64-BMI-NEXT:    movl %eax, %ecx948; X64-BMI-NEXT:    andl $1431655765, %ecx # imm = 0x55555555949; X64-BMI-NEXT:    shrl %eax950; X64-BMI-NEXT:    andl $1431655765, %eax # imm = 0x55555555951; X64-BMI-NEXT:    leal (%rax,%rcx,2), %eax952; X64-BMI-NEXT:    andnl %edi, %eax, %eax953; X64-BMI-NEXT:    retq954  %not = xor i32 %a1, -1955  %bitrev = tail call i32 @llvm.bitreverse.i32(i32 %not)956  %and = and i32 %bitrev, %a0957  ret i32 %and958}959 960define i16 @andnot_bitreverse_i16(i16 %a0, i16 %a1) nounwind {961; X86-LABEL: andnot_bitreverse_i16:962; X86:       # %bb.0:963; X86-NEXT:    movzwl {{[0-9]+}}(%esp), %eax964; X86-NEXT:    rolw $8, %ax965; X86-NEXT:    movl %eax, %ecx966; X86-NEXT:    andl $3855, %ecx # imm = 0xF0F967; X86-NEXT:    shll $4, %ecx968; X86-NEXT:    shrl $4, %eax969; X86-NEXT:    andl $3855, %eax # imm = 0xF0F970; X86-NEXT:    orl %ecx, %eax971; X86-NEXT:    movl %eax, %ecx972; X86-NEXT:    andl $13107, %ecx # imm = 0x3333973; X86-NEXT:    shrl $2, %eax974; X86-NEXT:    andl $13107, %eax # imm = 0x3333975; X86-NEXT:    leal (%eax,%ecx,4), %eax976; X86-NEXT:    movl %eax, %ecx977; X86-NEXT:    andl $21845, %ecx # imm = 0x5555978; X86-NEXT:    shrl %eax979; X86-NEXT:    andl $21845, %eax # imm = 0x5555980; X86-NEXT:    leal (%eax,%ecx,2), %eax981; X86-NEXT:    notl %eax982; X86-NEXT:    andw {{[0-9]+}}(%esp), %ax983; X86-NEXT:    # kill: def $ax killed $ax killed $eax984; X86-NEXT:    retl985;986; X64-NOBMI-LABEL: andnot_bitreverse_i16:987; X64-NOBMI:       # %bb.0:988; X64-NOBMI-NEXT:    # kill: def $esi killed $esi def $rsi989; X64-NOBMI-NEXT:    rolw $8, %si990; X64-NOBMI-NEXT:    movl %esi, %eax991; X64-NOBMI-NEXT:    andl $3855, %eax # imm = 0xF0F992; X64-NOBMI-NEXT:    shll $4, %eax993; X64-NOBMI-NEXT:    shrl $4, %esi994; X64-NOBMI-NEXT:    andl $3855, %esi # imm = 0xF0F995; X64-NOBMI-NEXT:    orl %eax, %esi996; X64-NOBMI-NEXT:    movl %esi, %eax997; X64-NOBMI-NEXT:    andl $13107, %eax # imm = 0x3333998; X64-NOBMI-NEXT:    shrl $2, %esi999; X64-NOBMI-NEXT:    andl $13107, %esi # imm = 0x33331000; X64-NOBMI-NEXT:    leal (%rsi,%rax,4), %eax1001; X64-NOBMI-NEXT:    movl %eax, %ecx1002; X64-NOBMI-NEXT:    andl $21845, %ecx # imm = 0x55551003; X64-NOBMI-NEXT:    shrl %eax1004; X64-NOBMI-NEXT:    andl $21845, %eax # imm = 0x55551005; X64-NOBMI-NEXT:    leal (%rax,%rcx,2), %eax1006; X64-NOBMI-NEXT:    notl %eax1007; X64-NOBMI-NEXT:    andl %edi, %eax1008; X64-NOBMI-NEXT:    # kill: def $ax killed $ax killed $eax1009; X64-NOBMI-NEXT:    retq1010;1011; X64-BMI-LABEL: andnot_bitreverse_i16:1012; X64-BMI:       # %bb.0:1013; X64-BMI-NEXT:    # kill: def $esi killed $esi def $rsi1014; X64-BMI-NEXT:    rolw $8, %si1015; X64-BMI-NEXT:    movl %esi, %eax1016; X64-BMI-NEXT:    andl $3855, %eax # imm = 0xF0F1017; X64-BMI-NEXT:    shll $4, %eax1018; X64-BMI-NEXT:    shrl $4, %esi1019; X64-BMI-NEXT:    andl $3855, %esi # imm = 0xF0F1020; X64-BMI-NEXT:    orl %eax, %esi1021; X64-BMI-NEXT:    movl %esi, %eax1022; X64-BMI-NEXT:    andl $13107, %eax # imm = 0x33331023; X64-BMI-NEXT:    shrl $2, %esi1024; X64-BMI-NEXT:    andl $13107, %esi # imm = 0x33331025; X64-BMI-NEXT:    leal (%rsi,%rax,4), %eax1026; X64-BMI-NEXT:    movl %eax, %ecx1027; X64-BMI-NEXT:    andl $21845, %ecx # imm = 0x55551028; X64-BMI-NEXT:    shrl %eax1029; X64-BMI-NEXT:    andl $21845, %eax # imm = 0x55551030; X64-BMI-NEXT:    leal (%rax,%rcx,2), %eax1031; X64-BMI-NEXT:    andnl %edi, %eax, %eax1032; X64-BMI-NEXT:    # kill: def $ax killed $ax killed $eax1033; X64-BMI-NEXT:    retq1034  %not = xor i16 %a1, -11035  %bitrev = tail call i16 @llvm.bitreverse.i16(i16 %not)1036  %and = and i16 %bitrev, %a01037  ret i16 %and1038}1039 1040define i8 @andnot_bitreverse_i8(i8 %a0, i8 %a1) nounwind {1041; X86-LABEL: andnot_bitreverse_i8:1042; X86:       # %bb.0:1043; X86-NEXT:    movzbl {{[0-9]+}}(%esp), %eax1044; X86-NEXT:    rolb $4, %al1045; X86-NEXT:    movl %eax, %ecx1046; X86-NEXT:    andb $51, %cl1047; X86-NEXT:    shlb $2, %cl1048; X86-NEXT:    shrb $2, %al1049; X86-NEXT:    andb $51, %al1050; X86-NEXT:    orb %cl, %al1051; X86-NEXT:    movl %eax, %ecx1052; X86-NEXT:    andb $85, %cl1053; X86-NEXT:    addb %cl, %cl1054; X86-NEXT:    shrb %al1055; X86-NEXT:    andb $85, %al1056; X86-NEXT:    orb %cl, %al1057; X86-NEXT:    notb %al1058; X86-NEXT:    andb {{[0-9]+}}(%esp), %al1059; X86-NEXT:    retl1060;1061; X64-LABEL: andnot_bitreverse_i8:1062; X64:       # %bb.0:1063; X64-NEXT:    rolb $4, %sil1064; X64-NEXT:    movl %esi, %eax1065; X64-NEXT:    andb $51, %al1066; X64-NEXT:    shlb $2, %al1067; X64-NEXT:    shrb $2, %sil1068; X64-NEXT:    andb $51, %sil1069; X64-NEXT:    orb %sil, %al1070; X64-NEXT:    movl %eax, %ecx1071; X64-NEXT:    andb $85, %cl1072; X64-NEXT:    addb %cl, %cl1073; X64-NEXT:    shrb %al1074; X64-NEXT:    andb $85, %al1075; X64-NEXT:    orb %cl, %al1076; X64-NEXT:    notb %al1077; X64-NEXT:    andb %dil, %al1078; X64-NEXT:    retq1079  %not = xor i8 %a1, -11080  %bitrev = tail call i8 @llvm.bitreverse.i8(i8 %not)1081  %and = and i8 %bitrev, %a01082  ret i8 %and1083}1084