|
| 1 | +; RUN: if [ %llvmver -ge 13 ]; then %opt < %s %loadEnzyme -enzyme -enzyme-preopt=false -mem2reg -instsimplify -simplifycfg -S | FileCheck %s; fi |
| 2 | +source_filename = "text" |
| 3 | +target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128" |
| 4 | +target triple = "x86_64-pc-linux-gnu" |
| 5 | + |
| 6 | +define private fastcc double @julia___2797(double %0, i64 signext %1) unnamed_addr #0 !dbg !7 { |
| 7 | +top: |
| 8 | + switch i64 %1, label %L20 [ |
| 9 | + i64 -1, label %L3 |
| 10 | + i64 0, label %L7 |
| 11 | + i64 1, label %L7.fold.split |
| 12 | + i64 2, label %L13 |
| 13 | + i64 3, label %L17 |
| 14 | + ], !dbg !9 |
| 15 | + |
| 16 | +L3: ; preds = %top |
| 17 | + %2 = fdiv double 1.000000e+00, %0, !dbg !10 |
| 18 | + ret double %2, !dbg !9 |
| 19 | + |
| 20 | +L7.fold.split: ; preds = %top |
| 21 | + br label %L7, !dbg !16 |
| 22 | + |
| 23 | +L7: ; preds = %top, %L7.fold.split |
| 24 | + %merge = phi double [ 1.000000e+00, %top ], [ %0, %L7.fold.split ] |
| 25 | + ret double %merge, !dbg !16 |
| 26 | + |
| 27 | +L13: ; preds = %top |
| 28 | + %3 = fmul double %0, %0, !dbg !17 |
| 29 | + ret double %3, !dbg !19 |
| 30 | + |
| 31 | +L17: ; preds = %top |
| 32 | + %4 = fmul double %0, %0, !dbg !20 |
| 33 | + %5 = fmul double %4, %0, !dbg !20 |
| 34 | + ret double %5, !dbg !24 |
| 35 | + |
| 36 | +L20: ; preds = %top |
| 37 | + %6 = sitofp i64 %1 to double, !dbg !25 |
| 38 | + %7 = call double @llvm.pow.f64(double %0, double %6), !dbg !27 |
| 39 | + ret double %7, !dbg !27 |
| 40 | +} |
| 41 | + |
| 42 | +; Function Attrs: nofree nosync nounwind readnone speculatable willreturn |
| 43 | +declare double @llvm.pow.f64(double, double) #1 |
| 44 | + |
| 45 | +; Function Attrs: nounwind |
| 46 | +declare double @__enzyme_autodiff(double (double, i64)*, ...) |
| 47 | + |
| 48 | +; Function Attrs: alwaysinline nosync readnone |
| 49 | +define double @julia_f_2794(double %0, i64 signext %1) local_unnamed_addr #2 !dbg !28 { |
| 50 | +entry: |
| 51 | + %2 = call fastcc double @julia___2797(double %0, i64 signext %1) #5, !dbg !29 |
| 52 | + ret double %2 |
| 53 | +} |
| 54 | + |
| 55 | +define double @test_derivative(double %x, i64 %y) { |
| 56 | +entry: |
| 57 | + %0 = tail call double (double (double, i64)*, ...) @__enzyme_autodiff(double (double, i64)* nonnull @julia_f_2794, double %x, i64 %y) |
| 58 | + ret double %0 |
| 59 | +} |
| 60 | + |
| 61 | +; CHECK: define internal { double } @diffejulia_f_2794(double %0, i64 signext %1, double %differeturn) local_unnamed_addr #5 !dbg !35 { |
| 62 | +; CHECK-NEXT: entry: |
| 63 | +; CHECK-NEXT: %2 = sub i64 %1, 1 |
| 64 | +; CHECK-NEXT: %3 = call fast fastcc double @julia___2797(double %0, i64 %2), !dbg !36 |
| 65 | +; CHECK-NEXT: %4 = sitofp i64 %1 to double |
| 66 | +; CHECK-NEXT: %5 = fmul fast double %differeturn, %3 |
| 67 | +; CHECK-NEXT: %6 = fmul fast double %5, %4 |
| 68 | +; CHECK-NEXT: %7 = insertvalue { double } undef, double %6, 0 |
| 69 | +; CHECK-NEXT: ret { double } %7 |
| 70 | +; CHECK-NEXT: } |
| 71 | + |
| 72 | +; Function Attrs: inaccessiblemem_or_argmemonly |
| 73 | +declare void @jl_gc_queue_root({} addrspace(10)*) #3 |
| 74 | + |
| 75 | +; Function Attrs: allocsize(1) |
| 76 | +declare noalias nonnull {} addrspace(10)* @jl_gc_pool_alloc(i8*, i32, i32) #4 |
| 77 | + |
| 78 | +; Function Attrs: allocsize(1) |
| 79 | +declare noalias nonnull {} addrspace(10)* @jl_gc_big_alloc(i8*, i64) #4 |
| 80 | + |
| 81 | +attributes #0 = { noinline nosync readnone "enzyme_math"="powi" "enzyme_shouldrecompute"="powi" "probe-stack"="inline-asm" } |
| 82 | +attributes #1 = { nofree nosync nounwind readnone speculatable willreturn } |
| 83 | +attributes #2 = { alwaysinline nosync readnone "probe-stack"="inline-asm" } |
| 84 | +attributes #3 = { inaccessiblemem_or_argmemonly } |
| 85 | +attributes #4 = { allocsize(1) } |
| 86 | +attributes #5 = { "probe-stack"="inline-asm" } |
| 87 | + |
| 88 | +!llvm.module.flags = !{!0, !1} |
| 89 | +!llvm.dbg.cu = !{!2, !5} |
| 90 | + |
| 91 | +!0 = !{i32 2, !"Dwarf Version", i32 4} |
| 92 | +!1 = !{i32 2, !"Debug Info Version", i32 3} |
| 93 | +!2 = distinct !DICompileUnit(language: DW_LANG_Julia, file: !3, producer: "julia", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !4, nameTableKind: None) |
| 94 | +!3 = !DIFile(filename: "math.jl", directory: ".") |
| 95 | +!4 = !{} |
| 96 | +!5 = distinct !DICompileUnit(language: DW_LANG_Julia, file: !6, producer: "julia", isOptimized: true, runtimeVersion: 0, emissionKind: LineTablesOnly, enums: !4, nameTableKind: None) |
| 97 | +!6 = !DIFile(filename: "REPL[3]", directory: ".") |
| 98 | +!7 = distinct !DISubprogram(name: "^", linkageName: "julia_^_2797", scope: null, file: !3, line: 922, type: !8, scopeLine: 922, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !4) |
| 99 | +!8 = !DISubroutineType(types: !4) |
| 100 | +!9 = !DILocation(line: 923, scope: !7) |
| 101 | +!10 = !DILocation(line: 408, scope: !11, inlinedAt: !13) |
| 102 | +!11 = distinct !DISubprogram(name: "/;", linkageName: "/", scope: !12, file: !12, type: !8, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !4) |
| 103 | +!12 = !DIFile(filename: "float.jl", directory: ".") |
| 104 | +!13 = !DILocation(line: 243, scope: !14, inlinedAt: !9) |
| 105 | +!14 = distinct !DISubprogram(name: "inv;", linkageName: "inv", scope: !15, file: !15, type: !8, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !4) |
| 106 | +!15 = !DIFile(filename: "number.jl", directory: ".") |
| 107 | +!16 = !DILocation(line: 924, scope: !7) |
| 108 | +!17 = !DILocation(line: 405, scope: !18, inlinedAt: !19) |
| 109 | +!18 = distinct !DISubprogram(name: "*;", linkageName: "*", scope: !12, file: !12, type: !8, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !4) |
| 110 | +!19 = !DILocation(line: 926, scope: !7) |
| 111 | +!20 = !DILocation(line: 405, scope: !18, inlinedAt: !21) |
| 112 | +!21 = !DILocation(line: 655, scope: !22, inlinedAt: !24) |
| 113 | +!22 = distinct !DISubprogram(name: "*;", linkageName: "*", scope: !23, file: !23, type: !8, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !4) |
| 114 | +!23 = !DIFile(filename: "operators.jl", directory: ".") |
| 115 | +!24 = !DILocation(line: 927, scope: !7) |
| 116 | +!25 = !DILocation(line: 146, scope: !26, inlinedAt: !27) |
| 117 | +!26 = distinct !DISubprogram(name: "Float64;", linkageName: "Float64", scope: !12, file: !12, type: !8, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !2, retainedNodes: !4) |
| 118 | +!27 = !DILocation(line: 928, scope: !7) |
| 119 | +!28 = distinct !DISubprogram(name: "f", linkageName: "julia_f_2794", scope: null, file: !6, line: 1, type: !8, scopeLine: 1, spFlags: DISPFlagDefinition | DISPFlagOptimized, unit: !5, retainedNodes: !4) |
| 120 | +!29 = !DILocation(line: 1, scope: !28, inlinedAt: !30) |
| 121 | +!30 = distinct !DILocation(line: 0, scope: !28) |
0 commit comments