; LLVM IR from huawei-noah/bolt :: compute/tensor/src/cpu/x86/int8/avx512 (dequantize)

; 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.TensorDesc = type { i32, i32, i32, [20 x i32] }

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z18dequantizeI32ToF3210TensorDescPiPKfS_Pf(ptr noundef byval(%struct.TensorDesc) align 8 %0, ptr noundef %1, ptr noundef %2, ptr noundef byval(%struct.TensorDesc) align 8 %3, ptr noundef %4) #0 {
  %6 = alloca ptr, align 8
  %7 = alloca ptr, align 8
  %8 = alloca ptr, align 8
  %9 = alloca i32, align 4
  %10 = alloca %struct.TensorDesc, align 8
  %11 = alloca i32, align 4
  %12 = alloca i32, align 4
  %13 = alloca float, align 4
  store ptr %1, ptr %6, align 8, !tbaa !5
  store ptr %2, ptr %7, align 8, !tbaa !5
  store ptr %4, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.start.p0(i64 4, ptr %9) #4
  call void @llvm.memcpy.p0.p0.i64(ptr align 4 %10, ptr align 8 %3, i64 92, i1 false), !tbaa.struct !9
  %14 = call noundef i32 @_Z17tensorNumElements10TensorDesc(ptr noundef byval(%struct.TensorDesc) align 8 %10)
  store i32 %14, ptr %9, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %11) #4
  %15 = load i32, ptr %9, align 4, !tbaa !14
  %16 = udiv i32 %15, 16
  store i32 %16, ptr %11, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %12) #4
  %17 = load i32, ptr %9, align 4, !tbaa !14
  %18 = urem i32 %17, 16
  %19 = call noundef double @_ZSt3powIijEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(i32 noundef 2, i32 noundef %18)
  %20 = fsub double %19, 1.000000e+00
  %21 = fptoui double %20 to i32
  store i32 %21, ptr %12, align 4, !tbaa !14
  call void @llvm.lifetime.start.p0(i64 4, ptr %13) #4
  %22 = load ptr, ptr %7, align 8, !tbaa !5
  %23 = load float, ptr %22, align 4, !tbaa !17
  %24 = fdiv float 1.000000e+00, %23
  store float %24, ptr %13, align 4, !tbaa !17
  %25 = load ptr, ptr %6, align 8, !tbaa !5
  %26 = load ptr, ptr %8, align 8, !tbaa !5
  %27 = load i32, ptr %11, align 4, !tbaa !14
  %28 = load i32, ptr %12, align 4, !tbaa !14
  %29 = call { ptr, ptr } asm sideeffect "vbroadcastss ($2), %zmm2              \0A\09.align 16                              \0A\090:                                     \0A\09vmovups ($0), %zmm0                   \0A\09vcvtdq2ps %zmm0, %zmm1               \0A\09vmulps %zmm2, %zmm1, %zmm0          \0A\09vmovups %zmm0, ($1)                   \0A\09add $$0x40, $0                          \0A\09add $$0x40, $1                          \0A\09dec %ebx                              \0A\09jg 0b                                  \0A\09vxorps %zmm0, %zmm0, %zmm0          \0A\09cmp $$0x0, %eax                       \0A\09je 1f                                  \0A\09kmovw %eax, %k1                      \0A\09vmovups ($0), %zmm0 {%k1}             \0A\09vcvtdq2ps %zmm0, %zmm1               \0A\09vmulps %zmm2, %zmm1, %zmm0          \0A\09vmovups %zmm0, ($1) {%k1}         \0A\09.align 16                              \0A\091:                                     \0A\09", "=r,=r,r,{bx},{ax},0,1,~{k1},~{zmm0},~{zmm1},~{zmm2},~{memory},~{cc},~{dirflag},~{fpsr},~{flags}"(ptr %13, i32 %27, i32 %28, ptr %25, ptr %26) #4, !srcloc !19
  %30 = extractvalue { ptr, ptr } %29, 0
  %31 = extractvalue { ptr, ptr } %29, 1
  store ptr %30, ptr %6, align 8, !tbaa !5
  store ptr %31, ptr %8, align 8, !tbaa !5
  call void @llvm.lifetime.end.p0(i64 4, 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 4, ptr %9) #4
  ret i32 0
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z17tensorNumElements10TensorDesc(ptr noundef byval(%struct.TensorDesc) align 8) #2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: readwrite)
declare void @llvm.memcpy.p0.p0.i64(ptr noalias nocapture writeonly, ptr noalias nocapture readonly, i64, i1 immarg) #3

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt3powIijEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(i32 noundef, i32 noundef) #2

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

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" }
attributes #1 = { nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint mustprogress 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 #3 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
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 = !{i64 0, i64 4, !10, i64 4, i64 4, !12, i64 8, i64 4, !14, i64 12, i64 80, !16}
!10 = !{!11, !11, i64 0}
!11 = !{!"_ZTS8DataType", !7, i64 0}
!12 = !{!13, !13, i64 0}
!13 = !{!"_ZTS10DataFormat", !7, i64 0}
!14 = !{!15, !15, i64 0}
!15 = !{!"int", !7, i64 0}
!16 = !{!7, !7, i64 0}
!17 = !{!18, !18, i64 0}
!18 = !{!"float", !7, i64 0}
!19 = !{i64 1489, i64 1531, i64 1603, i64 1675, i64 1747, i64 1819, i64 1891, i64 1963, i64 2035, i64 2107, i64 2179, i64 2251, i64 2325, i64 2396, i64 2468, i64 2540, i64 2615, i64 2687, i64 2759, i64 2830, i64 2902, i64 2974}


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

%struct.TensorDesc = type { i32, i32, i32, [20 x i32] }

; Function Attrs: mustprogress uwtable
define dso_local noundef i32 @_Z18dequantizeI32ToF3210TensorDescPiPKfS_Pf(ptr nocapture noundef readnone byval(%struct.TensorDesc) align 8 %0, ptr noundef %1, ptr nocapture noundef readonly %2, ptr nocapture noundef readonly byval(%struct.TensorDesc) align 8 %3, ptr noundef %4) local_unnamed_addr #0 {
  %6 = alloca float, align 4
  %7 = tail call noundef i32 @_Z17tensorNumElements10TensorDesc(ptr noundef nonnull byval(%struct.TensorDesc) align 8 %3)
  %8 = lshr i32 %7, 4
  %9 = and i32 %7, 15
  %10 = tail call noundef double @_ZSt3powIijEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(i32 noundef 2, i32 noundef %9)
  %11 = fadd double %10, -1.000000e+00
  %12 = fptoui double %11 to i32
  call void @llvm.lifetime.start.p0(i64 4, ptr nonnull %6) #3
  %13 = load float, ptr %2, align 4, !tbaa !5
  %14 = fdiv float 1.000000e+00, %13
  store float %14, ptr %6, align 4, !tbaa !5
  %15 = call { ptr, ptr } asm sideeffect "vbroadcastss ($2), %zmm2              \0A\09.align 16                              \0A\090:                                     \0A\09vmovups ($0), %zmm0                   \0A\09vcvtdq2ps %zmm0, %zmm1               \0A\09vmulps %zmm2, %zmm1, %zmm0          \0A\09vmovups %zmm0, ($1)                   \0A\09add $$0x40, $0                          \0A\09add $$0x40, $1                          \0A\09dec %ebx                              \0A\09jg 0b                                  \0A\09vxorps %zmm0, %zmm0, %zmm0          \0A\09cmp $$0x0, %eax                       \0A\09je 1f                                  \0A\09kmovw %eax, %k1                      \0A\09vmovups ($0), %zmm0 {%k1}             \0A\09vcvtdq2ps %zmm0, %zmm1               \0A\09vmulps %zmm2, %zmm1, %zmm0          \0A\09vmovups %zmm0, ($1) {%k1}         \0A\09.align 16                              \0A\091:                                     \0A\09", "=r,=r,r,{bx},{ax},0,1,~{k1},~{zmm0},~{zmm1},~{zmm2},~{memory},~{cc},~{dirflag},~{fpsr},~{flags}"(ptr nonnull %6, i32 %8, i32 %12, ptr %1, ptr %4) #3, !srcloc !9
  call void @llvm.lifetime.end.p0(i64 4, ptr nonnull %6) #3
  ret i32 0
}

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

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef i32 @_Z17tensorNumElements10TensorDesc(ptr noundef byval(%struct.TensorDesc) align 8) local_unnamed_addr #2

; Function Attrs: inlinehint mustprogress nounwind uwtable
declare dso_local noundef double @_ZSt3powIijEN9__gnu_cxx9__promoteIDTplcvNS1_IT_Xsr3std12__is_integerIS2_EE7__valueEE6__typeELi0EcvNS1_IT0_Xsr3std12__is_integerIS5_EE7__valueEE6__typeELi0EEXsr3std12__is_integerIS8_EE7__valueEE6__typeES2_S5_(i32 noundef, i32 noundef) local_unnamed_addr #2

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

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" }
attributes #1 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #2 = { inlinehint mustprogress 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 #3 = { 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 = !{!"float", !7, i64 0}
!7 = !{!"omnipotent char", !8, i64 0}
!8 = !{!"Simple C++ TBAA"}
!9 = !{i64 1489, i64 1531, i64 1603, i64 1675, i64 1747, i64 1819, i64 1891, i64 1963, i64 2035, i64 2107, i64 2179, i64 2251, i64 2325, i64 2396, i64 2468, i64 2540, i64 2615, i64 2687, i64 2759, i64 2830, i64 2902, i64 2974}


; Effective O3 passes: DSEPass,EarlyCSEPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,PostOrderFunctionAttrsPass,SROAPass,TailCallElimPass