; LLVM IR from Slingshot-Physics/slingshot-community :: common/math/src/simd_ops.ll (Z11dot_productPKfS0_jPf)

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

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z11dot_productPKfS0_jPf(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr noundef %3) #0 {
  %5 = alloca i32, align 4
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca i32, align 4
  %9 = alloca ptr, align 8
  %10 = alloca <4 x float>, align 16
  %11 = alloca <4 x float>, align 16
  %12 = alloca <4 x float>, align 16
  %13 = alloca <4 x float>, align 16
  %14 = alloca i32, align 4
  %15 = alloca i32, align 4
  %16 = alloca <4 x float>, align 16
  %17 = alloca <4 x float>, align 16
  store ptr %0, ptr %6, align 8, !tbaa !5
  store ptr %1, ptr %7, align 8, !tbaa !5
  store i32 %2, ptr %8, align 4, !tbaa !9
  store ptr %3, ptr %9, align 8, !tbaa !5
  %18 = load ptr, ptr %6, align 8, !tbaa !5
  %19 = ptrtoint ptr %18 to i64
  %20 = urem i64 %19, 16
  %21 = icmp ne i64 %20, 0
  br i1 %21, label %31, label %22

22:                                               ; preds = %4
  %23 = load ptr, ptr %7, align 8, !tbaa !5
  %24 = ptrtoint ptr %23 to i64
  %25 = urem i64 %24, 16
  %26 = icmp ne i64 %25, 0
  br i1 %26, label %31, label %27

27:                                               ; preds = %22
  %28 = load i32, ptr %8, align 4, !tbaa !9
  %29 = urem i32 %28, 4
  %30 = icmp ne i32 %29, 0
  br i1 %30, label %31, label %32

31:                                               ; preds = %27, %22, %4
  store i32 0, ptr %5, align 4
  br label %79

32:                                               ; preds = %27
  call void @llvm.lifetime.start.p0(i64 16, ptr %10) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %11) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %12) #4
  call void @llvm.lifetime.start.p0(i64 16, ptr %13) #4
  %33 = call noundef <4 x float> @_ZL11_mm_set_ps1f(float noundef 0.000000e+00)
  store <4 x float> %33, ptr %13, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 4, ptr %14) #4
  %34 = load i32, ptr %8, align 4, !tbaa !9
  %35 = udiv i32 %34, 4
  store i32 %35, ptr %14, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %15) #4
  store i32 0, ptr %15, align 4, !tbaa !9
  br label %36

36:                                               ; preds = %60, %32
  %37 = load i32, ptr %15, align 4, !tbaa !9
  %38 = load i32, ptr %14, align 4, !tbaa !9
  %39 = icmp ult i32 %37, %38
  br i1 %39, label %41, label %40

40:                                               ; preds = %36
  call void @llvm.lifetime.end.p0(i64 4, ptr %15) #4
  br label %63

41:                                               ; preds = %36
  %42 = load ptr, ptr %6, align 8, !tbaa !5
  %43 = load i32, ptr %15, align 4, !tbaa !9
  %44 = mul i32 %43, 4
  %45 = zext i32 %44 to i64
  %46 = getelementptr inbounds float, ptr %42, i64 %45
  %47 = call noundef <4 x float> @_ZL11_mm_load_psPKf(ptr noundef %46)
  store <4 x float> %47, ptr %10, align 16, !tbaa !11
  %48 = load ptr, ptr %7, align 8, !tbaa !5
  %49 = load i32, ptr %15, align 4, !tbaa !9
  %50 = mul i32 %49, 4
  %51 = zext i32 %50 to i64
  %52 = getelementptr inbounds float, ptr %48, i64 %51
  %53 = call noundef <4 x float> @_ZL11_mm_load_psPKf(ptr noundef %52)
  store <4 x float> %53, ptr %11, align 16, !tbaa !11
  %54 = load <4 x float>, ptr %10, align 16, !tbaa !11
  %55 = load <4 x float>, ptr %11, align 16, !tbaa !11
  %56 = call noundef <4 x float> @_ZL10_mm_mul_psDv4_fS_(<4 x float> noundef %54, <4 x float> noundef %55)
  store <4 x float> %56, ptr %12, align 16, !tbaa !11
  %57 = load <4 x float>, ptr %12, align 16, !tbaa !11
  %58 = load <4 x float>, ptr %13, align 16, !tbaa !11
  %59 = call noundef <4 x float> @_ZL10_mm_add_psDv4_fS_(<4 x float> noundef %57, <4 x float> noundef %58)
  store <4 x float> %59, ptr %13, align 16, !tbaa !11
  br label %60

60:                                               ; preds = %41
  %61 = load i32, ptr %15, align 4, !tbaa !9
  %62 = add i32 %61, 1
  store i32 %62, ptr %15, align 4, !tbaa !9
  br label %36, !llvm.loop !12

63:                                               ; preds = %40
  call void @llvm.lifetime.start.p0(i64 16, ptr %16) #4
  %64 = load <4 x float>, ptr %13, align 16, !tbaa !11
  %65 = load <4 x float>, ptr %13, align 16, !tbaa !11
  %66 = shufflevector <4 x float> %64, <4 x float> %65, <4 x i32> <i32 1, i32 0, i32 7, i32 6>
  store <4 x float> %66, ptr %16, align 16, !tbaa !11
  call void @llvm.lifetime.start.p0(i64 16, ptr %17) #4
  %67 = load <4 x float>, ptr %13, align 16, !tbaa !11
  %68 = load <4 x float>, ptr %16, align 16, !tbaa !11
  %69 = call noundef <4 x float> @_ZL10_mm_add_psDv4_fS_(<4 x float> noundef %67, <4 x float> noundef %68)
  store <4 x float> %69, ptr %17, align 16, !tbaa !11
  %70 = load <4 x float>, ptr %16, align 16, !tbaa !11
  %71 = load <4 x float>, ptr %17, align 16, !tbaa !11
  %72 = call noundef <4 x float> @_ZL13_mm_movehl_psDv4_fS_(<4 x float> noundef %70, <4 x float> noundef %71)
  store <4 x float> %72, ptr %16, align 16, !tbaa !11
  %73 = load <4 x float>, ptr %17, align 16, !tbaa !11
  %74 = load <4 x float>, ptr %16, align 16, !tbaa !11
  %75 = call noundef <4 x float> @_ZL10_mm_add_ssDv4_fS_(<4 x float> noundef %73, <4 x float> noundef %74)
  store <4 x float> %75, ptr %17, align 16, !tbaa !11
  %76 = load <4 x float>, ptr %17, align 16, !tbaa !11
  %77 = call noundef float @_ZL13_mm_cvtss_f32Dv4_f(<4 x float> noundef %76)
  %78 = load ptr, ptr %9, align 8, !tbaa !5
  store float %77, ptr %78, align 4, !tbaa !14
  store i32 1, ptr %5, align 4
  call void @llvm.lifetime.end.p0(i64 16, ptr %17) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %16) #4
  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 16, ptr %12) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %11) #4
  call void @llvm.lifetime.end.p0(i64 16, ptr %10) #4
  br label %79

79:                                               ; preds = %63, %31
  %80 = load i32, ptr %5, align 4
  ret i32 %80
}

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.start.p0(i64 immarg, ptr nocapture) #1

; Function Attrs: alwaysinline mustprogress uwtable
declare hidden noundef <4 x float> @_ZL11_mm_set_ps1f(float noundef) #2

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

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

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

; Function Attrs: nocallback nofree nosync nounwind willreturn memory(argmem: readwrite)
declare void @llvm.lifetime.end.p0(i64 immarg, ptr nocapture) #1

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

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

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

attributes #0 = { mustprogress 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 #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { alwaysinline mustprogress 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 mustprogress 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++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = !{!7, !7, i64 0}
!12 = distinct !{!12, !13}
!13 = !{!"llvm.loop.mustprogress"}
!14 = !{!15, !15, i64 0}
!15 = !{!"float", !7, i64 0}


; 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 noundef range(i32 0, 2) i32 @_Z11dot_productPKfS0_jPf(ptr noundef %0, ptr noundef %1, i32 noundef %2, ptr nocapture noundef writeonly %3) local_unnamed_addr #0 {
  %5 = ptrtoint ptr %0 to i64
  %6 = ptrtoint ptr %1 to i64
  %7 = or i64 %6, %5
  %8 = and i64 %7, 15
  %or.cond = icmp eq i64 %8, 0
  %9 = and i32 %2, 3
  %.not28 = icmp eq i32 %9, 0
  %or.cond30 = and i1 %.not28, %or.cond
  br i1 %or.cond30, label %10, label %25

10:                                               ; preds = %4
  %11 = tail call noundef <4 x float> @_ZL11_mm_set_ps1f(float noundef 0.000000e+00)
  %.not = icmp eq i32 %2, 0
  br i1 %.not, label %._crit_edge, label %.lr.ph.preheader

.lr.ph.preheader:                                 ; preds = %10
  %12 = lshr exact i32 %2, 2
  %wide.trip.count = zext nneg i32 %12 to i64
  br label %.lr.ph

._crit_edge:                                      ; preds = %.lr.ph, %10
  %.025.lcssa = phi <4 x float> [ %11, %10 ], [ %24, %.lr.ph ]
  %13 = shufflevector <4 x float> %.025.lcssa, <4 x float> poison, <4 x i32> <i32 1, i32 0, i32 3, i32 2>
  %14 = tail call noundef <4 x float> @_ZL10_mm_add_psDv4_fS_(<4 x float> noundef %.025.lcssa, <4 x float> noundef %13)
  %15 = tail call noundef <4 x float> @_ZL13_mm_movehl_psDv4_fS_(<4 x float> noundef %13, <4 x float> noundef %14)
  %16 = tail call noundef <4 x float> @_ZL10_mm_add_ssDv4_fS_(<4 x float> noundef %14, <4 x float> noundef %15)
  %17 = tail call noundef float @_ZL13_mm_cvtss_f32Dv4_f(<4 x float> noundef %16)
  store float %17, ptr %3, align 4, !tbaa !5
  br label %25

.lr.ph:                                           ; preds = %.lr.ph.preheader, %.lr.ph
  %indvars.iv = phi i64 [ 0, %.lr.ph.preheader ], [ %indvars.iv.next, %.lr.ph ]
  %.02532 = phi <4 x float> [ %11, %.lr.ph.preheader ], [ %24, %.lr.ph ]
  %18 = shl nuw i64 %indvars.iv, 2
  %19 = getelementptr inbounds float, ptr %0, i64 %18
  %20 = tail call noundef <4 x float> @_ZL11_mm_load_psPKf(ptr noundef %19)
  %21 = getelementptr inbounds float, ptr %1, i64 %18
  %22 = tail call noundef <4 x float> @_ZL11_mm_load_psPKf(ptr noundef %21)
  %23 = tail call noundef <4 x float> @_ZL10_mm_mul_psDv4_fS_(<4 x float> noundef %20, <4 x float> noundef %22)
  %24 = tail call noundef <4 x float> @_ZL10_mm_add_psDv4_fS_(<4 x float> noundef %23, <4 x float> noundef %.02532)
  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
  %exitcond.not = icmp eq i64 %indvars.iv.next, %wide.trip.count
  br i1 %exitcond.not, label %._crit_edge, label %.lr.ph, !llvm.loop !9

25:                                               ; preds = %4, %._crit_edge
  %.0 = phi i32 [ 1, %._crit_edge ], [ 0, %4 ]
  ret i32 %.0
}

; Function Attrs: alwaysinline mustprogress uwtable
declare hidden noundef <4 x float> @_ZL11_mm_set_ps1f(float noundef) local_unnamed_addr #1

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

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

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

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

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

; Function Attrs: alwaysinline mustprogress nounwind uwtable
declare hidden noundef float @_ZL13_mm_cvtss_f32Dv4_f(<4 x float> noundef) local_unnamed_addr #2

attributes #0 = { mustprogress 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 #1 = { alwaysinline mustprogress 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 #2 = { alwaysinline mustprogress 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" }

!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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = distinct !{!9, !10}
!10 = !{!"llvm.loop.mustprogress"}


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