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

; 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::SynetConvolution16b" = type { %"struct.Simd::Deletable", %"struct.Simd::ConvParam", %"struct.Simd::Array", %"class.std::__cxx11::basic_string", %"struct.Simd::Array.0", %"struct.Simd::Array.1", %"struct.Simd::Array.1", i8, i8, i8, i64, i64, i64, i64 }
%"struct.Simd::Deletable" = type { ptr }
%"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] }
%"struct.Simd::Array.0" = type { ptr, i64 }
%"struct.Simd::Array.1" = type { ptr, i64 }
%"class.Simd::Base::SynetConvolution16bNhwcDepthwise" = type { %"class.Simd::SynetConvolution16b", i64, i64, %"struct.Simd::Array.1", ptr }

; 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 void @_ZN4Simd4Base32SynetConvolution16bNhwcDepthwise7ForwardEPKhPhS4_(ptr noundef nonnull align 8 dereferenceable(368) %0, ptr noundef %1, ptr noundef %2, ptr noundef %3) unnamed_addr #1 align 2 {
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca ptr, align 8
  %10 = alloca i64, align 8
  store ptr %0, ptr %5, align 8, !tbaa !5
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %3, ptr %8, align 8, !tbaa !5
  %11 = load ptr, ptr %5, align 8
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %12 = getelementptr inbounds %"class.Simd::SynetConvolution16b", ptr %11, i32 0, i32 1
  store ptr %12, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %10) #2
  store i64 0, ptr %10, align 8, !tbaa !9
  br label %13

13:                                               ; preds = %43, %4
  %14 = load i64, ptr %10, align 8, !tbaa !9
  %15 = load ptr, ptr %9, align 8, !tbaa !5
  %16 = getelementptr inbounds %"struct.Simd::ConvParam", ptr %15, i32 0, i32 3
  %17 = load i64, ptr %16, align 8, !tbaa !11
  %18 = icmp ult i64 %14, %17
  br i1 %18, label %20, label %19

19:                                               ; preds = %13
  call void @llvm.lifetime.end.p0(i64 8, ptr %10) #2
  br label %46

20:                                               ; preds = %13
  %21 = getelementptr inbounds %"class.Simd::Base::SynetConvolution16bNhwcDepthwise", ptr %11, i32 0, i32 4
  %22 = load ptr, ptr %21, align 8, !tbaa !19
  %23 = load ptr, ptr %6, align 8, !tbaa !5
  %24 = getelementptr inbounds %"class.Simd::SynetConvolution16b", ptr %11, i32 0, i32 1
  %25 = getelementptr inbounds %"class.Simd::Base::SynetConvolution16bNhwcDepthwise", ptr %11, i32 0, i32 3
  %26 = getelementptr inbounds %"struct.Simd::Array.1", ptr %25, i32 0, i32 0
  %27 = load ptr, ptr %26, align 8, !tbaa !29
  %28 = getelementptr inbounds %"class.Simd::SynetConvolution16b", ptr %11, i32 0, i32 5
  %29 = getelementptr inbounds %"struct.Simd::Array.1", ptr %28, i32 0, i32 0
  %30 = load ptr, ptr %29, align 8, !tbaa !30
  %31 = getelementptr inbounds %"class.Simd::SynetConvolution16b", ptr %11, i32 0, i32 6
  %32 = getelementptr inbounds %"struct.Simd::Array.1", ptr %31, i32 0, i32 0
  %33 = load ptr, ptr %32, align 8, !tbaa !31
  %34 = load ptr, ptr %8, align 8, !tbaa !5
  call void %22(ptr noundef %23, ptr noundef nonnull align 8 dereferenceable(180) %24, ptr noundef %27, ptr noundef %30, ptr noundef %33, ptr noundef %34)
  %35 = getelementptr inbounds %"class.Simd::SynetConvolution16b", ptr %11, i32 0, i32 12
  %36 = load i64, ptr %35, align 8, !tbaa !32
  %37 = load ptr, ptr %6, align 8, !tbaa !5
  %38 = getelementptr inbounds i8, ptr %37, i64 %36
  store ptr %38, ptr %6, align 8, !tbaa !5
  %39 = getelementptr inbounds %"class.Simd::SynetConvolution16b", ptr %11, i32 0, i32 13
  %40 = load i64, ptr %39, align 8, !tbaa !33
  %41 = load ptr, ptr %8, align 8, !tbaa !5
  %42 = getelementptr inbounds i8, ptr %41, i64 %40
  store ptr %42, ptr %8, align 8, !tbaa !5
  br label %43

43:                                               ; preds = %20
  %44 = load i64, ptr %10, align 8, !tbaa !9
  %45 = add i64 %44, 1
  store i64 %45, ptr %10, align 8, !tbaa !9
  br label %13, !llvm.loop !34

46:                                               ; preds = %19
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  ret void
}

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 = { 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, !10, i64 0}
!10 = !{!"long", !7, i64 0}
!11 = !{!12, !10, i64 168}
!12 = !{!"_ZTSN4Simd9ConvParamE", !13, i64 0, !17, i64 160, !10, i64 168, !18, i64 176}
!13 = !{!"_ZTS25SimdConvolutionParameters", !10, i64 0, !10, i64 8, !10, i64 16, !14, i64 24, !15, i64 28, !10, i64 32, !10, i64 40, !10, i64 48, !14, i64 56, !15, i64 60, !10, i64 64, !10, i64 72, !10, i64 80, !10, i64 88, !10, i64 96, !10, i64 104, !10, i64 112, !10, i64 120, !10, i64 128, !10, i64 136, !10, i64 144, !16, i64 152}
!14 = !{!"_ZTS18SimdTensorDataType", !7, i64 0}
!15 = !{!"_ZTS20SimdTensorFormatType", !7, i64 0}
!16 = !{!"_ZTS29SimdConvolutionActivationType", !7, i64 0}
!17 = !{!"_ZTS8SimdBool", !7, i64 0}
!18 = !{!"_ZTS26SimdSynetCompatibilityType", !7, i64 0}
!19 = !{!20, !6, i64 360}
!20 = !{!"_ZTSN4Simd4Base32SynetConvolution16bNhwcDepthwiseE", !21, i64 0, !10, i64 328, !10, i64 336, !27, i64 344, !6, i64 360}
!21 = !{!"_ZTSN4Simd19SynetConvolution16bE", !22, i64 0, !12, i64 8, !23, i64 192, !24, i64 208, !26, i64 240, !27, i64 256, !27, i64 272, !28, i64 288, !28, i64 289, !28, i64 290, !10, i64 296, !10, i64 304, !10, i64 312, !10, i64 320}
!22 = !{!"_ZTSN4Simd9DeletableE"}
!23 = !{!"_ZTSN4Simd5ArrayIhEE", !6, i64 0, !10, i64 8}
!24 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !25, i64 0, !10, i64 8, !7, i64 16}
!25 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !6, i64 0}
!26 = !{!"_ZTSN4Simd5ArrayItEE", !6, i64 0, !10, i64 8}
!27 = !{!"_ZTSN4Simd5ArrayIfEE", !6, i64 0, !10, i64 8}
!28 = !{!"bool", !7, i64 0}
!29 = !{!20, !6, i64 344}
!30 = !{!21, !6, i64 256}
!31 = !{!21, !6, i64 272}
!32 = !{!21, !10, i64 312}
!33 = !{!21, !10, i64 320}
!34 = distinct !{!34, !35}
!35 = !{!"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"

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN4Simd4Base32SynetConvolution16bNhwcDepthwise7ForwardEPKhPhS4_(ptr noundef nonnull align 8 dereferenceable(368) %0, ptr noundef %1, ptr nocapture noundef readnone %2, ptr noundef %3) unnamed_addr #0 align 2 {
  %5 = getelementptr inbounds i8, ptr %0, i64 8
  %6 = getelementptr inbounds i8, ptr %0, i64 176
  %7 = load i64, ptr %6, align 8, !tbaa !5
  %.not = icmp eq i64 %7, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %4
  %8 = getelementptr inbounds i8, ptr %0, i64 360
  %9 = getelementptr inbounds i8, ptr %0, i64 344
  %10 = getelementptr inbounds i8, ptr %0, i64 256
  %11 = getelementptr inbounds i8, ptr %0, i64 272
  %12 = getelementptr inbounds i8, ptr %0, i64 312
  %13 = getelementptr inbounds i8, ptr %0, i64 320
  br label %14

._crit_edge:                                      ; preds = %14, %4
  ret void

14:                                               ; preds = %.lr.ph, %14
  %.011 = phi i64 [ 0, %.lr.ph ], [ %23, %14 ]
  %.0710 = phi ptr [ %1, %.lr.ph ], [ %20, %14 ]
  %.089 = phi ptr [ %3, %.lr.ph ], [ %22, %14 ]
  %15 = load ptr, ptr %8, align 8, !tbaa !16
  %16 = load ptr, ptr %9, align 8, !tbaa !27
  %17 = load ptr, ptr %10, align 8, !tbaa !28
  %18 = load ptr, ptr %11, align 8, !tbaa !29
  tail call void %15(ptr noundef %.0710, ptr noundef nonnull align 8 dereferenceable(180) %5, ptr noundef %16, ptr noundef %17, ptr noundef %18, ptr noundef %.089)
  %19 = load i64, ptr %12, align 8, !tbaa !30
  %20 = getelementptr inbounds i8, ptr %.0710, i64 %19
  %21 = load i64, ptr %13, align 8, !tbaa !31
  %22 = getelementptr inbounds i8, ptr %.089, i64 %21
  %23 = add nuw i64 %.011, 1
  %24 = load i64, ptr %6, align 8, !tbaa !5
  %25 = icmp ult i64 %23, %24
  br i1 %25, label %14, label %._crit_edge, !llvm.loop !32
}

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

!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, !8, i64 168}
!6 = !{!"_ZTSN4Simd9ConvParamE", !7, i64 0, !14, i64 160, !8, i64 168, !15, i64 176}
!7 = !{!"_ZTS25SimdConvolutionParameters", !8, i64 0, !8, i64 8, !8, i64 16, !11, i64 24, !12, i64 28, !8, i64 32, !8, i64 40, !8, i64 48, !11, i64 56, !12, i64 60, !8, i64 64, !8, i64 72, !8, i64 80, !8, i64 88, !8, i64 96, !8, i64 104, !8, i64 112, !8, i64 120, !8, i64 128, !8, i64 136, !8, i64 144, !13, i64 152}
!8 = !{!"long", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!"_ZTS18SimdTensorDataType", !9, i64 0}
!12 = !{!"_ZTS20SimdTensorFormatType", !9, i64 0}
!13 = !{!"_ZTS29SimdConvolutionActivationType", !9, i64 0}
!14 = !{!"_ZTS8SimdBool", !9, i64 0}
!15 = !{!"_ZTS26SimdSynetCompatibilityType", !9, i64 0}
!16 = !{!17, !21, i64 360}
!17 = !{!"_ZTSN4Simd4Base32SynetConvolution16bNhwcDepthwiseE", !18, i64 0, !8, i64 328, !8, i64 336, !25, i64 344, !21, i64 360}
!18 = !{!"_ZTSN4Simd19SynetConvolution16bE", !19, i64 0, !6, i64 8, !20, i64 192, !22, i64 208, !24, i64 240, !25, i64 256, !25, i64 272, !26, i64 288, !26, i64 289, !26, i64 290, !8, i64 296, !8, i64 304, !8, i64 312, !8, i64 320}
!19 = !{!"_ZTSN4Simd9DeletableE"}
!20 = !{!"_ZTSN4Simd5ArrayIhEE", !21, i64 0, !8, i64 8}
!21 = !{!"any pointer", !9, i64 0}
!22 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE", !23, i64 0, !8, i64 8, !9, i64 16}
!23 = !{!"_ZTSNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEE12_Alloc_hiderE", !21, i64 0}
!24 = !{!"_ZTSN4Simd5ArrayItEE", !21, i64 0, !8, i64 8}
!25 = !{!"_ZTSN4Simd5ArrayIfEE", !21, i64 0, !8, i64 8}
!26 = !{!"bool", !9, i64 0}
!27 = !{!17, !21, i64 344}
!28 = !{!18, !21, i64 256}
!29 = !{!18, !21, i64 272}
!30 = !{!18, !8, i64 312}
!31 = !{!18, !8, i64 320}
!32 = distinct !{!32, !33}
!33 = !{!"llvm.loop.mustprogress"}


; Effective O3 passes: CorrelatedValuePropagationPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,JumpThreadingPass,LICMPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,PostOrderFunctionAttrsPass,SROAPass,SimplifyCFGPass,TailCallElimPass