; 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 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: nounwind uwtable
define dso_local float @dcn_bw_pow(float noundef %0, float noundef %1) #1 {
  %3 = alloca float, align 4
  %4 = alloca float, align 4
  %5 = alloca float, align 4
  %6 = alloca float, align 4
  %7 = 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 4, ptr %6) #2
  %8 = load float, ptr %5, align 4, !tbaa !5
  %9 = fptosi float %8 to i32
  %10 = icmp eq i32 %9, 0
  br i1 %10, label %11, label %12

11:                                               ; preds = %2
  store float 1.000000e+00, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %43

12:                                               ; preds = %2
  %13 = load float, ptr %4, align 4, !tbaa !5
  %14 = load float, ptr %5, align 4, !tbaa !5
  %15 = fdiv float %14, 2.000000e+00
  %16 = fptosi float %15 to i32
  %17 = sitofp i32 %16 to float
  %18 = call float @dcn_bw_pow(float noundef %13, float noundef %17)
  store float %18, ptr %6, align 4, !tbaa !5
  %19 = load float, ptr %5, align 4, !tbaa !5
  %20 = fptosi float %19 to i32
  %21 = srem i32 %20, 2
  %22 = icmp eq i32 %21, 0
  br i1 %22, label %23, label %27

23:                                               ; preds = %12
  %24 = load float, ptr %6, align 4, !tbaa !5
  %25 = load float, ptr %6, align 4, !tbaa !5
  %26 = fmul float %24, %25
  store float %26, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %43

27:                                               ; preds = %12
  %28 = load float, ptr %5, align 4, !tbaa !5
  %29 = fptosi float %28 to i32
  %30 = icmp sgt i32 %29, 0
  br i1 %30, label %31, label %37

31:                                               ; preds = %27
  %32 = load float, ptr %4, align 4, !tbaa !5
  %33 = load float, ptr %6, align 4, !tbaa !5
  %34 = fmul float %32, %33
  %35 = load float, ptr %6, align 4, !tbaa !5
  %36 = fmul float %34, %35
  store float %36, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %43

37:                                               ; preds = %27
  %38 = load float, ptr %6, align 4, !tbaa !5
  %39 = load float, ptr %6, align 4, !tbaa !5
  %40 = fmul float %38, %39
  %41 = load float, ptr %4, align 4, !tbaa !5
  %42 = fdiv float %40, %41
  store float %42, ptr %3, align 4
  store i32 1, ptr %7, align 4
  br label %43

43:                                               ; preds = %37, %31, %23, %11
  call void @llvm.lifetime.end.p0(i64 4, ptr %6) #2
  %44 = load float, ptr %3, align 4
  ret float %44
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { 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"}


; 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: nofree nosync nounwind memory(none) uwtable
define dso_local float @dcn_bw_pow(float noundef %0, float noundef %1) local_unnamed_addr #0 {
  %3 = fptosi float %1 to i32
  %4 = icmp eq i32 %3, 0
  br i1 %4, label %22, label %5

5:                                                ; preds = %2
  %6 = fmul float %1, 5.000000e-01
  %7 = fptosi float %6 to i32
  %8 = sitofp i32 %7 to float
  %9 = tail call float @dcn_bw_pow(float noundef %0, float noundef %8)
  %10 = and i32 %3, 1
  %11 = icmp eq i32 %10, 0
  br i1 %11, label %12, label %14

12:                                               ; preds = %5
  %13 = fmul float %9, %9
  br label %22

14:                                               ; preds = %5
  %15 = icmp sgt i32 %3, 0
  br i1 %15, label %16, label %19

16:                                               ; preds = %14
  %17 = fmul float %9, %0
  %18 = fmul float %9, %17
  br label %22

19:                                               ; preds = %14
  %20 = fmul float %9, %9
  %21 = fdiv float %20, %0
  br label %22

22:                                               ; preds = %2, %19, %16, %12
  %.0 = phi float [ %13, %12 ], [ %18, %16 ], [ %21, %19 ], [ 1.000000e+00, %2 ]
  ret float %.0
}

attributes #0 = { nofree nosync nounwind 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,InferFunctionAttrsPass,InstCombinePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass