; LLVM IR from ROCm/aomp :: test/smoke/nativetests/nativetests.ll_ (nv_popcll)

; 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: nounwind uwtable
define dso_local i32 @__nv_popcll(i64 noundef %0) #0 {
  %2 = alloca i64, align 8
  %3 = alloca i32, align 4
  %4 = alloca i32, align 4
  store i64 %0, ptr %2, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %3) #2
  store i32 0, ptr %3, align 4, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 4, ptr %4) #2
  store i32 0, ptr %4, align 4, !tbaa !9
  br label %5

5:                                                ; preds = %18, %1
  %6 = load i32, ptr %3, align 4, !tbaa !9
  %7 = icmp slt i32 %6, 64
  br i1 %7, label %8, label %21

8:                                                ; preds = %5
  %9 = load i64, ptr %2, align 8, !tbaa !5
  %10 = load i32, ptr %3, align 4, !tbaa !9
  %11 = zext i32 %10 to i64
  %12 = shl i64 1, %11
  %13 = and i64 %9, %12
  %14 = icmp ne i64 %13, 0
  br i1 %14, label %15, label %18

15:                                               ; preds = %8
  %16 = load i32, ptr %4, align 4, !tbaa !9
  %17 = add nsw i32 %16, 1
  store i32 %17, ptr %4, align 4, !tbaa !9
  br label %18

18:                                               ; preds = %15, %8
  %19 = load i32, ptr %3, align 4, !tbaa !9
  %20 = add nsw i32 %19, 1
  store i32 %20, ptr %3, align 4, !tbaa !9
  br label %5, !llvm.loop !11

21:                                               ; preds = %5
  %22 = load i32, ptr %4, align 4, !tbaa !9
  call void @llvm.lifetime.end.p0(i64 4, ptr %4) #2
  call void @llvm.lifetime.end.p0(i64 4, ptr %3) #2
  ret i32 %22
}

; 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 = !{!"long long", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C/C++ TBAA"}
!9 = !{!10, !10, i64 0}
!10 = !{!"int", !7, i64 0}
!11 = distinct !{!11, !12}
!12 = !{!"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(none) uwtable
define dso_local i32 @__nv_popcll(i64 noundef %0) local_unnamed_addr #0 {
vector.ph:
  %broadcast.splatinsert = insertelement <4 x i64> poison, i64 %0, i64 0
  %broadcast.splat = shufflevector <4 x i64> %broadcast.splatinsert, <4 x i64> poison, <4 x i32> zeroinitializer
  %1 = and <4 x i64> %broadcast.splat, <i64 1, i64 2, i64 4, i64 8>
  %2 = and <4 x i64> %broadcast.splat, <i64 16, i64 32, i64 64, i64 128>
  %3 = icmp ne <4 x i64> %1, zeroinitializer
  %4 = icmp ne <4 x i64> %2, zeroinitializer
  %5 = zext <4 x i1> %3 to <4 x i32>
  %6 = zext <4 x i1> %4 to <4 x i32>
  %7 = and <4 x i64> %broadcast.splat, <i64 256, i64 512, i64 1024, i64 2048>
  %8 = and <4 x i64> %broadcast.splat, <i64 4096, i64 8192, i64 16384, i64 32768>
  %9 = icmp ne <4 x i64> %7, zeroinitializer
  %10 = icmp ne <4 x i64> %8, zeroinitializer
  %11 = zext <4 x i1> %9 to <4 x i32>
  %12 = zext <4 x i1> %10 to <4 x i32>
  %13 = add nuw nsw <4 x i32> %5, %11
  %14 = add nuw nsw <4 x i32> %6, %12
  %15 = and <4 x i64> %broadcast.splat, <i64 65536, i64 131072, i64 262144, i64 524288>
  %16 = and <4 x i64> %broadcast.splat, <i64 1048576, i64 2097152, i64 4194304, i64 8388608>
  %17 = icmp ne <4 x i64> %15, zeroinitializer
  %18 = icmp ne <4 x i64> %16, zeroinitializer
  %19 = zext <4 x i1> %17 to <4 x i32>
  %20 = zext <4 x i1> %18 to <4 x i32>
  %21 = add nuw nsw <4 x i32> %13, %19
  %22 = add nuw nsw <4 x i32> %14, %20
  %23 = and <4 x i64> %broadcast.splat, <i64 16777216, i64 33554432, i64 67108864, i64 134217728>
  %24 = and <4 x i64> %broadcast.splat, <i64 268435456, i64 536870912, i64 1073741824, i64 2147483648>
  %25 = icmp ne <4 x i64> %23, zeroinitializer
  %26 = icmp ne <4 x i64> %24, zeroinitializer
  %27 = zext <4 x i1> %25 to <4 x i32>
  %28 = zext <4 x i1> %26 to <4 x i32>
  %29 = add nuw nsw <4 x i32> %21, %27
  %30 = add nuw nsw <4 x i32> %22, %28
  %31 = and <4 x i64> %broadcast.splat, <i64 4294967296, i64 8589934592, i64 17179869184, i64 34359738368>
  %32 = and <4 x i64> %broadcast.splat, <i64 68719476736, i64 137438953472, i64 274877906944, i64 549755813888>
  %33 = icmp ne <4 x i64> %31, zeroinitializer
  %34 = icmp ne <4 x i64> %32, zeroinitializer
  %35 = zext <4 x i1> %33 to <4 x i32>
  %36 = zext <4 x i1> %34 to <4 x i32>
  %37 = add nuw nsw <4 x i32> %29, %35
  %38 = add nuw nsw <4 x i32> %30, %36
  %39 = and <4 x i64> %broadcast.splat, <i64 1099511627776, i64 2199023255552, i64 4398046511104, i64 8796093022208>
  %40 = and <4 x i64> %broadcast.splat, <i64 17592186044416, i64 35184372088832, i64 70368744177664, i64 140737488355328>
  %41 = icmp ne <4 x i64> %39, zeroinitializer
  %42 = icmp ne <4 x i64> %40, zeroinitializer
  %43 = zext <4 x i1> %41 to <4 x i32>
  %44 = zext <4 x i1> %42 to <4 x i32>
  %45 = add nuw nsw <4 x i32> %37, %43
  %46 = add nuw nsw <4 x i32> %38, %44
  %47 = and <4 x i64> %broadcast.splat, <i64 281474976710656, i64 562949953421312, i64 1125899906842624, i64 2251799813685248>
  %48 = and <4 x i64> %broadcast.splat, <i64 4503599627370496, i64 9007199254740992, i64 18014398509481984, i64 36028797018963968>
  %49 = icmp ne <4 x i64> %47, zeroinitializer
  %50 = icmp ne <4 x i64> %48, zeroinitializer
  %51 = zext <4 x i1> %49 to <4 x i32>
  %52 = zext <4 x i1> %50 to <4 x i32>
  %53 = add nuw nsw <4 x i32> %45, %51
  %54 = add nuw nsw <4 x i32> %46, %52
  %55 = and <4 x i64> %broadcast.splat, <i64 72057594037927936, i64 144115188075855872, i64 288230376151711744, i64 576460752303423488>
  %56 = and <4 x i64> %broadcast.splat, <i64 1152921504606846976, i64 2305843009213693952, i64 4611686018427387904, i64 -9223372036854775808>
  %57 = icmp ne <4 x i64> %55, zeroinitializer
  %58 = icmp ne <4 x i64> %56, zeroinitializer
  %59 = zext <4 x i1> %57 to <4 x i32>
  %60 = zext <4 x i1> %58 to <4 x i32>
  %61 = add <4 x i32> %53, %59
  %62 = add <4 x i32> %54, %60
  %bin.rdx = add <4 x i32> %62, %61
  %63 = tail call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %bin.rdx)
  ret i32 %63
}

; Function Attrs: nocallback nofree nosync nounwind speculatable willreturn memory(none)
declare i32 @llvm.vector.reduce.add.v4i32(<4 x i32>) #1

attributes #0 = { nofree norecurse nosync nounwind memory(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" }
attributes #1 = { nocallback nofree nosync nounwind speculatable willreturn memory(none) }

!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)"}


; Effective O3 passes: GVNPass,GlobalOptPass,IPSCCPPass,IndVarSimplifyPass,InferFunctionAttrsPass,InstCombinePass,LCSSAPass,LoopLoadEliminationPass,LoopRotatePass,LoopUnrollPass,LoopVectorizePass,PostOrderFunctionAttrsPass,ReassociatePass,SROAPass,SimplifyCFGPass,TailCallElimPass