1
- ; RUN: if [ %llvmver -ge 13 ]; then %opt < %s %loadEnzyme -enzyme -enzyme-preopt=false -mem2reg -instsimplify -simplifycfg -S | FileCheck %s; fi
1
+ ; RUN: %opt < %s %loadEnzyme -enzyme -enzyme-preopt=false -mem2reg -instsimplify -simplifycfg -S | FileCheck %s
2
+
2
3
source_filename = "text"
3
4
target datalayout = "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-f80:128-n8:16:32:64-S128"
4
5
target triple = "x86_64-pc-linux-gnu"
5
6
6
- define private fastcc double @julia___2797 (double %0 , i64 signext %1 ) unnamed_addr #0 !dbg !7 {
7
+ define private fastcc double @julia___2797 (double %x0 , i64 signext %x1 ) unnamed_addr #0 {
7
8
top:
8
- switch i64 %1 , label %L20 [
9
+ switch i64 %x1 , label %L20 [
9
10
i64 -1 , label %L3
10
11
i64 0 , label %L7
11
12
i64 1 , label %L7.fold.split
12
13
i64 2 , label %L13
13
14
i64 3 , label %L17
14
- ], !dbg !9
15
+ ]
15
16
16
17
L3: ; preds = %top
17
- %2 = fdiv double 1 .000000e+00 , %0 , !dbg !10
18
- ret double %2 , !dbg !9
18
+ %x2 = fdiv double 1 .000000e+00 , %x0
19
+ ret double %x2
19
20
20
21
L7.fold.split: ; preds = %top
21
- br label %L7 , !dbg !16
22
+ br label %L7
22
23
23
24
L7: ; preds = %top, %L7.fold.split
24
- %merge = phi double [ 1 .000000e+00 , %top ], [ %0 , %L7.fold.split ]
25
- ret double %merge , !dbg !16
25
+ %merge = phi double [ 1 .000000e+00 , %top ], [ %x0 , %L7.fold.split ]
26
+ ret double %merge
26
27
27
28
L13: ; preds = %top
28
- %3 = fmul double %0 , %0 , !dbg !17
29
- ret double %3 , !dbg !19
29
+ %x3 = fmul double %x0 , %x0
30
+ ret double %x3
30
31
31
32
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
33
+ %x4 = fmul double %x0 , %x0
34
+ %x5 = fmul double %x4 , %x0
35
+ ret double %x5
35
36
36
37
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
38
+ %x6 = sitofp i64 %x1 to double
39
+ %x7 = call double @llvm.pow.f64 (double %x0 , double %x6 )
40
+ ret double %x7
40
41
}
41
42
42
43
; Function Attrs: nofree nosync nounwind readnone speculatable willreturn
@@ -46,10 +47,10 @@ declare double @llvm.pow.f64(double, double) #1
46
47
declare double @__enzyme_autodiff (double (double , i64 )*, ...)
47
48
48
49
; Function Attrs: alwaysinline nosync readnone
49
- define double @julia_f_2794 (double %0 , i64 signext %1 ) local_unnamed_addr # 2 !dbg !28 {
50
+ define double @julia_f_2794 (double %y0 , i64 signext %y1 ) {
50
51
entry:
51
- %2 = call fastcc double @julia___2797 (double %0 , i64 signext %1 ) #5 , !dbg !29
52
- ret double %2
52
+ %y2 = call fastcc double @julia___2797 (double %y0 , i64 signext %y1 ) #5
53
+ ret double %y2
53
54
}
54
55
55
56
define double @test_derivative (double %x , i64 %y ) {
@@ -58,13 +59,15 @@ entry:
58
59
ret double %0
59
60
}
60
61
61
- ; CHECK: define internal { double } @diffejulia_f_2794(double %0 , i64 signext %1 , double %differeturn) local_unnamed_addr #5 !dbg !35 {
62
+ ; CHECK: define internal { double } @diffejulia_f_2794(double %y0 , i64 signext %y1 , double %differeturn)
62
63
; 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
64
+ ; CHECK-NEXT: %0 = sub i64 %y1, 1
65
+ ; CHECK-NEXT: %1 = call fast fastcc double @julia___2797(double %y0, i64 %0)
66
+ ; CHECK-NEXT: %2 = sitofp i64 %y1 to double
67
+ ; CHECK-NEXT: %3 = fmul fast double %differeturn, %1
68
+ ; CHECK-NEXT: %4 = fmul fast double %3, %2
69
+ ; CHECK-NEXT: %5 = icmp eq i64 0, %y1
70
+ ; CHECK-NEXT: %6 = select {{(fast )?}}i1 %5, double 0.000000e+00, double %4
68
71
; CHECK-NEXT: %7 = insertvalue { double } undef, double %6, 0
69
72
; CHECK-NEXT: ret { double } %7
70
73
; CHECK-NEXT: }
@@ -78,44 +81,10 @@ declare noalias nonnull {} addrspace(10)* @jl_gc_pool_alloc(i8*, i32, i32) #4
78
81
; Function Attrs: allocsize(1)
79
82
declare noalias nonnull {} addrspace (10 )* @jl_gc_big_alloc (i8* , i64 ) #4
80
83
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 #0 = { noinline readnone "enzyme_math" ="powi" "enzyme_shouldrecompute" ="powi" }
85
+ attributes #1 = { nounwind readnone speculatable }
86
+ attributes #2 = { alwaysinline readnone "probe-stack" ="inline-asm" }
84
87
attributes #3 = { inaccessiblemem_or_argmemonly }
85
88
attributes #4 = { allocsize(1 ) }
86
89
attributes #5 = { "probe-stack" ="inline-asm" }
87
90
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