; LLVM IR from PaddlePaddle/Paddle :: paddle/pir/src/core (op_operand_impl)

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

%"class.pir::Value" = type { ptr }
%"class.pir::detail::OpOperandImpl" = type { %"class.pir::Value", ptr, ptr, ptr }

; 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) #0

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3pir6detail13OpOperandImpl17RemoveFromUdChainEv(ptr noundef nonnull align 8 dereferenceable(32) %0) #1 align 2 {
  %2 = alloca ptr, align 8
  %3 = alloca %"class.pir::Value", align 8
  store ptr %0, ptr %2, align 8, !tbaa !5
  %4 = load ptr, ptr %2, align 8
  %5 = getelementptr inbounds %"class.pir::detail::OpOperandImpl", ptr %4, i32 0, i32 0
  %6 = call noundef zeroext i1 @_ZNK3pir5ValuentEv(ptr noundef nonnull align 8 dereferenceable(8) %5)
  br i1 %6, label %7, label %8

7:                                                ; preds = %1
  br label %44

8:                                                ; preds = %1
  %9 = getelementptr inbounds %"class.pir::detail::OpOperandImpl", ptr %4, i32 0, i32 2
  %10 = load ptr, ptr %9, align 8, !tbaa !9
  %11 = icmp ne ptr %10, null
  br i1 %11, label %13, label %12

12:                                               ; preds = %8
  br label %44

13:                                               ; preds = %8
  %14 = getelementptr inbounds %"class.pir::detail::OpOperandImpl", ptr %4, i32 0, i32 2
  %15 = load ptr, ptr %14, align 8, !tbaa !9
  %16 = getelementptr inbounds %"class.pir::detail::OpOperandImpl", ptr %4, i32 0, i32 0
  %17 = call noundef ptr @_ZNK3pir5Value4implEv(ptr noundef nonnull align 8 dereferenceable(8) %16)
  %18 = call noundef ptr @_ZN3pir6detail9ValueImpl14first_use_addrEv(ptr noundef nonnull align 8 dereferenceable(24) %17)
  %19 = icmp eq ptr %15, %18
  br i1 %19, label %20, label %25

20:                                               ; preds = %13
  %21 = getelementptr inbounds %"class.pir::detail::OpOperandImpl", ptr %4, i32 0, i32 0
  %22 = call noundef ptr @_ZNK3pir5Value4implEv(ptr noundef nonnull align 8 dereferenceable(8) %21)
  %23 = getelementptr inbounds %"class.pir::detail::OpOperandImpl", ptr %4, i32 0, i32 1
  %24 = load ptr, ptr %23, align 8, !tbaa !12
  call void @_ZN3pir6detail9ValueImpl13set_first_useEPNS0_13OpOperandImplE(ptr noundef nonnull align 8 dereferenceable(24) %22, ptr noundef %24)
  br label %30

25:                                               ; preds = %13
  %26 = getelementptr inbounds %"class.pir::detail::OpOperandImpl", ptr %4, i32 0, i32 1
  %27 = load ptr, ptr %26, align 8, !tbaa !12
  %28 = getelementptr inbounds %"class.pir::detail::OpOperandImpl", ptr %4, i32 0, i32 2
  %29 = load ptr, ptr %28, align 8, !tbaa !9
  store ptr %27, ptr %29, align 8, !tbaa !5
  br label %30

30:                                               ; preds = %25, %20
  %31 = getelementptr inbounds %"class.pir::detail::OpOperandImpl", ptr %4, i32 0, i32 1
  %32 = load ptr, ptr %31, align 8, !tbaa !12
  %33 = icmp ne ptr %32, null
  br i1 %33, label %34, label %40

34:                                               ; preds = %30
  %35 = getelementptr inbounds %"class.pir::detail::OpOperandImpl", ptr %4, i32 0, i32 2
  %36 = load ptr, ptr %35, align 8, !tbaa !9
  %37 = getelementptr inbounds %"class.pir::detail::OpOperandImpl", ptr %4, i32 0, i32 1
  %38 = load ptr, ptr %37, align 8, !tbaa !12
  %39 = getelementptr inbounds %"class.pir::detail::OpOperandImpl", ptr %38, i32 0, i32 2
  store ptr %36, ptr %39, align 8, !tbaa !9
  br label %40

40:                                               ; preds = %34, %30
  %41 = getelementptr inbounds %"class.pir::detail::OpOperandImpl", ptr %4, i32 0, i32 1
  store ptr null, ptr %41, align 8, !tbaa !12
  %42 = getelementptr inbounds %"class.pir::detail::OpOperandImpl", ptr %4, i32 0, i32 2
  store ptr null, ptr %42, align 8, !tbaa !9
  call void @llvm.lifetime.start.p0(i64 8, ptr %3) #5
  call void @_ZN3pir5ValueC2EDn(ptr noundef nonnull align 8 dereferenceable(8) %3, ptr null)
  %43 = getelementptr inbounds %"class.pir::detail::OpOperandImpl", ptr %4, i32 0, i32 0
  call void @llvm.memcpy.p0.p0.i64(ptr align 8 %43, ptr align 8 %3, i64 8, i1 false), !tbaa.struct !13
  call void @llvm.lifetime.end.p0(i64 8, ptr %3) #5
  br label %44

44:                                               ; preds = %40, %12, %7
  ret void
}

declare noundef zeroext i1 @_ZNK3pir5ValuentEv(ptr noundef nonnull align 8 dereferenceable(8)) #2

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK3pir5Value4implEv(ptr noundef nonnull align 8 dereferenceable(8)) #4 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN3pir6detail9ValueImpl14first_use_addrEv(ptr noundef nonnull align 8 dereferenceable(24)) #4 align 2

declare void @_ZN3pir6detail9ValueImpl13set_first_useEPNS0_13OpOperandImplE(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef) #2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3pir5ValueC2EDn(ptr noundef nonnull align 8 dereferenceable(8), ptr) unnamed_addr #4 align 2

attributes #0 = { nocallback nofree nounwind willreturn memory(argmem: readwrite) }
attributes #1 = { 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 #2 = { "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 nosync nounwind willreturn memory(argmem: readwrite) }
attributes #4 = { 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 #5 = { 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, !6, i64 16}
!10 = !{!"_ZTSN3pir6detail13OpOperandImplE", !11, i64 0, !6, i64 8, !6, i64 16, !6, i64 24}
!11 = !{!"_ZTSN3pir5ValueE", !6, i64 0}
!12 = !{!10, !6, i64 8}
!13 = !{i64 0, i64 8, !5}


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

%"class.pir::Value" = type { ptr }

; Function Attrs: mustprogress uwtable
define dso_local void @_ZN3pir6detail13OpOperandImpl17RemoveFromUdChainEv(ptr noundef nonnull align 8 dereferenceable(32) %0) local_unnamed_addr #0 align 2 {
  %2 = alloca %"class.pir::Value", align 8
  %3 = tail call noundef zeroext i1 @_ZNK3pir5ValuentEv(ptr noundef nonnull align 8 dereferenceable(8) %0)
  br i1 %3, label %27, label %4

4:                                                ; preds = %1
  %5 = getelementptr inbounds i8, ptr %0, i64 16
  %6 = load ptr, ptr %5, align 8, !tbaa !5
  %.not = icmp eq ptr %6, null
  br i1 %.not, label %27, label %7

7:                                                ; preds = %4
  %8 = tail call noundef ptr @_ZNK3pir5Value4implEv(ptr noundef nonnull align 8 dereferenceable(8) %0)
  %9 = tail call noundef ptr @_ZN3pir6detail9ValueImpl14first_use_addrEv(ptr noundef nonnull align 8 dereferenceable(24) %8)
  %10 = icmp eq ptr %6, %9
  br i1 %10, label %11, label %15

11:                                               ; preds = %7
  %12 = tail call noundef ptr @_ZNK3pir5Value4implEv(ptr noundef nonnull align 8 dereferenceable(8) %0)
  %13 = getelementptr inbounds i8, ptr %0, i64 8
  %14 = load ptr, ptr %13, align 8, !tbaa !11
  tail call void @_ZN3pir6detail9ValueImpl13set_first_useEPNS0_13OpOperandImplE(ptr noundef nonnull align 8 dereferenceable(24) %12, ptr noundef %14)
  %.pre = load ptr, ptr %13, align 8, !tbaa !11
  br label %19

15:                                               ; preds = %7
  %16 = getelementptr inbounds i8, ptr %0, i64 8
  %17 = load ptr, ptr %16, align 8, !tbaa !11
  %18 = load ptr, ptr %5, align 8, !tbaa !5
  store ptr %17, ptr %18, align 8, !tbaa !12
  br label %19

19:                                               ; preds = %15, %11
  %20 = phi ptr [ %17, %15 ], [ %.pre, %11 ]
  %21 = getelementptr inbounds i8, ptr %0, i64 8
  %.not2 = icmp eq ptr %20, null
  br i1 %.not2, label %25, label %22

22:                                               ; preds = %19
  %23 = load ptr, ptr %5, align 8, !tbaa !5
  %24 = getelementptr inbounds i8, ptr %20, i64 16
  store ptr %23, ptr %24, align 8, !tbaa !5
  br label %25

25:                                               ; preds = %22, %19
  tail call void @llvm.memset.p0.i64(ptr noundef nonnull align 8 dereferenceable(16) %21, i8 0, i64 16, i1 false)
  call void @llvm.lifetime.start.p0(i64 8, ptr nonnull %2) #5
  call void @_ZN3pir5ValueC2EDn(ptr noundef nonnull align 8 dereferenceable(8) %2, ptr null)
  %26 = load i64, ptr %2, align 8, !tbaa !12
  store i64 %26, ptr %0, align 8, !tbaa !12
  call void @llvm.lifetime.end.p0(i64 8, ptr nonnull %2) #5
  br label %27

27:                                               ; preds = %4, %1, %25
  ret void
}

declare noundef zeroext i1 @_ZNK3pir5ValuentEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #1

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

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

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZNK3pir5Value4implEv(ptr noundef nonnull align 8 dereferenceable(8)) local_unnamed_addr #3 align 2

; Function Attrs: mustprogress nounwind uwtable
declare dso_local noundef ptr @_ZN3pir6detail9ValueImpl14first_use_addrEv(ptr noundef nonnull align 8 dereferenceable(24)) local_unnamed_addr #3 align 2

declare void @_ZN3pir6detail9ValueImpl13set_first_useEPNS0_13OpOperandImplE(ptr noundef nonnull align 8 dereferenceable(24), ptr noundef) local_unnamed_addr #1

; Function Attrs: mustprogress nounwind uwtable
declare dso_local void @_ZN3pir5ValueC2EDn(ptr noundef nonnull align 8 dereferenceable(8), ptr) unnamed_addr #3 align 2

; Function Attrs: nocallback nofree nounwind willreturn memory(argmem: write)
declare void @llvm.memset.p0.i64(ptr nocapture writeonly, i8, i64, i1 immarg) #4

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 = { "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 = { mustprogress nocallback nofree nosync nounwind willreturn memory(argmem: readwrite) }
attributes #3 = { 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 #4 = { nocallback nofree nounwind willreturn memory(argmem: write) }
attributes #5 = { 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, !8, i64 16}
!6 = !{!"_ZTSN3pir6detail13OpOperandImplE", !7, i64 0, !8, i64 8, !8, i64 16, !8, i64 24}
!7 = !{!"_ZTSN3pir5ValueE", !8, i64 0}
!8 = !{!"any pointer", !9, i64 0}
!9 = !{!"omnipotent char", !10, i64 0}
!10 = !{!"Simple C++ TBAA"}
!11 = !{!6, !8, i64 8}
!12 = !{!8, !8, i64 0}


; Effective O3 passes: EarlyCSEPass,GVNPass,GlobalOptPass,InferFunctionAttrsPass,InstCombinePass,MemCpyOptPass,SROAPass,SimplifyCFGPass,TailCallElimPass