; LLVM IR from ermig1979/Simd :: src/Simd (SimdBaseSynetMergedConvolution32f)

; 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.Simd::SynetMergedConvolution32f" = type { %"struct.Simd::Deletable", %"struct.Simd::MergConvParam", %"struct.Simd::Array", %"class.std::__cxx11::basic_string" }
%"struct.Simd::Deletable" = type { ptr }
%"struct.Simd::MergConvParam" = type <{ [3 x %"struct.Simd::ConvParam"], i64, i32, [4 x i8] }>
%"struct.Simd::ConvParam" = type <{ %struct.SimdConvolutionParameters, i32, [4 x i8], i64, i32, [4 x i8] }>
%struct.SimdConvolutionParameters = type { i64, i64, i64, i32, i32, i64, i64, i64, i32, i32, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i64, i32 }
%"struct.Simd::Array" = type { ptr, i64 }
%"class.std::__cxx11::basic_string" = type { %"struct.std::__cxx11::basic_string<char>::_Alloc_hider", i64, %union.anon }
%"struct.std::__cxx11::basic_string<char>::_Alloc_hider" = type { ptr }
%union.anon = type { i64, [8 x i8] }
%"class.Simd::Base::SynetMergedConvolution32f" = type { %"class.Simd::SynetMergedConvolution32f", [4 x ptr], i64, i64, [2 x i64], [3 x %"struct.Simd::Array"], [3 x %"struct.Simd::Array"], [3 x %"struct.Simd::Array"], [3 x ptr], [3 x ptr], [3 x ptr], i64, i64, [2 x i64], [2 x i64], [2 x i64], [3 x i64] }

; 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 nounwind uwtable
define dso_local noundef i64 @_ZNK4Simd4Base25SynetMergedConvolution32f18InternalBufferSizeEv(ptr noundef nonnull align 8 dereferenceable(992) %0) unnamed_addr #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca i64, align 8
  %4 = alloca i64, align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %5 = load ptr, ptr %2, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #2
  %6 = getelementptr inbounds %"class.Simd::SynetMergedConvolution32f", ptr %5, i32 0, i32 2
  %7 = getelementptr inbounds %"struct.Simd::Array", ptr %6, i32 0, i32 1
  %8 = load i64, ptr %7, align 8, !tbaa !9
  store i64 %8, ptr %3, align 8, !tbaa !18
  call void @llvm.lifetime.start.p0(i64 8, ptr %4) #2
  store i64 0, ptr %4, align 8, !tbaa !18
  br label %9

9:                                                ; preds = %36, %1
  %10 = load i64, ptr %4, align 8, !tbaa !18
  %11 = getelementptr inbounds %"class.Simd::SynetMergedConvolution32f", ptr %5, i32 0, i32 1
  %12 = getelementptr inbounds %"struct.Simd::MergConvParam", ptr %11, i32 0, i32 1
  %13 = load i64, ptr %12, align 8, !tbaa !19
  %14 = icmp ult i64 %10, %13
  br i1 %14, label %16, label %15

15:                                               ; preds = %9
  call void @llvm.lifetime.end.p0(i64 8, ptr %4) #2
  br label %39

16:                                               ; preds = %9
  %17 = getelementptr inbounds %"class.Simd::Base::SynetMergedConvolution32f", ptr %5, i32 0, i32 5
  %18 = load i64, ptr %4, align 8, !tbaa !18
  %19 = getelementptr inbounds [3 x %"struct.Simd::Array"], ptr %17, i64 0, i64 %18
  %20 = getelementptr inbounds %"struct.Simd::Array", ptr %19, i32 0, i32 1
  %21 = load i64, ptr %20, align 8, !tbaa !20
  %22 = getelementptr inbounds %"class.Simd::Base::SynetMergedConvolution32f", ptr %5, i32 0, i32 6
  %23 = load i64, ptr %4, align 8, !tbaa !18
  %24 = getelementptr inbounds [3 x %"struct.Simd::Array"], ptr %22, i64 0, i64 %23
  %25 = getelementptr inbounds %"struct.Simd::Array", ptr %24, i32 0, i32 1
  %26 = load i64, ptr %25, align 8, !tbaa !20
  %27 = add i64 %21, %26
  %28 = getelementptr inbounds %"class.Simd::Base::SynetMergedConvolution32f", ptr %5, i32 0, i32 7
  %29 = load i64, ptr %4, align 8, !tbaa !18
  %30 = getelementptr inbounds [3 x %"struct.Simd::Array"], ptr %28, i64 0, i64 %29
  %31 = getelementptr inbounds %"struct.Simd::Array", ptr %30, i32 0, i32 1
  %32 = load i64, ptr %31, align 8, !tbaa !20
  %33 = add i64 %27, %32
  %34 = load i64, ptr %3, align 8, !tbaa !18
  %35 = add i64 %34, %33
  store i64 %35, ptr %3, align 8, !tbaa !18
  br label %36

36:                                               ; preds = %16
  %37 = load i64, ptr %4, align 8, !tbaa !18
  %38 = add i64 %37, 1
  store i64 %38, ptr %4, align 8, !tbaa !18
  br label %9, !llvm.loop !21

39:                                               ; preds = %15
  %40 = load i64, ptr %3, align 8, !tbaa !18
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #2
  ret i64 %40
}

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #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 = !{!"any pointer", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{!10, !13, i64 584}
!10 = !{!"_ZTSN4Simd25SynetMergedConvolution32fE", !11, i64 0, !12, i64 8, !15, i64 576, !16, i64 592}
!11 = !{!"_ZTSN4Simd9DeletableE"}
!12 = !{!"_ZTSN4Simd13MergConvParamE", !7, i64 0, !13, i64 552, !14, i64 560}
!13 = !{!"long", !7, i64 0}
!14 = !{!"_ZTS8SimdBool", !7, i64 0}
!15 = !{!"_ZTSN4Simd5ArrayIfEE", !6, i64 0, !13, i64 8}
!16 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !17, i64 0, !13, i64 8, !7, i64 16}
!17 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!18 = !{!13, !13, i64 0}
!19 = !{!10, !13, i64 560}
!20 = !{!15, !13, i64 8}
!21 = distinct !{!21, !22}
!22 = !{!"llvm.loop.mustprogress"}


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

%"struct.Simd::Array" = type { ptr, i64 }

; Function Attrs: mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) uwtable
define dso_local noundef i64 @_ZNK4Simd4Base25SynetMergedConvolution32f18InternalBufferSizeEv(ptr nocapture noundef nonnull readonly align 8 dereferenceable(992) %0) unnamed_addr #0 align 2 {
  %2 = getelementptr inbounds i8, ptr %0, i64 584
  %3 = load i64, ptr %2, align 8, !tbaa !5
  %4 = getelementptr inbounds i8, ptr %0, i64 560
  %5 = load i64, ptr %4, align 8, !tbaa !17
  %.not = icmp eq i64 %5, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %1
  %6 = getelementptr inbounds i8, ptr %0, i64 688
  %7 = getelementptr inbounds i8, ptr %0, i64 736
  %8 = getelementptr inbounds i8, ptr %0, i64 784
  %xtraiter = and i64 %5, 1
  %9 = icmp eq i64 %5, 1
  br i1 %9, label %._crit_edge.loopexit.unr-lcssa, label %.lr.ph.new

.lr.ph.new:                                       ; preds = %.lr.ph
  %unroll_iter = and i64 %5, -2
  br label %19

._crit_edge.loopexit.unr-lcssa:                   ; preds = %19, %.lr.ph
  %.lcssa.ph = phi i64 [ poison, %.lr.ph ], [ %38, %19 ]
  %.09.unr = phi i64 [ 0, %.lr.ph ], [ %39, %19 ]
  %.078.unr = phi i64 [ %3, %.lr.ph ], [ %38, %19 ]
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %._crit_edge, label %._crit_edge.loopexit.epilog-lcssa

._crit_edge.loopexit.epilog-lcssa:                ; preds = %._crit_edge.loopexit.unr-lcssa
  %10 = getelementptr inbounds [3 x %"struct.Simd::Array"], ptr %6, i64 0, i64 %.09.unr, i32 1
  %11 = load i64, ptr %10, align 8, !tbaa !18
  %12 = getelementptr inbounds [3 x %"struct.Simd::Array"], ptr %7, i64 0, i64 %.09.unr, i32 1
  %13 = load i64, ptr %12, align 8, !tbaa !18
  %14 = getelementptr inbounds [3 x %"struct.Simd::Array"], ptr %8, i64 0, i64 %.09.unr, i32 1
  %15 = load i64, ptr %14, align 8, !tbaa !18
  %16 = add i64 %11, %.078.unr
  %17 = add i64 %16, %13
  %18 = add i64 %17, %15
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit.epilog-lcssa, %._crit_edge.loopexit.unr-lcssa, %1
  %.07.lcssa = phi i64 [ %3, %1 ], [ %.lcssa.ph, %._crit_edge.loopexit.unr-lcssa ], [ %18, %._crit_edge.loopexit.epilog-lcssa ]
  ret i64 %.07.lcssa

19:                                               ; preds = %19, %.lr.ph.new
  %.09 = phi i64 [ 0, %.lr.ph.new ], [ %39, %19 ]
  %.078 = phi i64 [ %3, %.lr.ph.new ], [ %38, %19 ]
  %niter = phi i64 [ 0, %.lr.ph.new ], [ %niter.next.1, %19 ]
  %20 = getelementptr inbounds [3 x %"struct.Simd::Array"], ptr %6, i64 0, i64 %.09, i32 1
  %21 = load i64, ptr %20, align 8, !tbaa !18
  %22 = getelementptr inbounds [3 x %"struct.Simd::Array"], ptr %7, i64 0, i64 %.09, i32 1
  %23 = load i64, ptr %22, align 8, !tbaa !18
  %24 = getelementptr inbounds [3 x %"struct.Simd::Array"], ptr %8, i64 0, i64 %.09, i32 1
  %25 = load i64, ptr %24, align 8, !tbaa !18
  %26 = add i64 %21, %.078
  %27 = add i64 %26, %23
  %28 = add i64 %27, %25
  %29 = or disjoint i64 %.09, 1
  %30 = getelementptr inbounds [3 x %"struct.Simd::Array"], ptr %6, i64 0, i64 %29, i32 1
  %31 = load i64, ptr %30, align 8, !tbaa !18
  %32 = getelementptr inbounds [3 x %"struct.Simd::Array"], ptr %7, i64 0, i64 %29, i32 1
  %33 = load i64, ptr %32, align 8, !tbaa !18
  %34 = getelementptr inbounds [3 x %"struct.Simd::Array"], ptr %8, i64 0, i64 %29, i32 1
  %35 = load i64, ptr %34, align 8, !tbaa !18
  %36 = add i64 %31, %28
  %37 = add i64 %36, %33
  %38 = add i64 %37, %35
  %39 = add nuw i64 %.09, 2
  %niter.next.1 = add i64 %niter, 2
  %niter.ncmp.1 = icmp eq i64 %niter.next.1, %unroll_iter
  br i1 %niter.ncmp.1, label %._crit_edge.loopexit.unr-lcssa, label %19, !llvm.loop !19
}

attributes #0 = { mustprogress nofree norecurse nosync nounwind willreturn memory(argmem: read) 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, !11, i64 584}
!6 = !{!"_ZTSN4Simd25SynetMergedConvolution32fE", !7, i64 0, !8, i64 8, !13, i64 576, !15, i64 592}
!7 = !{!"_ZTSN4Simd9DeletableE"}
!8 = !{!"_ZTSN4Simd13MergConvParamE", !9, i64 0, !11, i64 552, !12, i64 560}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"long", !9, i64 0}
!12 = !{!"_ZTS8SimdBool", !9, i64 0}
!13 = !{!"_ZTSN4Simd5ArrayIfEE", !14, i64 0, !11, i64 8}
!14 = !{!"any pointer", !9, i64 0}
!15 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !16, i64 0, !11, i64 8, !9, i64 16}
!16 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !14, i64 0}
!17 = !{!6, !11, i64 560}
!18 = !{!13, !11, i64 8}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,GVNPass,GlobalOptPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass