; LLVM IR from sslab-gatech/janus :: lkl/drivers/gpu/drm/amd/display/dc/calcs (dcn_calc_math)

; 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"

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #0

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

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

; Function Attrs: nounwind uwtable
define dso_local float @dcn_bw_log(float noundef %0, float noundef %1) #2 {
  %3 = alloca float, align 4
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca ptr, align 8
  %7 = alloca i32, align 4
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  store float %0, ptr %4, align 4, !tbaa !5
  store float %1, ptr %5, align 4, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %6) #3
  store ptr %4, ptr %6, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %7) #3
  %10 = load ptr, ptr %6, align 8, !tbaa !9
  %11 = load i32, ptr %10, align 4, !tbaa !11
  store i32 %11, ptr %7, align 4, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %8) #3
  %12 = load i32, ptr %7, align 4, !tbaa !11
  %13 = ashr i32 %12, 23
  %14 = and i32 %13, 255
  %15 = sub nsw i32 %14, 128
  store i32 %15, ptr %8, align 4, !tbaa !11
  %16 = load i32, ptr %7, align 4, !tbaa !11
  %17 = and i32 %16, -2139095041
  store i32 %17, ptr %7, align 4, !tbaa !11
  %18 = load i32, ptr %7, align 4, !tbaa !11
  %19 = add nsw i32 %18, 1065353216
  store i32 %19, ptr %7, align 4, !tbaa !11
  %20 = load i32, ptr %7, align 4, !tbaa !11
  %21 = load ptr, ptr %6, align 8, !tbaa !9
  store i32 %20, ptr %21, align 4, !tbaa !11
  %22 = load float, ptr %4, align 4, !tbaa !5
  %23 = call float @llvm.fmuladd.f32(float 0xBFD5555560000000, float %22, float 2.000000e+00)
  %24 = load float, ptr %4, align 4, !tbaa !5
  %25 = call float @llvm.fmuladd.f32(float %23, float %24, float 0xBFE5555560000000)
  store float %25, ptr %4, align 4, !tbaa !5
  %26 = load float, ptr %5, align 4, !tbaa !5
  %27 = fpext float %26 to double
  %28 = fcmp ogt double %27, 2.000010e+00
  br i1 %28, label %33, label %29

29:                                               ; preds = %2
  %30 = load float, ptr %5, align 4, !tbaa !5
  %31 = fpext float %30 to double
  %32 = fcmp olt double %31, 1.999990e+00
  br i1 %32, label %33, label %41

33:                                               ; preds = %29, %2
  %34 = load float, ptr %4, align 4, !tbaa !5
  %35 = load i32, ptr %8, align 4, !tbaa !11
  %36 = sitofp i32 %35 to float
  %37 = fadd float %34, %36
  %38 = load float, ptr %5, align 4, !tbaa !5
  %39 = call float @dcn_bw_log(float noundef %38, float noundef 2.000000e+00)
  %40 = fdiv float %37, %39
  store float %40, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %46

41:                                               ; preds = %29
  %42 = load float, ptr %4, align 4, !tbaa !5
  %43 = load i32, ptr %8, align 4, !tbaa !11
  %44 = sitofp i32 %43 to float
  %45 = fadd float %42, %44
  store float %45, ptr %3, align 4
  store i32 1, ptr %9, align 4
  br label %46

46:                                               ; preds = %41, %33
  call void @llvm.lifetime.end.p0(i64 4, ptr %8) #3
  call void @llvm.lifetime.end.p0(i64 4, ptr %7) #3
  call void @llvm.lifetime.end.p0(i64 8, ptr %6) #3
  %47 = load float, ptr %3, align 4
  ret float %47
}

attributes #0 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"any pointer", !7, i64 0}
!11 = !{!12, !12, i64 0}
!12 = !{!"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 nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #0

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(none) uwtable
define dso_local float @dcn_bw_log(float noundef %0, float noundef %1) local_unnamed_addr #1 {
  %3 = bitcast float %0 to i32
  %4 = lshr i32 %3, 23
  %5 = and i32 %4, 255
  %6 = add nsw i32 %5, -128
  %7 = and i32 %3, -2139095041
  %8 = or disjoint i32 %7, 1065353216
  %9 = bitcast i32 %8 to float
  %10 = tail call float @llvm.fmuladd.f32(float %9, float 0xBFD5555560000000, float 2.000000e+00)
  %11 = tail call float @llvm.fmuladd.f32(float %10, float %9, float 0xBFE5555560000000)
  %12 = fpext float %1 to double
  %13 = fcmp ogt double %12, 2.000010e+00
  %14 = fcmp olt double %12, 1.999990e+00
  %or.cond = or i1 %13, %14
  %15 = sitofp i32 %6 to float
  %16 = fadd float %11, %15
  br i1 %or.cond, label %17, label %30

17:                                               ; preds = %2
  %18 = bitcast float %1 to i32
  %19 = lshr i32 %18, 23
  %20 = and i32 %19, 255
  %21 = add nsw i32 %20, -128
  %22 = and i32 %18, -2139095041
  %23 = or disjoint i32 %22, 1065353216
  %24 = bitcast i32 %23 to float
  %25 = tail call float @llvm.fmuladd.f32(float %24, float 0xBFD5555560000000, float 2.000000e+00)
  %26 = tail call float @llvm.fmuladd.f32(float %25, float %24, float 0xBFE5555560000000)
  %27 = sitofp i32 %21 to float
  %28 = fadd float %26, %27
  %29 = fdiv float %16, %28
  br label %30

30:                                               ; preds = %2, %17
  %.0 = phi float [ %29, %17 ], [ %16, %2 ]
  ret float %.0
}

attributes #0 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #1 = { mustprogress nofree norecurse nosync nounwind willreturn memory(none) 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)"}


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