llvm/llvm/test/CodeGen/X86/pr38217.ll

; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
; RUN: llc < %s -mtriple=x86_64-unknown-unknown | FileCheck %s

@_ZL11DIGIT_TABLE = dso_local constant [201 x i8] c"00010203040506070809101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899\00", align 16

define dso_local void @_Z12d2s_bufferedmPc(i64 %arg, ptr nocapture %arg1) {
; CHECK-LABEL: _Z12d2s_bufferedmPc:
; CHECK:       # %bb.0: # %bb
; CHECK-NEXT:    cmpq $10000, %rdi # imm = 0x2710
; CHECK-NEXT:    jb .LBB0_3
; CHECK-NEXT:  # %bb.1: # %bb2.preheader
; CHECK-NEXT:    xorl %ecx, %ecx
; CHECK-NEXT:    movabsq $3777893186295716171, %r8 # imm = 0x346DC5D63886594B
; CHECK-NEXT:    .p2align 4
; CHECK-NEXT:  .LBB0_2: # %bb2
; CHECK-NEXT:    # =>This Inner Loop Header: Depth=1
; CHECK-NEXT:    movq %rdi, %rax
; CHECK-NEXT:    mulq %r8
; CHECK-NEXT:    shrq $11, %rdx
; CHECK-NEXT:    imulq $10000, %rdx, %rax # imm = 0x2710
; CHECK-NEXT:    movq %rdi, %r9
; CHECK-NEXT:    subq %rax, %r9
; CHECK-NEXT:    imulq $42949673, %r9, %rax # imm = 0x28F5C29
; CHECK-NEXT:    shrq $32, %rax
; CHECK-NEXT:    imull $100, %eax, %r10d
; CHECK-NEXT:    subl %r10d, %r9d
; CHECK-NEXT:    movl %ecx, %r10d
; CHECK-NEXT:    movq %rsi, %r11
; CHECK-NEXT:    subq %r10, %r11
; CHECK-NEXT:    movzwl _ZL11DIGIT_TABLE(%r9,%r9), %r9d
; CHECK-NEXT:    movw %r9w, -1(%r11)
; CHECK-NEXT:    movzwl _ZL11DIGIT_TABLE(%rax,%rax), %eax
; CHECK-NEXT:    movw %ax, -3(%r11)
; CHECK-NEXT:    addl $4, %ecx
; CHECK-NEXT:    cmpq $99999999, %rdi # imm = 0x5F5E0FF
; CHECK-NEXT:    movq %rdx, %rdi
; CHECK-NEXT:    ja .LBB0_2
; CHECK-NEXT:  .LBB0_3: # %bb29
; CHECK-NEXT:    retq
bb:
  %i = icmp ugt i64 %arg, 9999
  br i1 %i, label %bb2, label %bb29

bb2:                                              ; preds = %bb2, %bb
  %i3 = phi i64 [ %i7, %bb2 ], [ %arg, %bb ]
  %i4 = phi i32 [ %i27, %bb2 ], [ 0, %bb ]
  %i5 = urem i64 %i3, 10000
  %i6 = trunc i64 %i5 to i32
  %i7 = udiv i64 %i3, 10000
  %i8 = urem i32 %i6, 100
  %i9 = shl nuw nsw i32 %i8, 1
  %i10 = udiv i32 %i6, 100
  %i11 = shl nuw nsw i32 %i10, 1
  %i12 = zext i32 %i4 to i64
  %i13 = sub nsw i64 0, %i12
  %i14 = getelementptr inbounds i8, ptr %arg1, i64 %i13
  %i15 = getelementptr inbounds i8, ptr %i14, i64 -1
  %i16 = zext i32 %i9 to i64
  %i17 = getelementptr inbounds [201 x i8], ptr @_ZL11DIGIT_TABLE, i64 0, i64 %i16
  %i20 = load i16, ptr %i17, align 2
  store i16 %i20, ptr %i15, align 1
  %i21 = getelementptr inbounds i8, ptr %i14, i64 -3
  %i22 = zext i32 %i11 to i64
  %i23 = getelementptr inbounds [201 x i8], ptr @_ZL11DIGIT_TABLE, i64 0, i64 %i22
  %i26 = load i16, ptr %i23, align 2
  store i16 %i26, ptr %i21, align 1
  %i27 = add i32 %i4, 4
  %i28 = icmp ugt i64 %i3, 99999999
  br i1 %i28, label %bb2, label %bb29

bb29:                                             ; preds = %bb2, %bb
  ret void
}