; LLVM IR from jgaeddert/liquid-dsp :: src/dotprod/src/dotprod_rrrf.sse (dotprod_rrrf_execute_sse)

; 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.dotprod_rrrf_s = type { i32, 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 speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

; 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 i32 @dotprod_rrrf_execute_sse(ptr noundef %0, ptr noundef %1, ptr noundef %2) #2 {
  %4 = alloca ptr, align 8
  %5 = alloca ptr, align 8
  %6 = alloca ptr, align 8
  %7 = alloca <4 x float>, align 16
  %8 = alloca <4 x float>, align 16
  %9 = alloca <4 x float>, align 16
  %10 = alloca <4 x float>, align 16
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca [4 x float], align 16
  %14 = alloca float, 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 16, ptr %7) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %8) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %9) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #4
  %15 = call <4 x float> @_mm_setzero_ps()
  store <4 x float> %15, ptr %10, align 16, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %16 = load ptr, ptr %4, align 8, !tbaa !5
  %17 = getelementptr inbounds %struct.dotprod_rrrf_s, ptr %16, i32 0, i32 0
  %18 = load i32, ptr %17, align 8, !tbaa !10
  %19 = lshr i32 %18, 2
  %20 = shl i32 %19, 2
  store i32 %20, ptr %11, align 4, !tbaa !13
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  store i32 0, ptr %12, align 4, !tbaa !13
  br label %21

21:                                               ; preds = %44, %3
  %22 = load i32, ptr %12, align 4, !tbaa !13
  %23 = load i32, ptr %11, align 4, !tbaa !13
  %24 = icmp ult i32 %22, %23
  br i1 %24, label %25, label %47

25:                                               ; preds = %21
  %26 = load ptr, ptr %5, align 8, !tbaa !5
  %27 = load i32, ptr %12, align 4, !tbaa !13
  %28 = zext i32 %27 to i64
  %29 = getelementptr inbounds float, ptr %26, i64 %28
  %30 = call <4 x float> @_mm_loadu_ps(ptr noundef %29)
  store <4 x float> %30, ptr %7, align 16, !tbaa !9
  %31 = load ptr, ptr %4, align 8, !tbaa !5
  %32 = getelementptr inbounds %struct.dotprod_rrrf_s, ptr %31, i32 0, i32 1
  %33 = load ptr, ptr %32, align 8, !tbaa !14
  %34 = load i32, ptr %12, align 4, !tbaa !13
  %35 = zext i32 %34 to i64
  %36 = getelementptr inbounds float, ptr %33, i64 %35
  %37 = call <4 x float> @_mm_load_ps(ptr noundef %36)
  store <4 x float> %37, ptr %8, align 16, !tbaa !9
  %38 = load <4 x float>, ptr %7, align 16, !tbaa !9
  %39 = load <4 x float>, ptr %8, align 16, !tbaa !9
  %40 = call <4 x float> @_mm_mul_ps(<4 x float> noundef %38, <4 x float> noundef %39)
  store <4 x float> %40, ptr %9, align 16, !tbaa !9
  %41 = load <4 x float>, ptr %10, align 16, !tbaa !9
  %42 = load <4 x float>, ptr %9, align 16, !tbaa !9
  %43 = call <4 x float> @_mm_add_ps(<4 x float> noundef %41, <4 x float> noundef %42)
  store <4 x float> %43, ptr %10, align 16, !tbaa !9
  br label %44

44:                                               ; preds = %25
  %45 = load i32, ptr %12, align 4, !tbaa !13
  %46 = add i32 %45, 4
  store i32 %46, ptr %12, align 4, !tbaa !13
  br label %21, !llvm.loop !15

47:                                               ; preds = %21
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #4
  %48 = getelementptr inbounds [4 x float], ptr %13, i64 0, i64 0
  %49 = load <4 x float>, ptr %10, align 16, !tbaa !9
  call void @_mm_store_ps(ptr noundef %48, <4 x float> noundef %49)
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %50 = getelementptr inbounds [4 x float], ptr %13, i64 0, i64 0
  %51 = load float, ptr %50, align 16, !tbaa !17
  %52 = getelementptr inbounds [4 x float], ptr %13, i64 0, i64 1
  %53 = load float, ptr %52, align 4, !tbaa !17
  %54 = fadd float %51, %53
  %55 = getelementptr inbounds [4 x float], ptr %13, i64 0, i64 2
  %56 = load float, ptr %55, align 8, !tbaa !17
  %57 = fadd float %54, %56
  %58 = getelementptr inbounds [4 x float], ptr %13, i64 0, i64 3
  %59 = load float, ptr %58, align 4, !tbaa !17
  %60 = fadd float %57, %59
  store float %60, ptr %14, align 4, !tbaa !17
  br label %61

61:                                               ; preds = %82, %47
  %62 = load i32, ptr %12, align 4, !tbaa !13
  %63 = load ptr, ptr %4, align 8, !tbaa !5
  %64 = getelementptr inbounds %struct.dotprod_rrrf_s, ptr %63, i32 0, i32 0
  %65 = load i32, ptr %64, align 8, !tbaa !10
  %66 = icmp ult i32 %62, %65
  br i1 %66, label %67, label %85

67:                                               ; preds = %61
  %68 = load ptr, ptr %5, align 8, !tbaa !5
  %69 = load i32, ptr %12, align 4, !tbaa !13
  %70 = zext i32 %69 to i64
  %71 = getelementptr inbounds float, ptr %68, i64 %70
  %72 = load float, ptr %71, align 4, !tbaa !17
  %73 = load ptr, ptr %4, align 8, !tbaa !5
  %74 = getelementptr inbounds %struct.dotprod_rrrf_s, ptr %73, i32 0, i32 1
  %75 = load ptr, ptr %74, align 8, !tbaa !14
  %76 = load i32, ptr %12, align 4, !tbaa !13
  %77 = zext i32 %76 to i64
  %78 = getelementptr inbounds float, ptr %75, i64 %77
  %79 = load float, ptr %78, align 4, !tbaa !17
  %80 = load float, ptr %14, align 4, !tbaa !17
  %81 = call float @llvm.fmuladd.f32(float %72, float %79, float %80)
  store float %81, ptr %14, align 4, !tbaa !17
  br label %82

82:                                               ; preds = %67
  %83 = load i32, ptr %12, align 4, !tbaa !13
  %84 = add i32 %83, 1
  store i32 %84, ptr %12, align 4, !tbaa !13
  br label %61, !llvm.loop !19

85:                                               ; preds = %61
  %86 = load float, ptr %14, align 4, !tbaa !17
  %87 = load ptr, ptr %6, align 8, !tbaa !5
  store float %86, ptr %87, align 4, !tbaa !17
  call void @llvm.lifetime.end.p0(i64 4, ptr %14) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %13) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 4, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %9) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %8) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %7) #4
  ret i32 0
}

; Function Attrs: alwaysinline nounwind uwtable
declare hidden <4 x float> @_mm_setzero_ps() #3

; Function Attrs: alwaysinline nounwind uwtable
declare hidden <4 x float> @_mm_loadu_ps(ptr noundef) #3

; Function Attrs: alwaysinline nounwind uwtable
declare hidden <4 x float> @_mm_load_ps(ptr noundef) #3

; Function Attrs: alwaysinline nounwind uwtable
declare hidden <4 x float> @_mm_mul_ps(<4 x float> noundef, <4 x float> noundef) #3

; Function Attrs: alwaysinline nounwind uwtable
declare hidden <4 x float> @_mm_add_ps(<4 x float> noundef, <4 x float> noundef) #3

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @_mm_store_ps(ptr noundef, <4 x float> noundef) #3

attributes #0 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="128" "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 #3 = { alwaysinline nounwind uwtable "min-legal-vector-width"="128" "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 #4 = { 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 = !{!7, !7, i64 0}
!10 = !{!11, !12, i64 0}
!11 = !{!"dotprod_rrrf_s", !12, i64 0, !6, i64 8}
!12 = !{!"int", !7, i64 0}
!13 = !{!12, !12, i64 0}
!14 = !{!11, !6, i64 8}
!15 = distinct !{!15, !16}
!16 = !{!"llvm.loop.mustprogress"}
!17 = !{!18, !18, i64 0}
!18 = !{!"float", !7, i64 0}
!19 = distinct !{!19, !16}


; 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 nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #0

; Function Attrs: mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare float @llvm.fmuladd.f32(float, float, float) #1

; Function Attrs: mustprogress 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 noundef i32 @dotprod_rrrf_execute_sse(ptr nocapture noundef readonly %0, ptr noundef %1, ptr nocapture noundef writeonly %2) local_unnamed_addr #2 {
  %4 = alloca [4 x float], align 16
  %5 = tail call <4 x float> @_mm_setzero_ps()
  %6 = load i32, ptr %0, align 8, !tbaa !5
  %7 = and i32 %6, -4
  %.not = icmp eq i32 %7, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph

.lr.ph:                                           ; preds = %3
  %8 = getelementptr inbounds i8, ptr %0, i64 8
  %9 = zext i32 %7 to i64
  br label %10

10:                                               ; preds = %.lr.ph, %10
  %indvars.iv = phi i64 [ 0, %.lr.ph ], [ %indvars.iv.next, %10 ]
  %.02324 = phi <4 x float> [ %5, %.lr.ph ], [ %17, %10 ]
  %11 = getelementptr inbounds float, ptr %1, i64 %indvars.iv
  %12 = tail call <4 x float> @_mm_loadu_ps(ptr noundef %11)
  %13 = load ptr, ptr %8, align 8, !tbaa !11
  %14 = getelementptr inbounds float, ptr %13, i64 %indvars.iv
  %15 = tail call <4 x float> @_mm_load_ps(ptr noundef %14)
  %16 = tail call <4 x float> @_mm_mul_ps(<4 x float> noundef %12, <4 x float> noundef %15)
  %17 = tail call <4 x float> @_mm_add_ps(<4 x float> noundef %.02324, <4 x float> noundef %16)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 4
  %18 = icmp ult i64 %indvars.iv.next, %9
  br i1 %18, label %10, label %._crit_edge.loopexit, !llvm.loop !12

._crit_edge.loopexit:                             ; preds = %10
  %19 = trunc nuw i64 %indvars.iv.next to i32
  br label %._crit_edge

._crit_edge:                                      ; preds = %._crit_edge.loopexit, %3
  %.023.lcssa = phi <4 x float> [ %5, %3 ], [ %17, %._crit_edge.loopexit ]
  %.022.lcssa = phi i32 [ 0, %3 ], [ %19, %._crit_edge.loopexit ]
  call void @llvm.lifetime.start.p0(i64 16, ptr nonnull %4) #4
  call void @_mm_store_ps(ptr noundef nonnull %4, <4 x float> noundef %.023.lcssa)
  %20 = load float, ptr %4, align 16, !tbaa !14
  %21 = getelementptr inbounds i8, ptr %4, i64 4
  %22 = load float, ptr %21, align 4, !tbaa !14
  %23 = fadd float %20, %22
  %24 = getelementptr inbounds i8, ptr %4, i64 8
  %25 = load float, ptr %24, align 8, !tbaa !14
  %26 = fadd float %23, %25
  %27 = getelementptr inbounds i8, ptr %4, i64 12
  %28 = load float, ptr %27, align 4, !tbaa !14
  %29 = fadd float %26, %28
  %30 = load i32, ptr %0, align 8, !tbaa !5
  %31 = icmp ult i32 %.022.lcssa, %30
  br i1 %31, label %.lr.ph30, label %._crit_edge31

.lr.ph30:                                         ; preds = %._crit_edge
  %32 = getelementptr inbounds i8, ptr %0, i64 8
  %33 = load ptr, ptr %32, align 8, !tbaa !11
  %34 = zext i32 %.022.lcssa to i64
  %wide.trip.count = zext i32 %30 to i64
  %35 = sub nsw i64 %wide.trip.count, %34
  %xtraiter = and i64 %35, 3
  %lcmp.mod.not = icmp eq i64 %xtraiter, 0
  br i1 %lcmp.mod.not, label %.prol.loopexit, label %.prol.preheader

.prol.preheader:                                  ; preds = %.lr.ph30, %.prol.preheader
  %indvars.iv36.prol = phi i64 [ %indvars.iv.next37.prol, %.prol.preheader ], [ %34, %.lr.ph30 ]
  %.028.prol = phi float [ %40, %.prol.preheader ], [ %29, %.lr.ph30 ]
  %prol.iter = phi i64 [ %prol.iter.next, %.prol.preheader ], [ 0, %.lr.ph30 ]
  %36 = getelementptr inbounds float, ptr %1, i64 %indvars.iv36.prol
  %37 = load float, ptr %36, align 4, !tbaa !14
  %38 = getelementptr inbounds float, ptr %33, i64 %indvars.iv36.prol
  %39 = load float, ptr %38, align 4, !tbaa !14
  %40 = call float @llvm.fmuladd.f32(float %37, float %39, float %.028.prol)
  %indvars.iv.next37.prol = add nuw nsw i64 %indvars.iv36.prol, 1
  %prol.iter.next = add i64 %prol.iter, 1
  %prol.iter.cmp.not = icmp eq i64 %prol.iter.next, %xtraiter
  br i1 %prol.iter.cmp.not, label %.prol.loopexit, label %.prol.preheader, !llvm.loop !16

.prol.loopexit:                                   ; preds = %.prol.preheader, %.lr.ph30
  %.lcssa.unr = phi float [ poison, %.lr.ph30 ], [ %40, %.prol.preheader ]
  %indvars.iv36.unr = phi i64 [ %34, %.lr.ph30 ], [ %indvars.iv.next37.prol, %.prol.preheader ]
  %.028.unr = phi float [ %29, %.lr.ph30 ], [ %40, %.prol.preheader ]
  %41 = sub nsw i64 %34, %wide.trip.count
  %42 = icmp ugt i64 %41, -4
  br i1 %42, label %._crit_edge31, label %.lr.ph30.new

.lr.ph30.new:                                     ; preds = %.prol.loopexit, %.lr.ph30.new
  %indvars.iv36 = phi i64 [ %indvars.iv.next37.3, %.lr.ph30.new ], [ %indvars.iv36.unr, %.prol.loopexit ]
  %.028 = phi float [ %62, %.lr.ph30.new ], [ %.028.unr, %.prol.loopexit ]
  %43 = getelementptr inbounds float, ptr %1, i64 %indvars.iv36
  %44 = load float, ptr %43, align 4, !tbaa !14
  %45 = getelementptr inbounds float, ptr %33, i64 %indvars.iv36
  %46 = load float, ptr %45, align 4, !tbaa !14
  %47 = call float @llvm.fmuladd.f32(float %44, float %46, float %.028)
  %indvars.iv.next37 = add nuw nsw i64 %indvars.iv36, 1
  %48 = getelementptr inbounds float, ptr %1, i64 %indvars.iv.next37
  %49 = load float, ptr %48, align 4, !tbaa !14
  %50 = getelementptr inbounds float, ptr %33, i64 %indvars.iv.next37
  %51 = load float, ptr %50, align 4, !tbaa !14
  %52 = call float @llvm.fmuladd.f32(float %49, float %51, float %47)
  %indvars.iv.next37.1 = add nuw nsw i64 %indvars.iv36, 2
  %53 = getelementptr inbounds float, ptr %1, i64 %indvars.iv.next37.1
  %54 = load float, ptr %53, align 4, !tbaa !14
  %55 = getelementptr inbounds float, ptr %33, i64 %indvars.iv.next37.1
  %56 = load float, ptr %55, align 4, !tbaa !14
  %57 = call float @llvm.fmuladd.f32(float %54, float %56, float %52)
  %indvars.iv.next37.2 = add nuw nsw i64 %indvars.iv36, 3
  %58 = getelementptr inbounds float, ptr %1, i64 %indvars.iv.next37.2
  %59 = load float, ptr %58, align 4, !tbaa !14
  %60 = getelementptr inbounds float, ptr %33, i64 %indvars.iv.next37.2
  %61 = load float, ptr %60, align 4, !tbaa !14
  %62 = call float @llvm.fmuladd.f32(float %59, float %61, float %57)
  %indvars.iv.next37.3 = add nuw nsw i64 %indvars.iv36, 4
  %exitcond.not.3 = icmp eq i64 %indvars.iv.next37.3, %wide.trip.count
  br i1 %exitcond.not.3, label %._crit_edge31, label %.lr.ph30.new, !llvm.loop !18

._crit_edge31:                                    ; preds = %.prol.loopexit, %.lr.ph30.new, %._crit_edge
  %.0.lcssa = phi float [ %29, %._crit_edge ], [ %.lcssa.unr, %.prol.loopexit ], [ %62, %.lr.ph30.new ]
  store float %.0.lcssa, ptr %2, align 4, !tbaa !14
  call void @llvm.lifetime.end.p0(i64 16, ptr nonnull %4) #4
  ret i32 0
}

; Function Attrs: alwaysinline nounwind uwtable
declare hidden <4 x float> @_mm_setzero_ps() local_unnamed_addr #3

; Function Attrs: alwaysinline nounwind uwtable
declare hidden <4 x float> @_mm_loadu_ps(ptr noundef) local_unnamed_addr #3

; Function Attrs: alwaysinline nounwind uwtable
declare hidden <4 x float> @_mm_load_ps(ptr noundef) local_unnamed_addr #3

; Function Attrs: alwaysinline nounwind uwtable
declare hidden <4 x float> @_mm_mul_ps(<4 x float> noundef, <4 x float> noundef) local_unnamed_addr #3

; Function Attrs: alwaysinline nounwind uwtable
declare hidden <4 x float> @_mm_add_ps(<4 x float> noundef, <4 x float> noundef) local_unnamed_addr #3

; Function Attrs: alwaysinline nounwind uwtable
declare hidden void @_mm_store_ps(ptr noundef, <4 x float> noundef) local_unnamed_addr #3

attributes #0 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { mustprogress nocallback nofree nosync nounwind speculatable willreturn memory(none) }
attributes #2 = { nounwind uwtable "min-legal-vector-width"="128" "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 #3 = { alwaysinline nounwind uwtable "min-legal-vector-width"="128" "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 #4 = { 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, !7, i64 0}
!6 = !{!"dotprod_rrrf_s", !7, i64 0, !10, i64 8}
!7 = !{!"int", !8, i64 0}
!8 = !{!"omnipotent char", !9, i64 0}
!9 = !{!"Simple C/C++ TBAA"}
!10 = !{!"any pointer", !8, i64 0}
!11 = !{!6, !10, i64 8}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !15, i64 0}
!15 = !{!"float", !8, i64 0}
!16 = distinct !{!16, !17}
!17 = !{!"llvm.loop.unroll.disable"}
!18 = distinct !{!18, !13}


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