llvm/llvm/test/Transforms/LICM/2008-07-22-LoadGlobalConstant.ll

; NOTE: Assertions have been autogenerated by utils/update_test_checks.py
; RUN: opt < %s -passes=licm -S | FileCheck %s

@a = external constant ptr

define void @test(i32 %count) {
; CHECK-LABEL: @test(
; CHECK-NEXT:  entry:
; CHECK-NEXT:    [[TMP3:%.*]] = load ptr, ptr @a, align 8
; CHECK-NEXT:    br label [[FORCOND:%.*]]
; CHECK:       forcond:
; CHECK-NEXT:    [[I_0:%.*]] = phi i32 [ 0, [[ENTRY:%.*]] ], [ [[INC:%.*]], [[FORBODY:%.*]] ]
; CHECK-NEXT:    [[CMP:%.*]] = icmp ult i32 [[I_0]], [[COUNT:%.*]]
; CHECK-NEXT:    br i1 [[CMP]], label [[FORBODY]], label [[AFTERFOR:%.*]]
; CHECK:       forbody:
; CHECK-NEXT:    [[ARRAYIDX:%.*]] = getelementptr float, ptr [[TMP3]], i32 [[I_0]]
; CHECK-NEXT:    [[TMP7:%.*]] = uitofp i32 [[I_0]] to float
; CHECK-NEXT:    store float [[TMP7]], ptr [[ARRAYIDX]], align 4
; CHECK-NEXT:    [[INC]] = add i32 [[I_0]], 1
; CHECK-NEXT:    br label [[FORCOND]]
; CHECK:       afterfor:
; CHECK-NEXT:    ret void
;
entry:
  br label %forcond

forcond:
  %i.0 = phi i32 [ 0, %entry ], [ %inc, %forbody ]
  %cmp = icmp ult i32 %i.0, %count
  br i1 %cmp, label %forbody, label %afterfor

forbody:
  %tmp3 = load ptr, ptr @a
  %arrayidx = getelementptr float, ptr %tmp3, i32 %i.0
  %tmp7 = uitofp i32 %i.0 to float
  store float %tmp7, ptr %arrayidx
  %inc = add i32 %i.0, 1
  br label %forcond

afterfor:
  ret void
}