; LLVM IR from libxsmm/libxsmm :: src (generator_common_x86)

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

%struct.libxsmm_generated_code = type { ptr, i32, i32, i32, i32, i32, i32 }

@.str.6 = external hidden unnamed_addr constant [76 x i8], align 1
@libxsmm_ninit = external global i32, align 4
@libxsmm_verbosity = external global i32, align 4
@__func__.libxsmm_generator_cvt_to_ps_avx512 = external hidden unnamed_addr constant [35 x i8], align 1

declare void @libxsmm_x86_instruction_vec_compute_2reg(ptr noundef, i32 noundef, i8 noundef signext, i32 noundef, i32 noundef) #0

declare void @libxsmm_handle_error(ptr noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) #0

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_generator_cvt_to_ps_avx512(ptr noundef %0, i8 noundef signext %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) #1 {
  %6 = alloca ptr, align 8
  %7 = alloca i8, align 1
  %8 = alloca i32, align 4
  %9 = alloca i32, align 4
  %10 = alloca i32, align 4
  store ptr %0, ptr %6, align 8, !tbaa !5
  store i8 %1, ptr %7, align 1, !tbaa !9
  store i32 %2, ptr %8, align 4, !tbaa !10
  store i32 %3, ptr %9, align 4, !tbaa !10
  store i32 %4, ptr %10, align 4, !tbaa !10
  %11 = load ptr, ptr %6, align 8, !tbaa !5
  %12 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %11, i32 0, i32 6
  %13 = load i32, ptr %12, align 4, !tbaa !12
  %14 = icmp ult i32 %13, 1101
  br i1 %14, label %15, label %24

15:                                               ; preds = %5
  %16 = load ptr, ptr %6, align 8, !tbaa !5
  %17 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !10
  %18 = icmp ult i32 1, %17
  br i1 %18, label %19, label %21

19:                                               ; preds = %15
  %20 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !10
  br label %22

21:                                               ; preds = %15
  br label %22

22:                                               ; preds = %21, %19
  %23 = phi i32 [ %20, %19 ], [ 1, %21 ]
  call void @libxsmm_handle_error(ptr noundef %16, i32 noundef 90006, ptr noundef @__func__.libxsmm_generator_cvt_to_ps_avx512, ptr noundef @.str.6, i32 noundef 2933, i32 noundef %23)
  br label %102

24:                                               ; preds = %5
  %25 = load i32, ptr %8, align 4, !tbaa !10
  %26 = icmp eq i32 %25, 1
  br i1 %26, label %27, label %37

27:                                               ; preds = %24
  %28 = load i32, ptr %9, align 4, !tbaa !10
  %29 = load i32, ptr %10, align 4, !tbaa !10
  %30 = icmp ne i32 %28, %29
  br i1 %30, label %31, label %36

31:                                               ; preds = %27
  %32 = load ptr, ptr %6, align 8, !tbaa !5
  %33 = load i8, ptr %7, align 1, !tbaa !9
  %34 = load i32, ptr %9, align 4, !tbaa !10
  %35 = load i32, ptr %10, align 4, !tbaa !10
  call void @libxsmm_x86_instruction_vec_compute_2reg(ptr noundef %32, i32 noundef 537138704, i8 noundef signext %33, i32 noundef %34, i32 noundef %35)
  br label %36

36:                                               ; preds = %31, %27
  br label %102

37:                                               ; preds = %24
  %38 = load i32, ptr %8, align 4, !tbaa !10
  %39 = icmp eq i32 %38, 2
  br i1 %39, label %40, label %45

40:                                               ; preds = %37
  %41 = load ptr, ptr %6, align 8, !tbaa !5
  %42 = load i8, ptr %7, align 1, !tbaa !9
  %43 = load i32, ptr %9, align 4, !tbaa !10
  %44 = load i32, ptr %10, align 4, !tbaa !10
  call void @libxsmm_generator_cvtbf16ps_sse_avx2_avx512(ptr noundef %41, i8 noundef signext %42, i32 noundef %43, i32 noundef %44)
  br label %101

45:                                               ; preds = %37
  %46 = load i32, ptr %8, align 4, !tbaa !10
  %47 = icmp eq i32 %46, 3
  br i1 %47, label %48, label %53

48:                                               ; preds = %45
  %49 = load ptr, ptr %6, align 8, !tbaa !5
  %50 = load i8, ptr %7, align 1, !tbaa !9
  %51 = load i32, ptr %9, align 4, !tbaa !10
  %52 = load i32, ptr %10, align 4, !tbaa !10
  call void @libxsmm_x86_instruction_vec_compute_2reg(ptr noundef %49, i32 noundef 537208083, i8 noundef signext %50, i32 noundef %51, i32 noundef %52)
  br label %100

53:                                               ; preds = %45
  %54 = load i32, ptr %8, align 4, !tbaa !10
  %55 = icmp eq i32 %54, 4
  br i1 %55, label %56, label %61

56:                                               ; preds = %53
  %57 = load ptr, ptr %6, align 8, !tbaa !5
  %58 = load i8, ptr %7, align 1, !tbaa !9
  %59 = load i32, ptr %9, align 4, !tbaa !10
  %60 = load i32, ptr %10, align 4, !tbaa !10
  call void @libxsmm_generator_cvtbf8ps_avx512(ptr noundef %57, i8 noundef signext %58, i32 noundef %59, i32 noundef %60)
  br label %99

61:                                               ; preds = %53
  %62 = load i32, ptr %8, align 4, !tbaa !10
  %63 = icmp eq i32 %62, 5
  br i1 %63, label %64, label %89

64:                                               ; preds = %61
  %65 = load ptr, ptr %6, align 8, !tbaa !5
  %66 = getelementptr inbounds %struct.libxsmm_generated_code, ptr %65, i32 0, i32 6
  %67 = load i32, ptr %66, align 4, !tbaa !12
  %68 = icmp ult i32 %67, 1106
  br i1 %68, label %69, label %74

69:                                               ; preds = %64
  %70 = load ptr, ptr %6, align 8, !tbaa !5
  %71 = load i8, ptr %7, align 1, !tbaa !9
  %72 = load i32, ptr %9, align 4, !tbaa !10
  %73 = load i32, ptr %10, align 4, !tbaa !10
  call void @libxsmm_generator_cvthf8ps_avx512(ptr noundef %70, i8 noundef signext %71, i32 noundef %72, i32 noundef %73)
  br label %88

74:                                               ; preds = %64
  %75 = load ptr, ptr %6, align 8, !tbaa !5
  %76 = load i8, ptr %7, align 1, !tbaa !9
  %77 = sext i8 %76 to i32
  %78 = icmp eq i32 %77, 122
  %79 = zext i1 %78 to i64
  %80 = select i1 %78, i32 121, i32 120
  %81 = trunc i32 %80 to i8
  %82 = load i32, ptr %10, align 4, !tbaa !10
  %83 = load i32, ptr %10, align 4, !tbaa !10
  call void @libxsmm_x86_instruction_vec_compute_2reg(ptr noundef %75, i32 noundef -536390370, i8 noundef signext %81, i32 noundef %82, i32 noundef %83)
  %84 = load ptr, ptr %6, align 8, !tbaa !5
  %85 = load i8, ptr %7, align 1, !tbaa !9
  %86 = load i32, ptr %10, align 4, !tbaa !10
  %87 = load i32, ptr %10, align 4, !tbaa !10
  call void @libxsmm_x86_instruction_vec_compute_2reg(ptr noundef %84, i32 noundef 537208083, i8 noundef signext %85, i32 noundef %86, i32 noundef %87)
  br label %88

88:                                               ; preds = %74, %69
  br label %98

89:                                               ; preds = %61
  %90 = load ptr, ptr %6, align 8, !tbaa !5
  %91 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !10
  %92 = icmp ult i32 1, %91
  br i1 %92, label %93, label %95

93:                                               ; preds = %89
  %94 = load i32, ptr @libxsmm_verbosity, align 4, !tbaa !10
  br label %96

95:                                               ; preds = %89
  br label %96

96:                                               ; preds = %95, %93
  %97 = phi i32 [ %94, %93 ], [ 1, %95 ]
  call void @libxsmm_handle_error(ptr noundef %90, i32 noundef 90033, ptr noundef @__func__.libxsmm_generator_cvt_to_ps_avx512, ptr noundef @.str.6, i32 noundef 2954, i32 noundef %97)
  br label %102

98:                                               ; preds = %88
  br label %99

99:                                               ; preds = %98, %56
  br label %100

100:                                              ; preds = %99, %48
  br label %101

101:                                              ; preds = %100, %40
  br label %102

102:                                              ; preds = %101, %96, %36, %22
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @libxsmm_generator_cvtbf16ps_sse_avx2_avx512(ptr noundef, i8 noundef signext, i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @libxsmm_generator_cvtbf8ps_avx512(ptr noundef, i8 noundef signext, i32 noundef, i32 noundef) #1

; Function Attrs: nounwind uwtable
declare dso_local void @libxsmm_generator_cvthf8ps_avx512(ptr noundef, i8 noundef signext, i32 noundef, i32 noundef) #1

attributes #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 #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" }

!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/C++ TBAA"}
!9 = !{!7, !7, i64 0}
!10 = !{!11, !11, i64 0}
!11 = !{!"int", !7, i64 0}
!12 = !{!13, !11, i64 28}
!13 = !{!"libxsmm_generated_code", !6, i64 0, !11, i64 8, !11, i64 12, !11, i64 16, !11, i64 20, !11, i64 24, !11, i64 28}


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

@.str.6 = external hidden unnamed_addr constant [76 x i8], align 1
@libxsmm_ninit = external local_unnamed_addr global i32, align 4
@libxsmm_verbosity = external local_unnamed_addr global i32, align 4
@__func__.libxsmm_generator_cvt_to_ps_avx512 = external hidden unnamed_addr constant [35 x i8], align 1

declare void @libxsmm_x86_instruction_vec_compute_2reg(ptr noundef, i32 noundef, i8 noundef signext, i32 noundef, i32 noundef) local_unnamed_addr #0

declare void @libxsmm_handle_error(ptr noundef, i32 noundef, ptr noundef, ptr noundef, i32 noundef, i32 noundef) local_unnamed_addr #0

; Function Attrs: nounwind uwtable
define dso_local void @libxsmm_generator_cvt_to_ps_avx512(ptr noundef %0, i8 noundef signext %1, i32 noundef %2, i32 noundef %3, i32 noundef %4) local_unnamed_addr #1 {
  %6 = getelementptr inbounds i8, ptr %0, i64 28
  %7 = load i32, ptr %6, align 4, !tbaa !5
  %8 = icmp ult i32 %7, 1101
  br i1 %8, label %9, label %14

9:                                                ; preds = %5
  %10 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !11
  %11 = icmp ugt i32 %10, 1
  %12 = load i32, ptr @libxsmm_verbosity, align 4
  %13 = select i1 %11, i32 %12, i32 1
  tail call void @libxsmm_handle_error(ptr noundef nonnull %0, i32 noundef 90006, ptr noundef nonnull @__func__.libxsmm_generator_cvt_to_ps_avx512, ptr noundef nonnull @.str.6, i32 noundef 2933, i32 noundef %13) #2
  br label %31

14:                                               ; preds = %5
  switch i32 %2, label %26 [
    i32 1, label %15
    i32 2, label %17
    i32 3, label %18
    i32 4, label %19
    i32 5, label %20
  ]

15:                                               ; preds = %14
  %.not = icmp eq i32 %3, %4
  br i1 %.not, label %31, label %16

16:                                               ; preds = %15
  tail call void @libxsmm_x86_instruction_vec_compute_2reg(ptr noundef nonnull %0, i32 noundef 537138704, i8 noundef signext %1, i32 noundef %3, i32 noundef %4) #2
  br label %31

17:                                               ; preds = %14
  tail call void @libxsmm_generator_cvtbf16ps_sse_avx2_avx512(ptr noundef nonnull %0, i8 noundef signext %1, i32 noundef %3, i32 noundef %4)
  br label %31

18:                                               ; preds = %14
  tail call void @libxsmm_x86_instruction_vec_compute_2reg(ptr noundef nonnull %0, i32 noundef 537208083, i8 noundef signext %1, i32 noundef %3, i32 noundef %4) #2
  br label %31

19:                                               ; preds = %14
  tail call void @libxsmm_generator_cvtbf8ps_avx512(ptr noundef nonnull %0, i8 noundef signext %1, i32 noundef %3, i32 noundef %4)
  br label %31

20:                                               ; preds = %14
  %21 = icmp ult i32 %7, 1106
  br i1 %21, label %22, label %23

22:                                               ; preds = %20
  tail call void @libxsmm_generator_cvthf8ps_avx512(ptr noundef nonnull %0, i8 noundef signext %1, i32 noundef %3, i32 noundef %4)
  br label %31

23:                                               ; preds = %20
  %24 = icmp eq i8 %1, 122
  %25 = select i1 %24, i8 121, i8 120
  tail call void @libxsmm_x86_instruction_vec_compute_2reg(ptr noundef nonnull %0, i32 noundef -536390370, i8 noundef signext %25, i32 noundef %4, i32 noundef %4) #2
  tail call void @libxsmm_x86_instruction_vec_compute_2reg(ptr noundef nonnull %0, i32 noundef 537208083, i8 noundef signext %1, i32 noundef %4, i32 noundef %4) #2
  br label %31

26:                                               ; preds = %14
  %27 = load i32, ptr @libxsmm_ninit, align 4, !tbaa !11
  %28 = icmp ugt i32 %27, 1
  %29 = load i32, ptr @libxsmm_verbosity, align 4
  %30 = select i1 %28, i32 %29, i32 1
  tail call void @libxsmm_handle_error(ptr noundef nonnull %0, i32 noundef 90033, ptr noundef nonnull @__func__.libxsmm_generator_cvt_to_ps_avx512, ptr noundef nonnull @.str.6, i32 noundef 2954, i32 noundef %30) #2
  br label %31

31:                                               ; preds = %17, %19, %22, %23, %18, %15, %16, %26, %9
  ret void
}

; Function Attrs: nounwind uwtable
declare dso_local void @libxsmm_generator_cvtbf16ps_sse_avx2_avx512(ptr noundef, i8 noundef signext, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @libxsmm_generator_cvtbf8ps_avx512(ptr noundef, i8 noundef signext, i32 noundef, i32 noundef) local_unnamed_addr #1

; Function Attrs: nounwind uwtable
declare dso_local void @libxsmm_generator_cvthf8ps_avx512(ptr noundef, i8 noundef signext, i32 noundef, i32 noundef) local_unnamed_addr #1

attributes #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 #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, !10, i64 28}
!6 = !{!"libxsmm_generated_code", !7, i64 0, !10, i64 8, !10, i64 12, !10, i64 16, !10, i64 20, !10, i64 24, !10, i64 28}
!7 = !{!"any pointer", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"int", !8, i64 0}
!11 = !{!10, !10, i64 0}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,IPSCCPPass,InstCombinePass,SROAPass,SimplifyCFGPass,TailCallElimPass