; LLVM IR from google/uVkCompute :: uvkc/benchmark/data_type_util.ll (ZNK4uvkc9benchmark4fp167toFloatEv)

; Unoptimized IR (clang -disable-llvm-passes):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

%"class.uvkc::benchmark::fp16" = type { i16 }

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress uwtable
define dso_local noundef float @_ZNK4uvkc9benchmark4fp167toFloatEv(ptr noundef nonnull align 2 dereferenceable(2) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  %5 = alloca i32, align 4
  %6 = alloca i32, align 4
  store ptr %0, ptr %2, align 8, !tbaa !5
  %7 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #3
  %8 = getelementptr inbounds %"class.uvkc::benchmark::fp16", ptr %7, i32 0, i32 0
  %9 = load i16, ptr %8, align 2, !tbaa !9
  %10 = zext i16 %9 to i32
  store i32 %10, ptr %3, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #3
  %11 = load i32, ptr %3, align 4, !tbaa !12
  %12 = and i32 %11, 32768
  %13 = lshr i32 %12, 15
  store i32 %13, ptr %4, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %5) #3
  %14 = load i32, ptr %3, align 4, !tbaa !12
  %15 = and i32 %14, 31744
  %16 = lshr i32 %15, 10
  store i32 %16, ptr %5, align 4, !tbaa !12
  call void @llvm.lifetime.start.p0(i64 4, ptr %6) #3
  %17 = load i32, ptr %3, align 4, !tbaa !12
  %18 = and i32 %17, 1023
  store i32 %18, ptr %6, align 4, !tbaa !12
  %19 = load i32, ptr %4, align 4, !tbaa !12
  %20 = shl i32 %19, 31
  store i32 %20, ptr %4, align 4, !tbaa !12
  %21 = load i32, ptr %5, align 4, !tbaa !12
  %22 = icmp sgt i32 %21, 0
  br i1 %22, label %23, label %30

23:                                               ; preds = %1
  %24 = load i32, ptr %5, align 4, !tbaa !12
  %25 = add nsw i32 %24, 127
  %26 = sub nsw i32 %25, 15
  %27 = shl i32 %26, 23
  store i32 %27, ptr %5, align 4, !tbaa !12
  %28 = load i32, ptr %6, align 4, !tbaa !12
  %29 = shl i32 %28, 13
  store i32 %29, ptr %6, align 4, !tbaa !12
  br label %31

30:                                               ; preds = %1
  store i32 0, ptr %6, align 4, !tbaa !12
  br label %31

31:                                               ; preds = %30, %23
  %32 = load i32, ptr %4, align 4, !tbaa !12
  %33 = load i32, ptr %5, align 4, !tbaa !12
  %34 = or i32 %32, %33
  %35 = load i32, ptr %6, align 4, !tbaa !12
  %36 = or i32 %34, %35
  store i32 %36, ptr %3, align 4, !tbaa !12
  %37 = load i32, ptr %3, align 4, !tbaa !12
  %38 = call noundef float @_ZN4uvkc9benchmarkL7bitcastIfjEET_T0_(i32 noundef %37)
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %5) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #3
  ret float %38
}

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef float @_ZN4uvkc9benchmarkL7bitcastIfjEET_T0_(i32 noundef) #2

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #2 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }
attributes #3 = { nounwind }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !6, i64 0}
!6 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !11, i64 0}
!10 = !{!"_ZTSN4uvkc9benchmark4fp16E", !11, i64 0}
!11 = !{!"short", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"int", !7, i64 0}


; Optimized IR (opt -passes='default<O3>'):
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128"
target triple = "x86_64-unknown-linux-gnu"

; Function Attrs: mustprogress nounwind uwtable
define dso_local noundef float @_ZNK4uvkc9benchmark4fp167toFloatEv(ptr nocapture noundef nonnull readonly align 2 dereferenceable(2) %0) local_unnamed_addr #0 align 2 {
  %2 = load i16, ptr %0, align 2, !tbaa !5
  %3 = zext i16 %2 to i32
  %4 = lshr i32 %3, 10
  %5 = and i32 %4, 31
  %.not = icmp eq i32 %5, 0
  %6 = shl nuw nsw i32 %5, 23
  %7 = add nuw nsw i32 %6, 939524096
  %8 = shl nuw nsw i32 %3, 13
  %9 = and i32 %8, 8380416
  %.011 = select i1 %.not, i32 0, i32 %7
  %.0 = select i1 %.not, i32 0, i32 %9
  %.signext = sext i16 %2 to i32
  %10 = and i32 %.signext, -2147483648
  %11 = or disjoint i32 %.0, %10
  %12 = or disjoint i32 %11, %.011
  %13 = tail call noundef float @_ZN4uvkc9benchmarkL7bitcastIfjEET_T0_(i32 noundef %12)
  ret float %13
}

; Function Attrs: mustprogress nounwind uwtable
declare hidden noundef float @_ZN4uvkc9benchmarkL7bitcastIfjEET_T0_(i32 noundef) local_unnamed_addr #0

attributes #0 = { mustprogress nounwind uwtable "min-legal-vector-width"="0" "no-trapping-math"="true" "stack-protector-buffer-size"="8" "target-cpu"="x86-64" "target-features"="+cmov,+cx8,+fxsr,+mmx,+sse,+sse2,+x87" "tune-cpu"="generic" }

!llvm.module.flags = !{!0, !1, !2, !3}
!llvm.ident = !{!4}

!0 = !{i32 1, !"wchar_size", i32 4}
!1 = !{i32 8, !"PIC Level", i32 2}
!2 = !{i32 7, !"PIE Level", i32 2}
!3 = !{i32 7, !"uwtable", i32 2}
!4 = !{!"clang version 19.1.0 (git@github.com:llvm/llvm-project.git a4bf6cd7cfb1a1421ba92bca9d017b49936c55e4)"}
!5 = !{!6, !7, i64 0}
!6 = !{!"_ZTSN4uvkc9benchmark4fp16E", !7, i64 0}
!7 = !{!"short", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C++ TBAA"}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass