; LLVM IR from FedericaPaoli1/stm32-speech-recognition-and-traduction :: Drivers/CMSIS/DSP/Source/MatrixFunctions (arm_mat_add_f32)

; 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.arm_matrix_instance_f32 = type { i16, i16, ptr }

; Function Attrs: nounwind uwtable
define dso_local i32 @arm_mat_add_f32(ptr noundef %0, ptr noundef %1, ptr noundef %2) #0 {
  %4 = alloca ptr, align 8
  %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 i32, align 4
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  store ptr %0, ptr %4, align 8, !tbaa !5
  store ptr %1, ptr %5, align 8, !tbaa !5
  store ptr %2, ptr %6, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %7) #2
  %13 = load ptr, ptr %4, align 8, !tbaa !5
  %14 = getelementptr inbounds %struct.arm_matrix_instance_f32, ptr %13, i32 0, i32 2
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  store ptr %15, ptr %7, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %8) #2
  %16 = load ptr, ptr %5, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.arm_matrix_instance_f32, ptr %16, i32 0, i32 2
  %18 = load ptr, ptr %17, align 8, !tbaa !9
  store ptr %18, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 8, ptr %9) #2
  %19 = load ptr, ptr %6, align 8, !tbaa !5
  %20 = getelementptr inbounds %struct.arm_matrix_instance_f32, ptr %19, i32 0, i32 2
  %21 = load ptr, ptr %20, align 8, !tbaa !9
  store ptr %21, ptr %9, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #2
  %22 = load ptr, ptr %4, align 8, !tbaa !5
  %23 = getelementptr inbounds %struct.arm_matrix_instance_f32, ptr %22, i32 0, i32 0
  %24 = load i16, ptr %23, align 8, !tbaa !12
  %25 = zext i16 %24 to i32
  %26 = load ptr, ptr %4, align 8, !tbaa !5
  %27 = getelementptr inbounds %struct.arm_matrix_instance_f32, ptr %26, i32 0, i32 1
  %28 = load i16, ptr %27, align 2, !tbaa !13
  %29 = zext i16 %28 to i32
  %30 = mul i32 %25, %29
  store i32 %30, ptr %10, align 4, !tbaa !14
  %31 = load i32, ptr %10, align 4, !tbaa !14
  store i32 %31, ptr %11, align 4, !tbaa !14
  br label %32

32:                                               ; preds = %35, %3
  %33 = load i32, ptr %11, align 4, !tbaa !14
  %34 = icmp ugt i32 %33, 0
  br i1 %34, label %35, label %47

35:                                               ; preds = %32
  %36 = load ptr, ptr %7, align 8, !tbaa !5
  %37 = getelementptr inbounds float, ptr %36, i32 1
  store ptr %37, ptr %7, align 8, !tbaa !5
  %38 = load float, ptr %36, align 4, !tbaa !16
  %39 = load ptr, ptr %8, align 8, !tbaa !5
  %40 = getelementptr inbounds float, ptr %39, i32 1
  store ptr %40, ptr %8, align 8, !tbaa !5
  %41 = load float, ptr %39, align 4, !tbaa !16
  %42 = fadd float %38, %41
  %43 = load ptr, ptr %9, align 8, !tbaa !5
  %44 = getelementptr inbounds float, ptr %43, i32 1
  store ptr %44, ptr %9, align 8, !tbaa !5
  store float %42, ptr %43, align 4, !tbaa !16
  %45 = load i32, ptr %11, align 4, !tbaa !14
  %46 = add i32 %45, -1
  store i32 %46, ptr %11, align 4, !tbaa !14
  br label %32, !llvm.loop !18

47:                                               ; preds = %32
  store i32 0, ptr %12, align 4, !tbaa !14
  %48 = load i32, ptr %12, align 4, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %10) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %9) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %8) #2
  call void @llvm.lifetime.end.p0(i64 8, ptr %7) #2
  ret i32 %48
}

; 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

attributes #0 = { 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
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/C++ TBAA"}
!9 = !{!10, !6, i64 8}
!10 = !{!"", !11, i64 0, !11, i64 2, !6, i64 8}
!11 = !{!"short", !7, i64 0}
!12 = !{!10, !11, i64 0}
!13 = !{!10, !11, i64 2}
!14 = !{!15, !15, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!17, !17, i64 0}
!17 = !{!"float", !7, i64 0}
!18 = distinct !{!18, !19}
!19 = !{!"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: nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: none) uwtable
define dso_local noundef i32 @arm_mat_add_f32(ptr nocapture noundef readonly %0, ptr nocapture noundef readonly %1, ptr nocapture noundef readonly %2) local_unnamed_addr #0 {
  %4 = load i16, ptr %0, align 8, !tbaa !5
  %5 = zext i16 %4 to i32
  %6 = getelementptr inbounds i8, ptr %0, i64 2
  %7 = load i16, ptr %6, align 2, !tbaa !11
  %8 = zext i16 %7 to i32
  %9 = mul nuw i32 %8, %5
  %.not14 = icmp eq i32 %9, 0
  br i1 %.not14, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %3
  %10 = getelementptr inbounds i8, ptr %2, i64 8
  %11 = load ptr, ptr %10, align 8, !tbaa !12
  %12 = getelementptr inbounds i8, ptr %1, i64 8
  %13 = load ptr, ptr %12, align 8, !tbaa !12
  %14 = getelementptr inbounds i8, ptr %0, i64 8
  %15 = load ptr, ptr %14, align 8, !tbaa !12
  %16 = zext i16 %4 to i64
  %17 = zext i16 %7 to i64
  %18 = mul nuw nsw i64 %16, %17
  %min.iters.check = icmp ult i64 %18, 8
  br i1 %min.iters.check, label %.lr.ph.preheader36, label %vector.memcheck

vector.memcheck:                                  ; preds = %.lr.ph.preheader
  %19 = ptrtoint ptr %15 to i64
  %20 = ptrtoint ptr %13 to i64
  %21 = ptrtoint ptr %11 to i64
  %22 = sub i64 %21, %19
  %diff.check = icmp ult i64 %22, 32
  %23 = sub i64 %21, %20
  %diff.check19 = icmp ult i64 %23, 32
  %conflict.rdx = or i1 %diff.check, %diff.check19
  br i1 %conflict.rdx, label %.lr.ph.preheader36, label %vector.ph

vector.ph:                                        ; preds = %vector.memcheck
  %n.vec = and i64 %18, 4294967288
  %24 = shl nuw nsw i64 %n.vec, 2
  %ind.end = getelementptr i8, ptr %15, i64 %24
  %.cast = trunc nuw i64 %n.vec to i32
  %ind.end20 = sub i32 %9, %.cast
  %25 = shl nuw nsw i64 %n.vec, 2
  %ind.end22 = getelementptr i8, ptr %13, i64 %25
  %26 = shl nuw nsw i64 %n.vec, 2
  %ind.end24 = getelementptr i8, ptr %11, i64 %26
  br label %vector.body

vector.body:                                      ; preds = %vector.body, %vector.ph
  %index = phi i64 [ 0, %vector.ph ], [ %index.next, %vector.body ]
  %offset.idx = shl i64 %index, 2
  %next.gep = getelementptr i8, ptr %15, i64 %offset.idx
  %offset.idx27 = shl i64 %index, 2
  %next.gep28 = getelementptr i8, ptr %13, i64 %offset.idx27
  %offset.idx30 = shl i64 %index, 2
  %next.gep31 = getelementptr i8, ptr %11, i64 %offset.idx30
  %27 = getelementptr i8, ptr %next.gep, i64 16
  %wide.load = load <4 x float>, ptr %next.gep, align 4, !tbaa !13
  %wide.load33 = load <4 x float>, ptr %27, align 4, !tbaa !13
  %28 = getelementptr i8, ptr %next.gep28, i64 16
  %wide.load34 = load <4 x float>, ptr %next.gep28, align 4, !tbaa !13
  %wide.load35 = load <4 x float>, ptr %28, align 4, !tbaa !13
  %29 = fadd <4 x float> %wide.load, %wide.load34
  %30 = fadd <4 x float> %wide.load33, %wide.load35
  %31 = getelementptr i8, ptr %next.gep31, i64 16
  store <4 x float> %29, ptr %next.gep31, align 4, !tbaa !13
  store <4 x float> %30, ptr %31, align 4, !tbaa !13
  %index.next = add nuw i64 %index, 8
  %32 = icmp eq i64 %index.next, %n.vec
  br i1 %32, label %middle.block, label %vector.body, !llvm.loop !15

middle.block:                                     ; preds = %vector.body
  %cmp.n = icmp eq i64 %18, %n.vec
  br i1 %cmp.n, label %._crit_edge, label %.lr.ph.preheader36

.lr.ph.preheader36:                               ; preds = %middle.block, %vector.memcheck, %.lr.ph.preheader
  %.018.ph = phi ptr [ %15, %vector.memcheck ], [ %15, %.lr.ph.preheader ], [ %ind.end, %middle.block ]
  %.01117.ph = phi i32 [ %9, %vector.memcheck ], [ %9, %.lr.ph.preheader ], [ %ind.end20, %middle.block ]
  %.01216.ph = phi ptr [ %13, %vector.memcheck ], [ %13, %.lr.ph.preheader ], [ %ind.end22, %middle.block ]
  %.01315.ph = phi ptr [ %11, %vector.memcheck ], [ %11, %.lr.ph.preheader ], [ %ind.end24, %middle.block ]
  %33 = add i32 %.01117.ph, -1
  %xtraiter = and i32 %.01117.ph, 3
  %lcmp.mod.not = icmp eq i32 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol

.lr.ph.prol:                                      ; preds = %.lr.ph.preheader36, %.lr.ph.prol
  %.018.prol = phi ptr [ %34, %.lr.ph.prol ], [ %.018.ph, %.lr.ph.preheader36 ]
  %.01117.prol = phi i32 [ %40, %.lr.ph.prol ], [ %.01117.ph, %.lr.ph.preheader36 ]
  %.01216.prol = phi ptr [ %36, %.lr.ph.prol ], [ %.01216.ph, %.lr.ph.preheader36 ]
  %.01315.prol = phi ptr [ %39, %.lr.ph.prol ], [ %.01315.ph, %.lr.ph.preheader36 ]
  %prol.iter = phi i32 [ %prol.iter.next, %.lr.ph.prol ], [ 0, %.lr.ph.preheader36 ]
  %34 = getelementptr inbounds i8, ptr %.018.prol, i64 4
  %35 = load float, ptr %.018.prol, align 4, !tbaa !13
  %36 = getelementptr inbounds i8, ptr %.01216.prol, i64 4
  %37 = load float, ptr %.01216.prol, align 4, !tbaa !13
  %38 = fadd float %35, %37
  %39 = getelementptr inbounds i8, ptr %.01315.prol, i64 4
  store float %38, ptr %.01315.prol, align 4, !tbaa !13
  %40 = add i32 %.01117.prol, -1
  %prol.iter.next = add i32 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i32 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %.lr.ph.prol.loopexit, label %.lr.ph.prol, !llvm.loop !19

.lr.ph.prol.loopexit:                             ; preds = %.lr.ph.prol, %.lr.ph.preheader36
  %.018.unr = phi ptr [ %.018.ph, %.lr.ph.preheader36 ], [ %34, %.lr.ph.prol ]
  %.01117.unr = phi i32 [ %.01117.ph, %.lr.ph.preheader36 ], [ %40, %.lr.ph.prol ]
  %.01216.unr = phi ptr [ %.01216.ph, %.lr.ph.preheader36 ], [ %36, %.lr.ph.prol ]
  %.01315.unr = phi ptr [ %.01315.ph, %.lr.ph.preheader36 ], [ %39, %.lr.ph.prol ]
  %41 = icmp ult i32 %33, 3
  br i1 %41, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %.lr.ph.prol.loopexit, %.lr.ph
  %.018 = phi ptr [ %60, %.lr.ph ], [ %.018.unr, %.lr.ph.prol.loopexit ]
  %.01117 = phi i32 [ %66, %.lr.ph ], [ %.01117.unr, %.lr.ph.prol.loopexit ]
  %.01216 = phi ptr [ %62, %.lr.ph ], [ %.01216.unr, %.lr.ph.prol.loopexit ]
  %.01315 = phi ptr [ %65, %.lr.ph ], [ %.01315.unr, %.lr.ph.prol.loopexit ]
  %42 = getelementptr inbounds i8, ptr %.018, i64 4
  %43 = load float, ptr %.018, align 4, !tbaa !13
  %44 = getelementptr inbounds i8, ptr %.01216, i64 4
  %45 = load float, ptr %.01216, align 4, !tbaa !13
  %46 = fadd float %43, %45
  %47 = getelementptr inbounds i8, ptr %.01315, i64 4
  store float %46, ptr %.01315, align 4, !tbaa !13
  %48 = getelementptr inbounds i8, ptr %.018, i64 8
  %49 = load float, ptr %42, align 4, !tbaa !13
  %50 = getelementptr inbounds i8, ptr %.01216, i64 8
  %51 = load float, ptr %44, align 4, !tbaa !13
  %52 = fadd float %49, %51
  %53 = getelementptr inbounds i8, ptr %.01315, i64 8
  store float %52, ptr %47, align 4, !tbaa !13
  %54 = getelementptr inbounds i8, ptr %.018, i64 12
  %55 = load float, ptr %48, align 4, !tbaa !13
  %56 = getelementptr inbounds i8, ptr %.01216, i64 12
  %57 = load float, ptr %50, align 4, !tbaa !13
  %58 = fadd float %55, %57
  %59 = getelementptr inbounds i8, ptr %.01315, i64 12
  store float %58, ptr %53, align 4, !tbaa !13
  %60 = getelementptr inbounds i8, ptr %.018, i64 16
  %61 = load float, ptr %54, align 4, !tbaa !13
  %62 = getelementptr inbounds i8, ptr %.01216, i64 16
  %63 = load float, ptr %56, align 4, !tbaa !13
  %64 = fadd float %61, %63
  %65 = getelementptr inbounds i8, ptr %.01315, i64 16
  store float %64, ptr %59, align 4, !tbaa !13
  %66 = add i32 %.01117, -4
  %.not.3 = icmp eq i32 %66, 0
  br i1 %.not.3, label %._crit_edge, label %.lr.ph, !llvm.loop !21

._crit_edge:                                      ; preds = %.lr.ph.prol.loopexit, %.lr.ph, %middle.block, %3
  ret i32 0
}

attributes #0 = { nofree norecurse nosync nounwind memory(readwrite, inaccessiblemem: 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)"}
!5 = !{!6, !7, i64 0}
!6 = !{!"", !7, i64 0, !7, i64 2, !10, i64 8}
!7 = !{!"short", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !7, i64 2}
!12 = !{!6, !10, i64 8}
!13 = !{!14, !14, i64 0}
!14 = !{!"float", !8, i64 0}
!15 = distinct !{!15, !16, !17, !18}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!"llvm.loop.isvectorized", i32 1}
!18 = !{!"llvm.loop.unroll.runtime.disable"}
!19 = distinct !{!19, !20}
!20 = !{!"llvm.loop.unroll.disable"}
!21 = distinct !{!21, !16, !17}


; Effective O3 passes: EarlyCSEPass,GlobalOptPass,IPSCCPPass,InferFunctionAttrsPass,InstCombinePass,InstSimplifyPass,JumpThreadingPass,LCSSAPass,LoopLoadEliminationPass,LoopRotatePass,LoopSimplifyPass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass