brintos

brintos / llvm-project-archived public Read only

0
0
Text · 9.2 KiB · c705505 Raw
328 lines · plain
1; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py2; RUN: llc < %s -mtriple=i686-unknown-unknown | FileCheck %s --check-prefixes=X863; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s --check-prefixes=X644 5define i32 @test_simple_rotl(i32 %x) {6; X86-LABEL: test_simple_rotl:7; X86:       # %bb.0:8; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax9; X86-NEXT:    roll $7, %eax10; X86-NEXT:    retl11;12; X64-LABEL: test_simple_rotl:13; X64:       # %bb.0:14; X64-NEXT:    movl %edi, %eax15; X64-NEXT:    roll $7, %eax16; X64-NEXT:    retq17  %shl = shl i32 %x, 718  %shr = lshr i32 %x, 2519  %add = add i32 %shl, %shr20  ret i32 %add21}22 23define i32 @test_simple_rotr(i32 %x) {24; X86-LABEL: test_simple_rotr:25; X86:       # %bb.0:26; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax27; X86-NEXT:    roll $25, %eax28; X86-NEXT:    retl29;30; X64-LABEL: test_simple_rotr:31; X64:       # %bb.0:32; X64-NEXT:    movl %edi, %eax33; X64-NEXT:    roll $25, %eax34; X64-NEXT:    retq35  %shr = lshr i32 %x, 736  %shl = shl i32 %x, 2537  %add = add i32 %shr, %shl38  ret i32 %add39}40 41define i32 @test_rotl_var(i32 %x, i32 %y) {42; X86-LABEL: test_rotl_var:43; X86:       # %bb.0:44; X86-NEXT:    movzbl {{[0-9]+}}(%esp), %ecx45; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax46; X86-NEXT:    roll %cl, %eax47; X86-NEXT:    retl48;49; X64-LABEL: test_rotl_var:50; X64:       # %bb.0:51; X64-NEXT:    movl %esi, %ecx52; X64-NEXT:    movl %edi, %eax53; X64-NEXT:    # kill: def $cl killed $cl killed $ecx54; X64-NEXT:    roll %cl, %eax55; X64-NEXT:    retq56  %shl = shl i32 %x, %y57  %sub = sub i32 32, %y58  %shr = lshr i32 %x, %sub59  %add = add i32 %shl, %shr60  ret i32 %add61}62 63define i32 @test_rotr_var(i32 %x, i32 %y) {64; X86-LABEL: test_rotr_var:65; X86:       # %bb.0:66; X86-NEXT:    movzbl {{[0-9]+}}(%esp), %ecx67; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax68; X86-NEXT:    rorl %cl, %eax69; X86-NEXT:    retl70;71; X64-LABEL: test_rotr_var:72; X64:       # %bb.0:73; X64-NEXT:    movl %esi, %ecx74; X64-NEXT:    movl %edi, %eax75; X64-NEXT:    # kill: def $cl killed $cl killed $ecx76; X64-NEXT:    rorl %cl, %eax77; X64-NEXT:    retq78  %shr = lshr i32 %x, %y79  %sub = sub i32 32, %y80  %shl = shl i32 %x, %sub81  %add = add i32 %shr, %shl82  ret i32 %add83}84 85define i32 @test_invalid_rotl_var_and(i32 %x, i32 %y) {86; X86-LABEL: test_invalid_rotl_var_and:87; X86:       # %bb.0:88; X86-NEXT:    movzbl {{[0-9]+}}(%esp), %ecx89; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax90; X86-NEXT:    movl %eax, %edx91; X86-NEXT:    shll %cl, %edx92; X86-NEXT:    negb %cl93; X86-NEXT:    shrl %cl, %eax94; X86-NEXT:    addl %edx, %eax95; X86-NEXT:    retl96;97; X64-LABEL: test_invalid_rotl_var_and:98; X64:       # %bb.0:99; X64-NEXT:    movl %esi, %ecx100; X64-NEXT:    movl %edi, %eax101; X64-NEXT:    shll %cl, %eax102; X64-NEXT:    negb %cl103; X64-NEXT:    # kill: def $cl killed $cl killed $ecx104; X64-NEXT:    shrl %cl, %edi105; X64-NEXT:    addl %edi, %eax106; X64-NEXT:    retq107  %shr = shl i32 %x, %y108  %sub = sub nsw i32 0, %y109  %and = and i32 %sub, 31110  %shl = lshr i32 %x, %and111  %add = add i32 %shl, %shr112  ret i32 %add113}114 115define i32 @test_invalid_rotr_var_and(i32 %x, i32 %y) {116; X86-LABEL: test_invalid_rotr_var_and:117; X86:       # %bb.0:118; X86-NEXT:    movzbl {{[0-9]+}}(%esp), %ecx119; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax120; X86-NEXT:    movl %eax, %edx121; X86-NEXT:    shrl %cl, %edx122; X86-NEXT:    negb %cl123; X86-NEXT:    shll %cl, %eax124; X86-NEXT:    addl %edx, %eax125; X86-NEXT:    retl126;127; X64-LABEL: test_invalid_rotr_var_and:128; X64:       # %bb.0:129; X64-NEXT:    movl %esi, %ecx130; X64-NEXT:    movl %edi, %eax131; X64-NEXT:    shrl %cl, %eax132; X64-NEXT:    negb %cl133; X64-NEXT:    # kill: def $cl killed $cl killed $ecx134; X64-NEXT:    shll %cl, %edi135; X64-NEXT:    addl %edi, %eax136; X64-NEXT:    retq137  %shr = lshr i32 %x, %y138  %sub = sub nsw i32 0, %y139  %and = and i32 %sub, 31140  %shl = shl i32 %x, %and141  %add = add i32 %shr, %shl142  ret i32 %add143}144 145define i32 @test_fshl_special_case(i32 %x0, i32 %x1, i32 %y) {146; X86-LABEL: test_fshl_special_case:147; X86:       # %bb.0:148; X86-NEXT:    movzbl {{[0-9]+}}(%esp), %ecx149; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx150; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax151; X86-NEXT:    shldl %cl, %edx, %eax152; X86-NEXT:    retl153;154; X64-LABEL: test_fshl_special_case:155; X64:       # %bb.0:156; X64-NEXT:    movl %edx, %ecx157; X64-NEXT:    movl %edi, %eax158; X64-NEXT:    # kill: def $cl killed $cl killed $ecx159; X64-NEXT:    shldl %cl, %esi, %eax160; X64-NEXT:    retq161  %shl = shl i32 %x0, %y162  %srli = lshr i32 %x1, 1163  %x = xor i32 %y, 31164  %srlo = lshr i32 %srli, %x165  %o = add i32 %shl, %srlo166  ret i32 %o167}168 169define i32 @test_fshr_special_case(i32 %x0, i32 %x1, i32 %y) {170; X86-LABEL: test_fshr_special_case:171; X86:       # %bb.0:172; X86-NEXT:    movzbl {{[0-9]+}}(%esp), %ecx173; X86-NEXT:    movl {{[0-9]+}}(%esp), %edx174; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax175; X86-NEXT:    shrdl %cl, %edx, %eax176; X86-NEXT:    retl177;178; X64-LABEL: test_fshr_special_case:179; X64:       # %bb.0:180; X64-NEXT:    movl %edx, %ecx181; X64-NEXT:    movl %esi, %eax182; X64-NEXT:    # kill: def $cl killed $cl killed $ecx183; X64-NEXT:    shrdl %cl, %edi, %eax184; X64-NEXT:    retq185  %shl = lshr i32 %x1, %y186  %srli = shl i32 %x0, 1187  %x = xor i32 %y, 31188  %srlo = shl i32 %srli, %x189  %o = add i32 %shl, %srlo190  ret i32 %o191}192 193define i64 @test_rotl_udiv_special_case(i64 %i) {194; X86-LABEL: test_rotl_udiv_special_case:195; X86:       # %bb.0:196; X86-NEXT:    pushl %ebx197; X86-NEXT:    .cfi_def_cfa_offset 8198; X86-NEXT:    pushl %edi199; X86-NEXT:    .cfi_def_cfa_offset 12200; X86-NEXT:    pushl %esi201; X86-NEXT:    .cfi_def_cfa_offset 16202; X86-NEXT:    .cfi_offset %esi, -16203; X86-NEXT:    .cfi_offset %edi, -12204; X86-NEXT:    .cfi_offset %ebx, -8205; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx206; X86-NEXT:    movl {{[0-9]+}}(%esp), %edi207; X86-NEXT:    movl %ecx, %esi208; X86-NEXT:    addl %edi, %esi209; X86-NEXT:    adcl $0, %esi210; X86-NEXT:    movl $-1431655765, %ebx # imm = 0xAAAAAAAB211; X86-NEXT:    movl %esi, %eax212; X86-NEXT:    mull %ebx213; X86-NEXT:    shrl %edx214; X86-NEXT:    leal (%edx,%edx,2), %eax215; X86-NEXT:    subl %eax, %esi216; X86-NEXT:    subl %esi, %ecx217; X86-NEXT:    sbbl $0, %edi218; X86-NEXT:    movl %ecx, %eax219; X86-NEXT:    mull %ebx220; X86-NEXT:    imull $-1431655766, %ecx, %ecx # imm = 0xAAAAAAAA221; X86-NEXT:    addl %ecx, %edx222; X86-NEXT:    imull $-1431655765, %edi, %ecx # imm = 0xAAAAAAAB223; X86-NEXT:    addl %ecx, %edx224; X86-NEXT:    movl %edx, %ecx225; X86-NEXT:    shldl $28, %eax, %ecx226; X86-NEXT:    shrdl $4, %eax, %edx227; X86-NEXT:    movl %ecx, %eax228; X86-NEXT:    popl %esi229; X86-NEXT:    .cfi_def_cfa_offset 12230; X86-NEXT:    popl %edi231; X86-NEXT:    .cfi_def_cfa_offset 8232; X86-NEXT:    popl %ebx233; X86-NEXT:    .cfi_def_cfa_offset 4234; X86-NEXT:    retl235;236; X64-LABEL: test_rotl_udiv_special_case:237; X64:       # %bb.0:238; X64-NEXT:    movq %rdi, %rax239; X64-NEXT:    movabsq $-6148914691236517205, %rcx # imm = 0xAAAAAAAAAAAAAAAB240; X64-NEXT:    mulq %rcx241; X64-NEXT:    movq %rdx, %rax242; X64-NEXT:    shrq %rax243; X64-NEXT:    rolq $60, %rax244; X64-NEXT:    retq245  %lhs_div = udiv i64 %i, 3246  %rhs_div = udiv i64 %i, 48247  %lhs_shift = shl i64 %lhs_div, 60248  %out = add i64 %lhs_shift, %rhs_div249  ret i64 %out250}251 252define i32 @test_rotl_mul_special_case(i32 %i) {253; X86-LABEL: test_rotl_mul_special_case:254; X86:       # %bb.0:255; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax256; X86-NEXT:    leal (%eax,%eax,8), %eax257; X86-NEXT:    roll $7, %eax258; X86-NEXT:    retl259;260; X64-LABEL: test_rotl_mul_special_case:261; X64:       # %bb.0:262; X64-NEXT:    # kill: def $edi killed $edi def $rdi263; X64-NEXT:    leal (%rdi,%rdi,8), %eax264; X64-NEXT:    roll $7, %eax265; X64-NEXT:    retq266  %lhs_mul = mul i32 %i, 9267  %rhs_mul = mul i32 %i, 1152268  %lhs_shift = lshr i32 %lhs_mul, 25269  %out = add i32 %lhs_shift, %rhs_mul270  ret i32 %out271}272 273define i64 @test_rotl_mul_with_mask_special_case(i64 %i) {274; X86-LABEL: test_rotl_mul_with_mask_special_case:275; X86:       # %bb.0:276; X86-NEXT:    movl {{[0-9]+}}(%esp), %eax277; X86-NEXT:    leal (%eax,%eax,8), %ecx278; X86-NEXT:    movl $9, %eax279; X86-NEXT:    mull {{[0-9]+}}(%esp)280; X86-NEXT:    addl %ecx, %edx281; X86-NEXT:    shrdl $25, %eax, %edx282; X86-NEXT:    movzbl %dl, %eax283; X86-NEXT:    xorl %edx, %edx284; X86-NEXT:    retl285;286; X64-LABEL: test_rotl_mul_with_mask_special_case:287; X64:       # %bb.0:288; X64-NEXT:    leaq (%rdi,%rdi,8), %rax289; X64-NEXT:    # kill: def $edi killed $edi killed $rdi def $rdi290; X64-NEXT:    shll $7, %edi291; X64-NEXT:    leal (%rdi,%rdi,8), %ecx292; X64-NEXT:    movzbl %cl, %ecx293; X64-NEXT:    shrq $57, %rax294; X64-NEXT:    orq %rcx, %rax295; X64-NEXT:    retq296  %lhs_mul = mul i64 %i, 1152297  %rhs_mul = mul i64 %i, 9298  %lhs_and = and i64 %lhs_mul, 160299  %rhs_shift = lshr i64 %rhs_mul, 57300  %out = add i64 %lhs_and, %rhs_shift301  ret i64 %out302}303 304define i32 @test_fshl_with_mask_special_case(i32 %x) {305; X86-LABEL: test_fshl_with_mask_special_case:306; X86:       # %bb.0:307; X86-NEXT:    movl {{[0-9]+}}(%esp), %ecx308; X86-NEXT:    movl %ecx, %eax309; X86-NEXT:    orl $1, %eax310; X86-NEXT:    shldl $5, %ecx, %eax311; X86-NEXT:    andl $-31, %eax312; X86-NEXT:    retl313;314; X64-LABEL: test_fshl_with_mask_special_case:315; X64:       # %bb.0:316; X64-NEXT:    movl %edi, %eax317; X64-NEXT:    orl $1, %eax318; X64-NEXT:    shldl $5, %edi, %eax319; X64-NEXT:    andl $-31, %eax320; X64-NEXT:    retq321  %or1 = or i32 %x, 1322  %sh1 = shl i32 %or1, 5323  %sh2 = lshr i32 %x, 27324  %1 = and i32 %sh2, 1325  %r = add i32 %sh1, %1326  ret i32 %r327}328