Home | History | Annotate | Download | only in X86
      1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
      2 ; RUN: llc < %s -mtriple=x86_64-unknown | FileCheck %s
      3 
      4 ; SHLD/SHRD manual shifts
      5 
      6 define i64 @test1(i64 %hi, i64 %lo, i64 %bits) nounwind {
      7 ; CHECK-LABEL: test1:
      8 ; CHECK:       # %bb.0:
      9 ; CHECK-NEXT:    andl $63, %edx
     10 ; CHECK-NEXT:    movl %edx, %ecx
     11 ; CHECK-NEXT:    shldq %cl, %rsi, %rdi
     12 ; CHECK-NEXT:    movq %rdi, %rax
     13 ; CHECK-NEXT:    retq
     14   %and = and i64 %bits, 63
     15   %and64 = sub i64 64, %and
     16   %sh_lo = lshr i64 %lo, %and64
     17   %sh_hi = shl i64 %hi, %and
     18   %sh = or i64 %sh_lo, %sh_hi
     19   ret i64 %sh
     20 }
     21 
     22 define i64 @test2(i64 %hi, i64 %lo, i64 %bits) nounwind {
     23 ; CHECK-LABEL: test2:
     24 ; CHECK:       # %bb.0:
     25 ; CHECK-NEXT:    andl $63, %edx
     26 ; CHECK-NEXT:    movl %edx, %ecx
     27 ; CHECK-NEXT:    shrdq %cl, %rdi, %rsi
     28 ; CHECK-NEXT:    movq %rsi, %rax
     29 ; CHECK-NEXT:    retq
     30   %and = and i64 %bits, 63
     31   %and64 = sub i64 64, %and
     32   %sh_lo = shl i64 %hi, %and64
     33   %sh_hi = lshr i64 %lo, %and
     34   %sh = or i64 %sh_lo, %sh_hi
     35   ret i64 %sh
     36 }
     37 
     38 define i64 @test3(i64 %hi, i64 %lo, i64 %bits) nounwind {
     39 ; CHECK-LABEL: test3:
     40 ; CHECK:       # %bb.0:
     41 ; CHECK-NEXT:    movl %edx, %ecx
     42 ; CHECK-NEXT:    shldq %cl, %rsi, %rdi
     43 ; CHECK-NEXT:    movq %rdi, %rax
     44 ; CHECK-NEXT:    retq
     45   %bits64 = sub i64 64, %bits
     46   %sh_lo = lshr i64 %lo, %bits64
     47   %sh_hi = shl i64 %hi, %bits
     48   %sh = or i64 %sh_lo, %sh_hi
     49   ret i64 %sh
     50 }
     51 
     52 define i64 @test4(i64 %hi, i64 %lo, i64 %bits) nounwind {
     53 ; CHECK-LABEL: test4:
     54 ; CHECK:       # %bb.0:
     55 ; CHECK-NEXT:    movl %edx, %ecx
     56 ; CHECK-NEXT:    shrdq %cl, %rdi, %rsi
     57 ; CHECK-NEXT:    movq %rsi, %rax
     58 ; CHECK-NEXT:    retq
     59   %bits64 = sub i64 64, %bits
     60   %sh_lo = shl i64 %hi, %bits64
     61   %sh_hi = lshr i64 %lo, %bits
     62   %sh = or i64 %sh_lo, %sh_hi
     63   ret i64 %sh
     64 }
     65 
     66 define i64 @test5(i64 %hi, i64 %lo, i64 %bits) nounwind {
     67 ; CHECK-LABEL: test5:
     68 ; CHECK:       # %bb.0:
     69 ; CHECK-NEXT:    movl %edx, %ecx
     70 ; CHECK-NEXT:    shldq %cl, %rsi, %rdi
     71 ; CHECK-NEXT:    movq %rdi, %rax
     72 ; CHECK-NEXT:    retq
     73   %bits64 = xor i64 %bits, 63
     74   %lo2 = lshr i64 %lo, 1
     75   %sh_lo = lshr i64 %lo2, %bits64
     76   %sh_hi = shl i64 %hi, %bits
     77   %sh = or i64 %sh_lo, %sh_hi
     78   ret i64 %sh
     79 }
     80 
     81 define i64 @test6(i64 %hi, i64 %lo, i64 %bits) nounwind {
     82 ; CHECK-LABEL: test6:
     83 ; CHECK:       # %bb.0:
     84 ; CHECK-NEXT:    movl %edx, %ecx
     85 ; CHECK-NEXT:    shrdq %cl, %rsi, %rdi
     86 ; CHECK-NEXT:    movq %rdi, %rax
     87 ; CHECK-NEXT:    retq
     88   %bits64 = xor i64 %bits, 63
     89   %lo2 = shl i64 %lo, 1
     90   %sh_lo = shl i64 %lo2, %bits64
     91   %sh_hi = lshr i64 %hi, %bits
     92   %sh = or i64 %sh_lo, %sh_hi
     93   ret i64 %sh
     94 }
     95 
     96 define i64 @test7(i64 %hi, i64 %lo, i64 %bits) nounwind {
     97 ; CHECK-LABEL: test7:
     98 ; CHECK:       # %bb.0:
     99 ; CHECK-NEXT:    movl %edx, %ecx
    100 ; CHECK-NEXT:    shrdq %cl, %rsi, %rdi
    101 ; CHECK-NEXT:    movq %rdi, %rax
    102 ; CHECK-NEXT:    retq
    103   %bits64 = xor i64 %bits, 63
    104   %lo2 = add i64 %lo, %lo
    105   %sh_lo = shl i64 %lo2, %bits64
    106   %sh_hi = lshr i64 %hi, %bits
    107   %sh = or i64 %sh_lo, %sh_hi
    108   ret i64 %sh
    109 }
    110