EnzymeAD / Enzyme.jl

Julia bindings for the Enzyme automatic differentiator
https://enzyme.mit.edu
MIT License
455 stars 64 forks source link

Second order AD of broadcast function #1637

Closed AtilaSaraiva closed 4 months ago

AtilaSaraiva commented 4 months ago

Hey, thx for package,

I ran into a nasty error in the following code:

using Enzyme
using Random

function f(x)
    return x .^ 3
end

x = rand(Xoshiro(0), 10)
dx = ones(10)
dx2 = ones(10)

∂f(x, dx) = Enzyme.autodiff_deferred(Forward, f, DuplicatedNoNeed, Duplicated(x, dx)) |> only

∂²f(x, dx, dx2) = Enzyme.autodiff_deferred(
                                       Forward,
                                       ∂f,
                                       DuplicatedNoNeed,
                                       Duplicated(x, dx2),
                                       Const(dx)
                                      ) |> only

@show 3 .* x .^ 2 == ∂f(x, dx) # Works
@show 6 .* x == ∂²f(x, dx, dx2) # Fails

Am I doing something wrong?

The Enzyme version: "[7da242da] Enzyme v0.12.22"

The error:

PHI nodes not grouped at top of basic block!
  %"arrayptr60.i.fr.i'dual_phi" = phi double addrspace(13)* 
label %L103.lr.ph.i.i
; Function Attrs: mustprogress willreturn
define noalias nonnull "enzyme_type"="{[-1]:Pointer, [-1,0]:Pointer, [-1,0,-1]:Float@double, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer}" {} addrspace(10)* @preprocess_julia__f_2881({} addrspace(10)* nocapture noundef nonnull readonly align 16 dereferenceable(40) "enzyme_type"="{[-1]:Pointer, [-1,0]:Pointer, [-1,0,-1]:Float@double, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer}" "enzymejl_parmtype"="140480217219936" "enzymejl_parmtype_ref"="2" %0, {} addrspace(10)* nocapture noundef nonnull readonly align 16 dereferenceable(40) "enzyme_type"="{[-1]:Pointer, [-1,0]:Pointer, [-1,0,-1]:Float@double, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer}" "enzymejl_parmtype"="140480217219936" "enzymejl_parmtype_ref"="2" %1) local_unnamed_addr #10 !dbg !388 {
top:
  %newstruct6.i.i = alloca [1 x [1 x i64]], align 8
  %newstruct44.i.i = alloca [1 x [1 x i64]], align 8
  %2 = call {}*** @julia.get_pgcstack() #11
  %ptls_field3 = getelementptr inbounds {}**, {}*** %2, i64 2
  %3 = bitcast {}*** %ptls_field3 to i64***
  %ptls_load45 = load i64**, i64*** %3, align 8, !tbaa !12
  %4 = getelementptr inbounds i64*, i64** %ptls_load45, i64 2
  %safepoint = load i64*, i64** %4, align 8, !tbaa !16
  fence syncscope("singlethread") seq_cst
  call void @julia.safepoint(i64* %safepoint) #11, !dbg !389
  fence syncscope("singlethread") seq_cst
  %5 = bitcast [1 x [1 x i64]]* %newstruct6.i.i to i8*
  %6 = bitcast [1 x [1 x i64]]* %newstruct44.i.i to i8*
  %ptls_load5657.i.i = load i64**, i64*** %3, align 8, !tbaa !12, !alias.scope !390, !noalias !393
  %7 = getelementptr inbounds i64*, i64** %ptls_load5657.i.i, i64 2
  %safepoint.i.i = load i64*, i64** %7, align 8, !tbaa !16, !alias.scope !395, !noalias !398
  fence syncscope("singlethread") seq_cst
  call void @julia.safepoint(i64* %safepoint.i.i) #11, !dbg !400
  fence syncscope("singlethread") seq_cst
  %8 = addrspacecast {} addrspace(10)* %0 to { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(11)*, !dbg !407
  %arraylen_ptr.i.i = getelementptr inbounds { i8 addrspace(13)*, i64, i16, i16, i32 }, { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(11)* %8, i64 0, i32 1, !dbg !407
  %arraylen.i.i = load i64, i64 addrspace(11)* %arraylen_ptr.i.i, align 8, !dbg !407, !tbaa !59, !range !62, !alias.scope !414, !noalias !417
  %arraylen.i.fr.i = freeze i64 %arraylen.i.i, !dbg !419
  %memcpy_refined_dst.i.i = getelementptr inbounds [1 x [1 x i64]], [1 x [1 x i64]]* %newstruct6.i.i, i64 0, i64 0, i64 0, !dbg !423
  store i64 %arraylen.i.fr.i, i64* %memcpy_refined_dst.i.i, align 8, !dbg !423, !tbaa !86, !alias.scope !88, !noalias !425
  %9 = call noalias nonnull "enzyme_type"="{[-1]:Pointer, [-1,0]:Pointer, [-1,0,-1]:Float@double, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer}" {} addrspace(10)* @ijl_alloc_array_1d({} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 140480217219936 to {}*) to {} addrspace(10)*), i64 noundef %arraylen.i.fr.i) #12, !dbg !432
  %10 = call noalias nonnull "enzyme_type"="{[-1]:Pointer, [-1,0]:Pointer, [-1,0,-1]:Float@double, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer}" {} addrspace(10)* @ijl_alloc_array_1d({} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 140480217219936 to {}*) to {} addrspace(10)*), i64 noundef %arraylen.i.fr.i) #12, !dbg !432
  %11 = addrspacecast {} addrspace(10)* %9 to { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(11)*, !dbg !439
  %arraylen_ptr19.i.i = getelementptr inbounds { i8 addrspace(13)*, i64, i16, i16, i32 }, { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(11)* %11, i64 0, i32 1, !dbg !439
  %arraylen20.i.i = load i64, i64 addrspace(11)* %arraylen_ptr19.i.i, align 8, !dbg !439, !tbaa !59, !range !62, !alias.scope !442, !noalias !445
  %.not.not.i.i = icmp eq i64 %arraylen20.i.i, %arraylen.i.fr.i, !dbg !447
  br i1 %.not.not.i.i, label %L66.i.i, label %L137.i.i, !dbg !451

L66.i.i:                                          ; preds = %top
  %12 = icmp eq i64 %arraylen.i.fr.i, 1, !dbg !452
  %.not58.i.i = icmp eq i64 %arraylen.i.fr.i, 0, !dbg !463
  br i1 %.not58.i.i, label %fwddiffejulia_f_2949wrap.exit, label %L103.lr.ph.i.i, !dbg !465

L103.lr.ph.i.i:                                   ; preds = %L66.i.i
  %"'ipc.i.i" = addrspacecast {} addrspace(10)* %1 to double addrspace(13)* addrspace(11)*
  %13 = addrspacecast {} addrspace(10)* %0 to double addrspace(13)* addrspace(11)*
  %"arrayptr60'ipl.i.i" = load double addrspace(13)*, double addrspace(13)* addrspace(11)* %"'ipc.i.i", align 16, !tbaa !151, !alias.scope !466, !noalias !469, !nonnull !11
  %"arrayptr60'ipl.i.fr.i" = freeze double addrspace(13)* %"arrayptr60'ipl.i.i"
  %arrayptr60.i.i = load double addrspace(13)*, double addrspace(13)* addrspace(11)* %13, align 16, !tbaa !151, !alias.scope !470, !noalias !417, !nonnull !11
  %arrayptr60.i.fr.i = freeze double addrspace(13)* %arrayptr60.i.i
  %"'ipc9.i.i" = addrspacecast {} addrspace(10)* %10 to double addrspace(13)* addrspace(11)*
  %14 = addrspacecast {} addrspace(10)* %9 to double addrspace(13)* addrspace(11)*
  %"arrayptr3261'ipl.i.i" = load double addrspace(13)*, double addrspace(13)* addrspace(11)* %"'ipc9.i.i", align 8, !tbaa !151, !alias.scope !471, !noalias !472, !nonnull !11
  %arrayptr3261.i.i = load double addrspace(13)*, double addrspace(13)* addrspace(11)* %14, align 8, !tbaa !151, !alias.scope !473, !noalias !445, !nonnull !11
  %min.iters.check.i = icmp ult i64 %arraylen.i.fr.i, 20, !dbg !419
  br i1 %min.iters.check.i, label %scalar.ph.i, label %vector.memcheck.i, !dbg !419

vector.memcheck.i:                                ; preds = %L103.lr.ph.i.i
  %scevgep.i = getelementptr double, double addrspace(13)* %"arrayptr3261'ipl.i.i", i64 %arraylen.i.fr.i, !dbg !419
  %scevgep4.i = getelementptr double, double addrspace(13)* %arrayptr3261.i.i, i64 %arraylen.i.fr.i, !dbg !419
  %scevgep7.i = getelementptr double, double addrspace(13)* %"arrayptr60'ipl.i.fr.i", i64 1, !dbg !419
  %scevgep9.i = getelementptr double, double addrspace(13)* %"arrayptr60'ipl.i.fr.i", i64 %arraylen.i.fr.i, !dbg !419
  %scevgep13.i = getelementptr double, double addrspace(13)* %arrayptr60.i.fr.i, i64 1, !dbg !419
  %scevgep15.i = getelementptr double, double addrspace(13)* %arrayptr60.i.fr.i, i64 %arraylen.i.fr.i, !dbg !419
  %bound0.i = icmp ult double addrspace(13)* %"arrayptr3261'ipl.i.i", %scevgep4.i, !dbg !419
  %bound1.i = icmp ult double addrspace(13)* %arrayptr3261.i.i, %scevgep.i, !dbg !419
  %found.conflict.i = and i1 %bound1.i, %bound0.i, !dbg !419
  %bound026.i = icmp ult double addrspace(13)* %"arrayptr3261'ipl.i.i", %scevgep7.i, !dbg !419
  %bound127.i = icmp ult double addrspace(13)* %"arrayptr60'ipl.i.fr.i", %scevgep.i, !dbg !419
  %bound029.i = icmp ult double addrspace(13)* %"arrayptr3261'ipl.i.i", %scevgep9.i, !dbg !419
  %found.conflict281.i = or i1 %bound026.i, %bound029.i, !dbg !419
  %15 = and i1 %found.conflict281.i, %bound127.i, !dbg !419
  %conflict.rdx32.i = or i1 %15, %found.conflict.i, !dbg !419
  %bound033.i = icmp ult double addrspace(13)* %"arrayptr3261'ipl.i.i", %scevgep13.i, !dbg !419
  %bound134.i = icmp ult double addrspace(13)* %arrayptr60.i.fr.i, %scevgep.i, !dbg !419
  %bound037.i = icmp ult double addrspace(13)* %"arrayptr3261'ipl.i.i", %scevgep15.i, !dbg !419
  %found.conflict352.i = or i1 %bound033.i, %bound037.i, !dbg !419
  %16 = and i1 %bound134.i, %found.conflict352.i, !dbg !419
  %conflict.rdx40.i = or i1 %16, %conflict.rdx32.i, !dbg !419
  %bound041.i = icmp ult double addrspace(13)* %arrayptr3261.i.i, %scevgep7.i, !dbg !419
  %bound142.i = icmp ult double addrspace(13)* %"arrayptr60'ipl.i.fr.i", %scevgep4.i, !dbg !419
  %bound045.i = icmp ult double addrspace(13)* %arrayptr3261.i.i, %scevgep9.i, !dbg !419
  %found.conflict433.i = or i1 %bound041.i, %bound045.i, !dbg !419
  %17 = and i1 %found.conflict433.i, %bound142.i, !dbg !419
  %conflict.rdx48.i = or i1 %17, %conflict.rdx40.i, !dbg !419
  %bound049.i = icmp ult double addrspace(13)* %arrayptr3261.i.i, %scevgep13.i, !dbg !419
  %bound150.i = icmp ult double addrspace(13)* %arrayptr60.i.fr.i, %scevgep4.i, !dbg !419
  %bound053.i = icmp ult double addrspace(13)* %arrayptr3261.i.i, %scevgep15.i, !dbg !419
  %found.conflict514.i = or i1 %bound049.i, %bound053.i, !dbg !419
  %18 = and i1 %found.conflict514.i, %bound150.i, !dbg !419
  %conflict.rdx56.i = or i1 %18, %conflict.rdx48.i, !dbg !419
  br i1 %conflict.rdx56.i, label %scalar.ph.i, label %vector.ph.i, !dbg !419

vector.ph.i:                                      ; preds = %vector.memcheck.i
  %n.vec.i = and i64 %arraylen.i.fr.i, -4, !dbg !419
  br label %vector.body.i, !dbg !419

vector.body.i:                                    ; preds = %vector.body.i, %vector.ph.i
  %iv = phi i64 [ %iv.next, %vector.body.i ], [ 0, %vector.ph.i ], !dbg !474
  %19 = shl nuw i64 %iv, 2, !dbg !419
  %iv.next = add nuw nsw i64 %iv, 1, !dbg !419
  %20 = or i64 %19, 1, !dbg !419
  %21 = or i64 %19, 2, !dbg !419
  %22 = or i64 %19, 3, !dbg !419
  %23 = select i1 %12, i64 0, i64 %19, !dbg !477
  %24 = select i1 %12, i64 0, i64 %20, !dbg !477
  %25 = select i1 %12, i64 0, i64 %21, !dbg !477
  %26 = select i1 %12, i64 0, i64 %22, !dbg !477
  %27 = getelementptr inbounds double, double addrspace(13)* %"arrayptr60'ipl.i.fr.i", i64 %23, !dbg !477
  %28 = getelementptr inbounds double, double addrspace(13)* %"arrayptr60'ipl.i.fr.i", i64 %24, !dbg !477
  %29 = getelementptr inbounds double, double addrspace(13)* %"arrayptr60'ipl.i.fr.i", i64 %25, !dbg !477
  %30 = getelementptr inbounds double, double addrspace(13)* %"arrayptr60'ipl.i.fr.i", i64 %26, !dbg !477
  %31 = getelementptr inbounds double, double addrspace(13)* %arrayptr60.i.fr.i, i64 %23, !dbg !477
  %32 = getelementptr inbounds double, double addrspace(13)* %arrayptr60.i.fr.i, i64 %24, !dbg !477
  %33 = getelementptr inbounds double, double addrspace(13)* %arrayptr60.i.fr.i, i64 %25, !dbg !477
  %34 = getelementptr inbounds double, double addrspace(13)* %arrayptr60.i.fr.i, i64 %26, !dbg !477
  %35 = load double, double addrspace(13)* %27, align 8, !dbg !477, !tbaa !180, !alias.scope !485, !noalias !490
  %36 = load double, double addrspace(13)* %28, align 8, !dbg !477, !tbaa !180, !alias.scope !485, !noalias !490
  %37 = load double, double addrspace(13)* %29, align 8, !dbg !477, !tbaa !180, !alias.scope !485, !noalias !490
  %38 = load double, double addrspace(13)* %30, align 8, !dbg !477, !tbaa !180, !alias.scope !485, !noalias !490
  %39 = insertelement <4 x double> poison, double %35, i64 0, !dbg !477
  %40 = insertelement <4 x double> %39, double %36, i64 1, !dbg !477
  %41 = insertelement <4 x double> %40, double %37, i64 2, !dbg !477
  %42 = insertelement <4 x double> %41, double %38, i64 3, !dbg !477
  %43 = load double, double addrspace(13)* %31, align 8, !dbg !477, !tbaa !180, !alias.scope !492, !noalias !494
  %44 = load double, double addrspace(13)* %32, align 8, !dbg !477, !tbaa !180, !alias.scope !492, !noalias !494
  %45 = load double, double addrspace(13)* %33, align 8, !dbg !477, !tbaa !180, !alias.scope !492, !noalias !494
  %46 = load double, double addrspace(13)* %34, align 8, !dbg !477, !tbaa !180, !alias.scope !492, !noalias !494
  %47 = insertelement <4 x double> poison, double %43, i64 0, !dbg !419
  %48 = insertelement <4 x double> %47, double %44, i64 1, !dbg !419
  %49 = insertelement <4 x double> %48, double %45, i64 2, !dbg !419
  %50 = insertelement <4 x double> %49, double %46, i64 3, !dbg !419
  %51 = fmul <4 x double> %50, %50, !dbg !419
  %52 = fmul <4 x double> %50, %51, !dbg !495
  %53 = fmul fast <4 x double> %42, <double 3.000000e+00, double 3.000000e+00, double 3.000000e+00, double 3.000000e+00>, !dbg !419
  %54 = fmul fast <4 x double> %53, %51, !dbg !500
  %55 = getelementptr inbounds double, double addrspace(13)* %"arrayptr3261'ipl.i.i", i64 %19, !dbg !500
  %56 = getelementptr inbounds double, double addrspace(13)* %arrayptr3261.i.i, i64 %19, !dbg !500
  %57 = bitcast double addrspace(13)* %55 to <4 x double> addrspace(13)*, !dbg !500
  store <4 x double> %54, <4 x double> addrspace(13)* %57, align 8, !dbg !500, !tbaa !180, !alias.scope !501, !noalias !505
  %58 = bitcast double addrspace(13)* %56 to <4 x double> addrspace(13)*, !dbg !500
  store <4 x double> %52, <4 x double> addrspace(13)* %58, align 8, !dbg !500, !tbaa !180, !alias.scope !510, !noalias !511
  %index.next.i = add nuw i64 %19, 4, !dbg !474
  %59 = icmp eq i64 %index.next.i, %n.vec.i, !dbg !474
  br i1 %59, label %middle.block.i, label %vector.body.i, !dbg !474, !llvm.loop !512

middle.block.i:                                   ; preds = %vector.body.i
  %cmp.n.i = icmp eq i64 %arraylen.i.fr.i, %n.vec.i, !dbg !419
  br i1 %cmp.n.i, label %fwddiffejulia_f_2949wrap.exit, label %scalar.ph.i, !dbg !419

scalar.ph.i:                                      ; preds = %middle.block.i, %vector.memcheck.i, %L103.lr.ph.i.i
  %bc.resume.val.i = phi i64 [ %n.vec.i, %middle.block.i ], [ 0, %L103.lr.ph.i.i ], [ 0, %vector.memcheck.i ]
  br label %L103.i.i, !dbg !419

L103.i.i:                                         ; preds = %L103.i.i, %scalar.ph.i
  %iv1 = phi i64 [ %iv.next2, %L103.i.i ], [ 0, %scalar.ph.i ]
  %60 = add nuw nsw i64 %bc.resume.val.i, %iv1, !dbg !474
  %iv.next2 = add nuw nsw i64 %iv1, 1, !dbg !474
  %iv.next.i.i = add nuw nsw i64 %60, 1, !dbg !474
  %61 = select i1 %12, i64 0, i64 %60, !dbg !477
  %"'ipg.i.i" = getelementptr inbounds double, double addrspace(13)* %"arrayptr60'ipl.i.fr.i", i64 %61, !dbg !477
  %62 = getelementptr inbounds double, double addrspace(13)* %arrayptr60.i.fr.i, i64 %61, !dbg !477
  %"arrayref'ipl.i.i" = load double, double addrspace(13)* %"'ipg.i.i", align 8, !dbg !477, !tbaa !180, !alias.scope !513, !noalias !490
  %arrayref.i.i = load double, double addrspace(13)* %62, align 8, !dbg !477, !tbaa !180, !alias.scope !514, !noalias !494
  %63 = fmul double %arrayref.i.i, %arrayref.i.i, !dbg !495
  %64 = fmul double %arrayref.i.i, %63, !dbg !495
  %65 = fmul fast double %"arrayref'ipl.i.i", 3.000000e+00, !dbg !500
  %66 = fmul fast double %65, %63, !dbg !500
  %"'ipg10.i.i" = getelementptr inbounds double, double addrspace(13)* %"arrayptr3261'ipl.i.i", i64 %60, !dbg !500
  %67 = getelementptr inbounds double, double addrspace(13)* %arrayptr3261.i.i, i64 %60, !dbg !500
  store double %66, double addrspace(13)* %"'ipg10.i.i", align 8, !dbg !500, !tbaa !180, !alias.scope !515, !noalias !516
  store double %64, double addrspace(13)* %67, align 8, !dbg !500, !tbaa !180, !alias.scope !517, !noalias !518
  %exitcond.not.i.i = icmp eq i64 %iv.next.i.i, %arraylen.i.fr.i, !dbg !519
  br i1 %exitcond.not.i.i, label %fwddiffejulia_f_2949wrap.exit.loopexit, label %L103.i.i, !dbg !419, !llvm.loop !521

L137.i.i:                                         ; preds = %top
  %68 = getelementptr inbounds [1 x [1 x i64]], [1 x [1 x i64]]* %newstruct44.i.i, i64 0, i64 0, i64 0, !dbg !522
  store i64 %arraylen20.i.i, i64* %68, align 8, !dbg !522, !tbaa !86, !alias.scope !88, !noalias !425
  %69 = addrspacecast [1 x [1 x i64]]* %newstruct44.i.i to [1 x [1 x i64]] addrspace(11)*, !dbg !451
  %70 = addrspacecast [1 x [1 x i64]]* %newstruct6.i.i to [1 x [1 x i64]] addrspace(11)*, !dbg !451
  call fastcc void @julia_throwdm_2954([1 x [1 x i64]] addrspace(11)* nocapture nofree noundef nonnull readonly align 8 dereferenceable(8) %69, [1 x [1 x i64]] addrspace(11)* nocapture nofree noundef nonnull readonly align 8 dereferenceable(8) %70) #13, !dbg !451
  unreachable, !dbg !451

fwddiffejulia_f_2949wrap.exit.loopexit:           ; preds = %L103.i.i
  br label %fwddiffejulia_f_2949wrap.exit

fwddiffejulia_f_2949wrap.exit:                    ; preds = %fwddiffejulia_f_2949wrap.exit.loopexit, %middle.block.i, %L66.i.i
  call void @llvm.lifetime.end.p0i8(i64 noundef 8, i8* noundef nonnull %5) #11
  call void @llvm.lifetime.end.p0i8(i64 noundef 8, i8* noundef nonnull %6) #11
  ret {} addrspace(10)* %10, !dbg !526
}

; Function Attrs: mustprogress willreturn
define internal {} addrspace(10)* @fwddiffejulia__f_2881({} addrspace(10)* nocapture noundef nonnull readonly align 16 dereferenceable(40) "enzyme_type"="{[-1]:Pointer, [-1,0]:Pointer, [-1,0,-1]:Float@double, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer}" "enzymejl_parmtype"="140480217219936" "enzymejl_parmtype_ref"="2" %0, {} addrspace(10)* nocapture align 16 "enzyme_type"="{[-1]:Pointer, [-1,0]:Pointer, [-1,0,-1]:Float@double, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer}" "enzymejl_parmtype"="140480217219936" "enzymejl_parmtype_ref"="2" %"'", {} addrspace(10)* nocapture noundef nonnull readonly align 16 dereferenceable(40) "enzyme_type"="{[-1]:Pointer, [-1,0]:Pointer, [-1,0,-1]:Float@double, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer}" "enzymejl_parmtype"="140480217219936" "enzymejl_parmtype_ref"="2" %1) local_unnamed_addr #10 !dbg !531 {
top:
  %"iv'ac" = alloca i64, align 8
  %"iv1'ac" = alloca i64, align 8
  %newstruct6.i.i = alloca [1 x [1 x i64]], align 8
  %newstruct44.i.i = alloca [1 x [1 x i64]], align 8
  %2 = call {}*** @julia.get_pgcstack() #11
  %ptls_field3 = getelementptr inbounds {}**, {}*** %2, i64 2
  %3 = bitcast {}*** %ptls_field3 to i64***
  %ptls_load45 = load i64**, i64*** %3, align 8, !tbaa !12, !alias.scope !532, !noalias !535
  %4 = getelementptr inbounds i64*, i64** %ptls_load45, i64 2
  %safepoint = load i64*, i64** %4, align 8, !tbaa !16, !alias.scope !537, !noalias !540
  fence syncscope("singlethread") seq_cst
  call void @julia.safepoint(i64* %safepoint) #11, !dbg !542
  fence syncscope("singlethread") seq_cst
  %ptls_load5657.i.i = load i64**, i64*** %3, align 8, !tbaa !12, !alias.scope !543, !noalias !544
  %5 = getelementptr inbounds i64*, i64** %ptls_load5657.i.i, i64 2
  %safepoint.i.i = load i64*, i64** %5, align 8, !tbaa !16, !alias.scope !545, !noalias !548
  fence syncscope("singlethread") seq_cst
  call void @julia.safepoint(i64* %safepoint.i.i) #11, !dbg !550
  fence syncscope("singlethread") seq_cst
  %6 = addrspacecast {} addrspace(10)* %0 to { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(11)*, !dbg !557
  %arraylen_ptr.i.i = getelementptr inbounds { i8 addrspace(13)*, i64, i16, i16, i32 }, { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(11)* %6, i64 0, i32 1, !dbg !557
  %arraylen.i.i = load i64, i64 addrspace(11)* %arraylen_ptr.i.i, align 8, !dbg !557, !tbaa !59, !range !62, !alias.scope !564, !noalias !567
  %arraylen.i.fr.i = freeze i64 %arraylen.i.i, !dbg !569
  %memcpy_refined_dst.i.i = getelementptr inbounds [1 x [1 x i64]], [1 x [1 x i64]]* %newstruct6.i.i, i64 0, i64 0, i64 0, !dbg !573
  store i64 %arraylen.i.fr.i, i64* %memcpy_refined_dst.i.i, align 8, !dbg !573, !tbaa !86, !alias.scope !88, !noalias !575
  %7 = call noalias nonnull "enzyme_type"="{[-1]:Pointer, [-1,0]:Pointer, [-1,0,-1]:Float@double, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer}" {} addrspace(10)* @ijl_alloc_array_1d({} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 140480217219936 to {}*) to {} addrspace(10)*), i64 noundef %arraylen.i.fr.i) #12, !dbg !582
  %8 = call noalias nonnull "enzyme_type"="{[-1]:Pointer, [-1,0]:Pointer, [-1,0,-1]:Float@double, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer}" {} addrspace(10)* @ijl_alloc_array_1d({} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 140480217219936 to {}*) to {} addrspace(10)*), i64 noundef %arraylen.i.fr.i) #12, !dbg !582
  %9 = call noalias nonnull "enzyme_type"="{[-1]:Pointer, [-1,0]:Pointer, [-1,0,-1]:Float@double, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer}" {} addrspace(10)* @ijl_alloc_array_1d({} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 140480217219936 to {}*) to {} addrspace(10)*), i64 noundef %arraylen.i.fr.i) #12, !dbg !582
  %10 = call noalias nonnull "enzyme_type"="{[-1]:Pointer, [-1,0]:Pointer, [-1,0,-1]:Float@double, [-1,8]:Integer, [-1,9]:Integer, [-1,10]:Integer, [-1,11]:Integer, [-1,12]:Integer, [-1,13]:Integer, [-1,14]:Integer, [-1,15]:Integer, [-1,16]:Integer, [-1,17]:Integer, [-1,18]:Integer, [-1,19]:Integer, [-1,20]:Integer, [-1,21]:Integer, [-1,22]:Integer, [-1,23]:Integer, [-1,24]:Integer, [-1,25]:Integer, [-1,26]:Integer, [-1,27]:Integer, [-1,28]:Integer, [-1,29]:Integer, [-1,30]:Integer, [-1,31]:Integer, [-1,32]:Integer, [-1,33]:Integer, [-1,34]:Integer, [-1,35]:Integer, [-1,36]:Integer, [-1,37]:Integer, [-1,38]:Integer, [-1,39]:Integer}" {} addrspace(10)* @ijl_alloc_array_1d({} addrspace(10)* noundef addrspacecast ({}* inttoptr (i64 140480217219936 to {}*) to {} addrspace(10)*), i64 noundef %arraylen.i.fr.i) #12, !dbg !582
  %11 = addrspacecast {} addrspace(10)* %7 to { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(11)*, !dbg !589
  %arraylen_ptr19.i.i = getelementptr inbounds { i8 addrspace(13)*, i64, i16, i16, i32 }, { i8 addrspace(13)*, i64, i16, i16, i32 } addrspace(11)* %11, i64 0, i32 1, !dbg !589
  %arraylen20.i.i = load i64, i64 addrspace(11)* %arraylen_ptr19.i.i, align 8, !dbg !589, !tbaa !59, !range !62, !alias.scope !592, !noalias !595
  %.not.not.i.i = icmp eq i64 %arraylen20.i.i, %arraylen.i.fr.i, !dbg !597
  br i1 %.not.not.i.i, label %L66.i.i, label %L137.i.i, !dbg !601

L66.i.i:                                          ; preds = %top
  %12 = icmp eq i64 %arraylen.i.fr.i, 1, !dbg !602
  %.not58.i.i = icmp eq i64 %arraylen.i.fr.i, 0, !dbg !613
  br i1 %.not58.i.i, label %fwddiffejulia_f_2949wrap.exit, label %L103.lr.ph.i.i, !dbg !615

L103.lr.ph.i.i:                                   ; preds = %L66.i.i
  %"'ipc.i.i" = addrspacecast {} addrspace(10)* %1 to double addrspace(13)* addrspace(11)*
  %"'ipc" = addrspacecast {} addrspace(10)* %"'" to double addrspace(13)* addrspace(11)*
  %13 = addrspacecast {} addrspace(10)* %0 to double addrspace(13)* addrspace(11)*
  %"arrayptr60'ipl.i.i" = load double addrspace(13)*, double addrspace(13)* addrspace(11)* %"'ipc.i.i", align 16, !tbaa !151, !alias.scope !616, !noalias !619, !nonnull !11
  %"arrayptr60'ipl.i.fr.i" = freeze double addrspace(13)* %"arrayptr60'ipl.i.i"
  %"arrayptr60.i.i'ipl" = load double addrspace(13)*, double addrspace(13)* addrspace(11)* %"'ipc", align 16, !tbaa !151, !alias.scope !621, !noalias !622, !nonnull !11
  %arrayptr60.i.i = load double addrspace(13)*, double addrspace(13)* addrspace(11)* %13, align 16, !tbaa !151, !alias.scope !623, !noalias !567, !nonnull !11
  %arrayptr60.i.fr.i = freeze double addrspace(13)* %arrayptr60.i.i
  %"arrayptr60.i.fr.i'dual_phi" = phi double addrspace(13)* 
  %"'ipc9.i.i'ipc" = addrspacecast {} addrspace(10)* %10 to double addrspace(13)* addrspace(11)*
  %"'ipc9.i.i" = addrspacecast {} addrspace(10)* %9 to double addrspace(13)* addrspace(11)*
  %"'ipc31" = addrspacecast {} addrspace(10)* %8 to double addrspace(13)* addrspace(11)*
  %14 = addrspacecast {} addrspace(10)* %7 to double addrspace(13)* addrspace(11)*
  %"arrayptr3261'ipl.i.i'ipl" = load double addrspace(13)*, double addrspace(13)* addrspace(11)* %"'ipc9.i.i'ipc", align 8, !tbaa !151, !alias.scope !624, !noalias !627, !nonnull !11
  %"arrayptr3261'ipl.i.i" = load double addrspace(13)*, double addrspace(13)* addrspace(11)* %"'ipc9.i.i", align 8, !tbaa !151, !alias.scope !629, !noalias !630, !nonnull !11
  %"arrayptr3261.i.i'ipl" = load double addrspace(13)*, double addrspace(13)* addrspace(11)* %"'ipc31", align 8, !tbaa !151, !alias.scope !631, !noalias !632, !nonnull !11
  %arrayptr3261.i.i = load double addrspace(13)*, double addrspace(13)* addrspace(11)* %14, align 8, !tbaa !151, !alias.scope !633, !noalias !595, !nonnull !11
  %min.iters.check.i = icmp ult i64 %arraylen.i.fr.i, 20, !dbg !569
  br i1 %min.iters.check.i, label %scalar.ph.i, label %vector.memcheck.i, !dbg !569

vector.memcheck.i:                                ; preds = %L103.lr.ph.i.i
  %scevgep.i = getelementptr double, double addrspace(13)* %"arrayptr3261'ipl.i.i", i64 %arraylen.i.fr.i, !dbg !569
  %scevgep4.i = getelementptr double, double addrspace(13)* %arrayptr3261.i.i, i64 %arraylen.i.fr.i, !dbg !569
  %scevgep7.i = getelementptr double, double addrspace(13)* %"arrayptr60'ipl.i.fr.i", i64 1, !dbg !569
  %scevgep9.i = getelementptr double, double addrspace(13)* %"arrayptr60'ipl.i.fr.i", i64 %arraylen.i.fr.i, !dbg !569
  %scevgep13.i = getelementptr double, double addrspace(13)* %arrayptr60.i.fr.i, i64 1, !dbg !569
  %scevgep15.i = getelementptr double, double addrspace(13)* %arrayptr60.i.fr.i, i64 %arraylen.i.fr.i, !dbg !569
  %bound0.i = icmp ult double addrspace(13)* %"arrayptr3261'ipl.i.i", %scevgep4.i, !dbg !569
  %bound1.i = icmp ult double addrspace(13)* %arrayptr3261.i.i, %scevgep.i, !dbg !569
  %found.conflict.i = and i1 %bound1.i, %bound0.i, !dbg !569
  %bound026.i = icmp ult double addrspace(13)* %"arrayptr3261'ipl.i.i", %scevgep7.i, !dbg !569
  %bound127.i = icmp ult double addrspace(13)* %"arrayptr60'ipl.i.fr.i", %scevgep.i, !dbg !569
  %bound029.i = icmp ult double addrspace(13)* %"arrayptr3261'ipl.i.i", %scevgep9.i, !dbg !569
  %found.conflict281.i = or i1 %bound026.i, %bound029.i, !dbg !569
  %15 = and i1 %found.conflict281.i, %bound127.i, !dbg !569
  %conflict.rdx32.i = or i1 %15, %found.conflict.i, !dbg !569
  %bound033.i = icmp ult double addrspace(13)* %"arrayptr3261'ipl.i.i", %scevgep13.i, !dbg !569
  %bound134.i = icmp ult double addrspace(13)* %arrayptr60.i.fr.i, %scevgep.i, !dbg !569
  %bound037.i = icmp ult double addrspace(13)* %"arrayptr3261'ipl.i.i", %scevgep15.i, !dbg !569
  %found.conflict352.i = or i1 %bound033.i, %bound037.i, !dbg !569
  %16 = and i1 %bound134.i, %found.conflict352.i, !dbg !569
  %conflict.rdx40.i = or i1 %16, %conflict.rdx32.i, !dbg !569
  %bound041.i = icmp ult double addrspace(13)* %arrayptr3261.i.i, %scevgep7.i, !dbg !569
  %bound142.i = icmp ult double addrspace(13)* %"arrayptr60'ipl.i.fr.i", %scevgep4.i, !dbg !569
  %bound045.i = icmp ult double addrspace(13)* %arrayptr3261.i.i, %scevgep9.i, !dbg !569
  %found.conflict433.i = or i1 %bound041.i, %bound045.i, !dbg !569
  %17 = and i1 %found.conflict433.i, %bound142.i, !dbg !569
  %conflict.rdx48.i = or i1 %17, %conflict.rdx40.i, !dbg !569
  %bound049.i = icmp ult double addrspace(13)* %arrayptr3261.i.i, %scevgep13.i, !dbg !569
  %bound150.i = icmp ult double addrspace(13)* %arrayptr60.i.fr.i, %scevgep4.i, !dbg !569
  %bound053.i = icmp ult double addrspace(13)* %arrayptr3261.i.i, %scevgep15.i, !dbg !569
  %found.conflict514.i = or i1 %bound049.i, %bound053.i, !dbg !569
  %18 = and i1 %found.conflict514.i, %bound150.i, !dbg !569
  %conflict.rdx56.i = or i1 %18, %conflict.rdx48.i, !dbg !569
  br i1 %conflict.rdx56.i, label %scalar.ph.i, label %vector.ph.i, !dbg !569

vector.ph.i:                                      ; preds = %vector.memcheck.i
  %n.vec.i = and i64 %arraylen.i.fr.i, -4, !dbg !569
  %19 = add i64 %n.vec.i, -4, !dbg !569
  %20 = lshr i64 %19, 2, !dbg !569
  br label %vector.body.i, !dbg !569

vector.body.i:                                    ; preds = %vector.body.i, %vector.ph.i
  %iv = phi i64 [ %iv.next, %vector.body.i ], [ 0, %vector.ph.i ], !dbg !634
  %iv.next = add nuw nsw i64 %iv, 1, !dbg !569
  %21 = shl nuw i64 %iv, 2, !dbg !569
  %22 = or i64 %21, 1, !dbg !569
  %23 = or i64 %21, 2, !dbg !569
  %24 = or i64 %21, 3, !dbg !569
  %25 = select i1 %12, i64 0, i64 %21, !dbg !637
  %26 = select i1 %12, i64 0, i64 %22, !dbg !637
  %27 = select i1 %12, i64 0, i64 %23, !dbg !637
  %28 = select i1 %12, i64 0, i64 %24, !dbg !637
  %29 = getelementptr inbounds double, double addrspace(13)* %"arrayptr60'ipl.i.fr.i", i64 %25, !dbg !637
  %30 = getelementptr inbounds double, double addrspace(13)* %"arrayptr60'ipl.i.fr.i", i64 %26, !dbg !637
  %31 = getelementptr inbounds double, double addrspace(13)* %"arrayptr60'ipl.i.fr.i", i64 %27, !dbg !637
  %32 = getelementptr inbounds double, double addrspace(13)* %"arrayptr60'ipl.i.fr.i", i64 %28, !dbg !637
  %"'ipg" = getelementptr inbounds double, double addrspace(13)* %"arrayptr60.i.fr.i'dual_phi", i64 %25, !dbg !637
  %33 = getelementptr inbounds double, double addrspace(13)* %arrayptr60.i.fr.i, i64 %25, !dbg !637
  %"'ipg32" = getelementptr inbounds double, double addrspace(13)* %"arrayptr60.i.fr.i'dual_phi", i64 %26, !dbg !637
  %34 = getelementptr inbounds double, double addrspace(13)* %arrayptr60.i.fr.i, i64 %26, !dbg !637
  %"'ipg33" = getelementptr inbounds double, double addrspace(13)* %"arrayptr60.i.fr.i'dual_phi", i64 %27, !dbg !637
  %35 = getelementptr inbounds double, double addrspace(13)* %arrayptr60.i.fr.i, i64 %27, !dbg !637
  %"'ipg34" = getelementptr inbounds double, double addrspace(13)* %"arrayptr60.i.fr.i'dual_phi", i64 %28, !dbg !637
  %36 = getelementptr inbounds double, double addrspace(13)* %arrayptr60.i.fr.i, i64 %28, !dbg !637
  %37 = load double, double addrspace(13)* %29, align 8, !dbg !637, !tbaa !180, !alias.scope !645, !noalias !648
  %38 = load double, double addrspace(13)* %30, align 8, !dbg !637, !tbaa !180, !alias.scope !645, !noalias !648
  %39 = load double, double addrspace(13)* %31, align 8, !dbg !637, !tbaa !180, !alias.scope !645, !noalias !648
  %40 = load double, double addrspace(13)* %32, align 8, !dbg !637, !tbaa !180, !alias.scope !645, !noalias !648
  %41 = insertelement <4 x double> poison, double %37, i64 0, !dbg !637
  %42 = insertelement <4 x double> %41, double %38, i64 1, !dbg !637
  %43 = insertelement <4 x double> %42, double %39, i64 2, !dbg !637
  %44 = insertelement <4 x double> %43, double %40, i64 3, !dbg !637
  %"'ipl" = load double, double addrspace(13)* %"'ipg", align 8, !dbg !637, !tbaa !180, !alias.scope !650, !noalias !653
  %45 = load double, double addrspace(13)* %33, align 8, !dbg !637, !tbaa !180, !alias.scope !655, !noalias !656
  %"'ipl35" = load double, double addrspace(13)* %"'ipg32", align 8, !dbg !637, !tbaa !180, !alias.scope !650, !noalias !653
  %46 = load double, double addrspace(13)* %34, align 8, !dbg !637, !tbaa !180, !alias.scope !655, !noalias !656
  %"'ipl36" = load double, double addrspace(13)* %"'ipg33", align 8, !dbg !637, !tbaa !180, !alias.scope !650, !noalias !653
  %47 = load double, double addrspace(13)* %35, align 8, !dbg !637, !tbaa !180, !alias.scope !655, !noalias !656
  %"'ipl37" = load double, double addrspace(13)* %"'ipg34", align 8, !dbg !637, !tbaa !180, !alias.scope !650, !noalias !653
  %48 = load double, double addrspace(13)* %36, align 8, !dbg !637, !tbaa !180, !alias.scope !655, !noalias !656
  %"'ipie" = insertelement <4 x double> zeroinitializer, double %"'ipl", i64 0, !dbg !569
  %49 = insertelement <4 x double> poison, double %45, i64 0, !dbg !569
  %"'ipie38" = insertelement <4 x double> %"'ipie", double %"'ipl35", i64 1, !dbg !569
  %50 = insertelement <4 x double> %49, double %46, i64 1, !dbg !569
  %"'ipie39" = insertelement <4 x double> %"'ipie38", double %"'ipl36", i64 2, !dbg !569
  %51 = insertelement <4 x double> %50, double %47, i64 2, !dbg !569
  %"'ipie40" = insertelement <4 x double> %"'ipie39", double %"'ipl37", i64 3, !dbg !569
  %52 = insertelement <4 x double> %51, double %48, i64 3, !dbg !569
  %53 = fmul <4 x double> %52, %52, !dbg !569
  %54 = fmul fast <4 x double> %"'ipie40", %52, !dbg !657
  %55 = fadd fast <4 x double> zeroinitializer, %54, !dbg !657
  %56 = fmul fast <4 x double> %"'ipie40", %52, !dbg !657
  %57 = fadd fast <4 x double> %55, %56, !dbg !657
  %58 = fmul <4 x double> %52, %53, !dbg !657
  %59 = fmul fast <4 x double> %"'ipie40", %53, !dbg !569
  %60 = fadd fast <4 x double> zeroinitializer, %59, !dbg !569
  %61 = fmul fast <4 x double> %57, %52, !dbg !569
  %62 = fadd fast <4 x double> %60, %61, !dbg !569
  %63 = fmul fast <4 x double> %44, <double 3.000000e+00, double 3.000000e+00, double 3.000000e+00, double 3.000000e+00>, !dbg !569
  %64 = fmul fast <4 x double> %63, %53, !dbg !662
  %65 = fmul fast <4 x double> %57, %63, !dbg !662
  %66 = fadd fast <4 x double> zeroinitializer, %65, !dbg !662
  %"'ipg41" = getelementptr inbounds double, double addrspace(13)* %"arrayptr3261'ipl.i.i'ipl", i64 %21, !dbg !662
  %67 = getelementptr inbounds double, double addrspace(13)* %"arrayptr3261'ipl.i.i", i64 %21, !dbg !662
  %"'ipg42" = getelementptr inbounds double, double addrspace(13)* %"arrayptr3261.i.i'ipl", i64 %21, !dbg !662
  %68 = getelementptr inbounds double, double addrspace(13)* %arrayptr3261.i.i, i64 %21, !dbg !662
  %"'ipc43" = bitcast double addrspace(13)* %"'ipg41" to <4 x double> addrspace(13)*, !dbg !662
  %69 = bitcast double addrspace(13)* %67 to <4 x double> addrspace(13)*, !dbg !662
  store <4 x double> %66, <4 x double> addrspace(13)* %"'ipc43", align 8, !dbg !662, !tbaa !180, !alias.scope !663, !noalias !666
  store <4 x double> %64, <4 x double> addrspace(13)* %69, align 8, !dbg !662, !tbaa !180, !alias.scope !668, !noalias !669
  %"'ipc44" = bitcast double addrspace(13)* %"'ipg42" to <4 x double> addrspace(13)*, !dbg !662
  %70 = bitcast double addrspace(13)* %68 to <4 x double> addrspace(13)*, !dbg !662
  store <4 x double> %62, <4 x double> addrspace(13)* %"'ipc44", align 8, !dbg !662, !tbaa !180, !alias.scope !670, !noalias !673
  store <4 x double> %58, <4 x double> addrspace(13)* %70, align 8, !dbg !662, !tbaa !180, !alias.scope !675, !noalias !676
  %index.next.i = add nuw i64 %21, 4, !dbg !634
  %71 = icmp eq i64 %index.next.i, %n.vec.i, !dbg !634
  br i1 %71, label %middle.block.i, label %vector.body.i, !dbg !634, !llvm.loop !677

middle.block.i:                                   ; preds = %vector.body.i
  %cmp.n.i = icmp eq i64 %arraylen.i.fr.i, %n.vec.i, !dbg !569
  br i1 %cmp.n.i, label %fwddiffejulia_f_2949wrap.exit, label %scalar.ph.i, !dbg !569

scalar.ph.i:                                      ; preds = %middle.block.i, %vector.memcheck.i, %L103.lr.ph.i.i
  %bc.resume.val.i = phi i64 [ %n.vec.i, %middle.block.i ], [ 0, %L103.lr.ph.i.i ], [ 0, %vector.memcheck.i ]
  %72 = add i64 %arraylen.i.fr.i, -1, !dbg !569
  %73 = sub i64 %72, %bc.resume.val.i, !dbg !569
  br label %L103.i.i, !dbg !569

L103.i.i:                                         ; preds = %L103.i.i, %scalar.ph.i
  %iv1 = phi i64 [ %iv.next2, %L103.i.i ], [ 0, %scalar.ph.i ]
  %iv.next2 = add nuw nsw i64 %iv1, 1, !dbg !634
  %74 = add nuw nsw i64 %bc.resume.val.i, %iv1, !dbg !634
  %iv.next.i.i = add nuw nsw i64 %74, 1, !dbg !634
  %75 = select i1 %12, i64 0, i64 %74, !dbg !637
  %"'ipg.i.i" = getelementptr inbounds double, double addrspace(13)* %"arrayptr60'ipl.i.fr.i", i64 %75, !dbg !637
  %"'ipg45" = getelementptr inbounds double, double addrspace(13)* %"arrayptr60.i.fr.i'dual_phi", i64 %75, !dbg !637
  %76 = getelementptr inbounds double, double addrspace(13)* %arrayptr60.i.fr.i, i64 %75, !dbg !637
  %"arrayref'ipl.i.i" = load double, double addrspace(13)* %"'ipg.i.i", align 8, !dbg !637, !tbaa !180, !alias.scope !678, !noalias !648
  %"arrayref.i.i'ipl" = load double, double addrspace(13)* %"'ipg45", align 8, !dbg !637, !tbaa !180, !alias.scope !679, !noalias !653
  %arrayref.i.i = load double, double addrspace(13)* %76, align 8, !dbg !637, !tbaa !180, !alias.scope !680, !noalias !656
  %77 = fmul double %arrayref.i.i, %arrayref.i.i, !dbg !657
  %78 = fmul fast double %"arrayref.i.i'ipl", %arrayref.i.i, !dbg !657
  %79 = fmul fast double %"arrayref.i.i'ipl", %arrayref.i.i, !dbg !657
  %80 = fadd fast double %78, %79, !dbg !657
  %81 = fmul double %arrayref.i.i, %77, !dbg !657
  %82 = fmul fast double %"arrayref.i.i'ipl", %77, !dbg !662
  %83 = fmul fast double %80, %arrayref.i.i, !dbg !662
  %84 = fadd fast double %82, %83, !dbg !662
  %85 = fmul fast double %"arrayref'ipl.i.i", 3.000000e+00, !dbg !662
  %86 = fmul fast double %85, %77, !dbg !662
  %87 = fmul fast double %80, %85, !dbg !662
  %"'ipg10.i.i'ipg" = getelementptr inbounds double, double addrspace(13)* %"arrayptr3261'ipl.i.i'ipl", i64 %74, !dbg !662
  %"'ipg10.i.i" = getelementptr inbounds double, double addrspace(13)* %"arrayptr3261'ipl.i.i", i64 %74, !dbg !662
  %"'ipg46" = getelementptr inbounds double, double addrspace(13)* %"arrayptr3261.i.i'ipl", i64 %74, !dbg !662
  %88 = getelementptr inbounds double, double addrspace(13)* %arrayptr3261.i.i, i64 %74, !dbg !662
  store double %87, double addrspace(13)* %"'ipg10.i.i'ipg", align 8, !dbg !662, !tbaa !180, !alias.scope !681, !noalias !682
  store double %86, double addrspace(13)* %"'ipg10.i.i", align 8, !dbg !662, !tbaa !180, !alias.scope !683, !noalias !684
  store double %84, double addrspace(13)* %"'ipg46", align 8, !dbg !662, !tbaa !180, !alias.scope !685, !noalias !686
  store double %81, double addrspace(13)* %88, align 8, !dbg !662, !tbaa !180, !alias.scope !687, !noalias !688
  %exitcond.not.i.i = icmp eq i64 %iv.next.i.i, %arraylen.i.fr.i, !dbg !689
  br i1 %exitcond.not.i.i, label %fwddiffejulia_f_2949wrap.exit.loopexit, label %L103.i.i, !dbg !569, !llvm.loop !691

L137.i.i:                                         ; preds = %top
  %89 = getelementptr inbounds [1 x [1 x i64]], [1 x [1 x i64]]* %newstruct44.i.i, i64 0, i64 0, i64 0, !dbg !692
  store i64 %arraylen20.i.i, i64* %89, align 8, !dbg !692, !tbaa !86, !alias.scope !88, !noalias !575
  %90 = addrspacecast [1 x [1 x i64]]* %newstruct44.i.i to [1 x [1 x i64]] addrspace(11)*, !dbg !601
  %91 = addrspacecast [1 x [1 x i64]]* %newstruct6.i.i to [1 x [1 x i64]] addrspace(11)*, !dbg !601
  call fastcc void @julia_throwdm_2954([1 x [1 x i64]] addrspace(11)* nocapture nofree noundef nonnull readonly align 8 dereferenceable(8) %90, [1 x [1 x i64]] addrspace(11)* nocapture nofree noundef nonnull readonly align 8 dereferenceable(8) %91) #13, !dbg !601
  unreachable, !dbg !601

fwddiffejulia_f_2949wrap.exit.loopexit:           ; preds = %L103.i.i
  br label %fwddiffejulia_f_2949wrap.exit

fwddiffejulia_f_2949wrap.exit:                    ; preds = %fwddiffejulia_f_2949wrap.exit.loopexit, %middle.block.i, %L66.i.i
  ret {} addrspace(10)* %10
}

JIT session error: Failed to materialize symbols: { (JuliaExternal, { ##func#2089 }) }

[162491] signal (11.1): Segmentation fault
in expression starting at /home/atila/Files/synced/phd/projects/julia/PINNs.jl/experiments/script5.jl:23
unknown function (ip: (nil))
Allocations: 21706709 (Pool: 21670279; Big: 36430); GC: 30
wsmoses commented 4 months ago

Resolved on main by jll bump. Please reopen if it persists

AtilaSaraiva commented 3 months ago

Hey @wsmoses , are you sure? I just tested with the Enzyme from the main branch and it is not working still.