Skip to content

Commit d1f8325

Browse files
committed
ui test for f32 and f64
Signed-off-by: Karan Janthe <karanjanthe@gmail.com>
1 parent a6ebaad commit d1f8325

File tree

6 files changed

+107
-17
lines changed

6 files changed

+107
-17
lines changed

tests/codegen/autodiff/f32.rs renamed to tests/ui/autodiff/f32.rs

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,11 @@
1+
//@ run-pass
12
//@ compile-flags: -Zautodiff=Enable,PrintTAFn=callee -Zautodiff=NoPostopt -C opt-level=3 -Clto=fat -g
23
//@ no-prefer-dynamic
34
//@ needs-enzyme
45
#![feature(autodiff)]
56

67
use std::autodiff::autodiff_reverse;
78

8-
// CHECK-LABEL: callee
9-
// CHECK: callee - {[-1]:Float@float} |{[-1]:Pointer}:{}
10-
// CHECK: ptr %x: {[-1]:Pointer, [-1,0]:Float@float}
11-
// CHECK: start
12-
// CHECK: %_2 = load float, ptr %x, align 4, !noundef !3: {[-1]:Float@float}
13-
// CHECK: %_0 = fmul float %_2, %_2: {[-1]:Float@float}
14-
// CHECK: ret float %_0: {}
15-
169
#[autodiff_reverse(d_square, Duplicated, Active)]
1710
#[no_mangle]
1811
fn callee(x: &f32) -> f32 {

tests/ui/autodiff/f32.stderr

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
analyzing function callee
2+
+ knowndata: ptr %0 : {[-1]:Pointer} - {}
3+
+ retdata: {[-1]:Float@float}
4+
updating analysis of val: ptr %0 current: {} new {[-1]:Pointer} from ptr %0 Changed=1 legal=1
5+
updating analysis of val: ptr %0 current: {[-1]:Pointer} new {[-1]:Pointer} from ptr %0 Changed=0 legal=1
6+
updating analysis of val: %3 = fmul float %2, %2, !dbg !355 current: {} new {[-1]:Float@float} from %3 = fmul float %2, %2, !dbg !355 Changed=1 legal=1
7+
updating analysis of val: %3 = fmul float %2, %2, !dbg !355 current: {[-1]:Float@float} new {[-1]:Float@float} from %3 = fmul float %2, %2, !dbg !355 Changed=0 legal=1
8+
updating analysis of val: ptr %0 current: {[-1]:Pointer} new {[-1]:Pointer} from %2 = load float, ptr %0, align 4, !dbg !355, !noundef !14 Changed=0 legal=1
9+
updating analysis of val: %2 = load float, ptr %0, align 4, !dbg !355, !noundef !14 current: {} new {} from %2 = load float, ptr %0, align 4, !dbg !355, !noundef !14 Changed=0 legal=1
10+
updating analysis of val: %2 = load float, ptr %0, align 4, !dbg !355, !noundef !14 current: {} new {[-1]:Float@float} from %3 = fmul float %2, %2, !dbg !355 Changed=1 legal=1
11+
updating analysis of val: %2 = load float, ptr %0, align 4, !dbg !355, !noundef !14 current: {[-1]:Float@float} new {[-1]:Float@float} from %3 = fmul float %2, %2, !dbg !355 Changed=0 legal=1
12+
updating analysis of val: %3 = fmul float %2, %2, !dbg !355 current: {[-1]:Float@float} new {[-1]:Float@float} from %3 = fmul float %2, %2, !dbg !355 Changed=0 legal=1
13+
updating analysis of val: ptr %0 current: {[-1]:Pointer} new {[-1]:Pointer, [-1,0]:Float@float} from %2 = load float, ptr %0, align 4, !dbg !355, !noundef !14 Changed=1 legal=1
14+
updating analysis of val: %2 = load float, ptr %0, align 4, !dbg !355, !noundef !14 current: {[-1]:Float@float} new {[-1]:Float@float} from %2 = load float, ptr %0, align 4, !dbg !355, !noundef !14 Changed=0 legal=1
15+
analyzing function preprocess_callee
16+
+ knowndata: ptr %0 : {[-1]:Pointer, [-1,0]:Float@float} - {}
17+
+ retdata: {[-1]:Float@float}
18+
updating analysis of val: ptr %0 current: {} new {[-1]:Pointer, [-1,0]:Float@float} from ptr %0 Changed=1 legal=1
19+
updating analysis of val: ptr %0 current: {[-1]:Pointer, [-1,0]:Float@float} new {[-1]:Pointer, [-1,0]:Float@float} from ptr %0 Changed=0 legal=1
20+
updating analysis of val: %3 = fmul float %2, %2, !dbg !17194 current: {} new {[-1]:Float@float} from %3 = fmul float %2, %2, !dbg !17194 Changed=1 legal=1
21+
updating analysis of val: %3 = fmul float %2, %2, !dbg !17194 current: {[-1]:Float@float} new {[-1]:Float@float} from %3 = fmul float %2, %2, !dbg !17194 Changed=0 legal=1
22+
updating analysis of val: ptr %0 current: {[-1]:Pointer, [-1,0]:Float@float} new {[-1]:Pointer} from %2 = load float, ptr %0, align 4, !dbg !17194, !noundef !14 Changed=0 legal=1
23+
updating analysis of val: %2 = load float, ptr %0, align 4, !dbg !17194, !noundef !14 current: {} new {[-1]:Float@float} from %2 = load float, ptr %0, align 4, !dbg !17194, !noundef !14 Changed=1 legal=1
24+
updating analysis of val: %2 = load float, ptr %0, align 4, !dbg !17194, !noundef !14 current: {[-1]:Float@float} new {[-1]:Float@float} from %3 = fmul float %2, %2, !dbg !17194 Changed=0 legal=1
25+
updating analysis of val: %2 = load float, ptr %0, align 4, !dbg !17194, !noundef !14 current: {[-1]:Float@float} new {[-1]:Float@float} from %3 = fmul float %2, %2, !dbg !17194 Changed=0 legal=1
26+
updating analysis of val: %3 = fmul float %2, %2, !dbg !17194 current: {[-1]:Float@float} new {[-1]:Float@float} from %3 = fmul float %2, %2, !dbg !17194 Changed=0 legal=1
27+
analyzing function callee
28+
+ knowndata: ptr %0 : {[-1]:Pointer} - {}
29+
+ retdata: {[-1]:Float@float}
30+
updating analysis of val: ptr %0 current: {} new {[-1]:Pointer} from ptr %0 Changed=1 legal=1
31+
updating analysis of val: ptr %0 current: {[-1]:Pointer} new {[-1]:Pointer} from ptr %0 Changed=0 legal=1
32+
updating analysis of val: %3 = fmul float %2, %2, !dbg !355 current: {} new {[-1]:Float@float} from %3 = fmul float %2, %2, !dbg !355 Changed=1 legal=1
33+
updating analysis of val: %3 = fmul float %2, %2, !dbg !355 current: {[-1]:Float@float} new {[-1]:Float@float} from %3 = fmul float %2, %2, !dbg !355 Changed=0 legal=1
34+
updating analysis of val: ptr %0 current: {[-1]:Pointer} new {[-1]:Pointer} from %2 = load float, ptr %0, align 4, !dbg !355, !noundef !14 Changed=0 legal=1
35+
updating analysis of val: %2 = load float, ptr %0, align 4, !dbg !355, !noundef !14 current: {} new {} from %2 = load float, ptr %0, align 4, !dbg !355, !noundef !14 Changed=0 legal=1
36+
updating analysis of val: %2 = load float, ptr %0, align 4, !dbg !355, !noundef !14 current: {} new {[-1]:Float@float} from %3 = fmul float %2, %2, !dbg !355 Changed=1 legal=1
37+
updating analysis of val: %2 = load float, ptr %0, align 4, !dbg !355, !noundef !14 current: {[-1]:Float@float} new {[-1]:Float@float} from %3 = fmul float %2, %2, !dbg !355 Changed=0 legal=1
38+
updating analysis of val: %3 = fmul float %2, %2, !dbg !355 current: {[-1]:Float@float} new {[-1]:Float@float} from %3 = fmul float %2, %2, !dbg !355 Changed=0 legal=1
39+
updating analysis of val: ptr %0 current: {[-1]:Pointer} new {[-1]:Pointer, [-1,0]:Float@float} from %2 = load float, ptr %0, align 4, !dbg !355, !noundef !14 Changed=1 legal=1
40+
updating analysis of val: %2 = load float, ptr %0, align 4, !dbg !355, !noundef !14 current: {[-1]:Float@float} new {[-1]:Float@float} from %2 = load float, ptr %0, align 4, !dbg !355, !noundef !14 Changed=0 legal=1

tests/ui/autodiff/f32.stdout

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
callee - {[-1]:Float@float} |{[-1]:Pointer}:{}
2+
ptr %0: {[-1]:Pointer, [-1,0]:Float@float}
3+
4+
%2 = load float, ptr %0, align 4, !dbg !61, !noundef !14: {[-1]:Float@float}
5+
%3 = fmul float %2, %2, !dbg !61: {[-1]:Float@float}
6+
ret float %3, !dbg !62: {}
7+
callee - {[-1]:Float@float} |{[-1]:Pointer, [-1,0]:Float@float}:{}
8+
ptr %0: {[-1]:Pointer, [-1,0]:Float@float}
9+
10+
%2 = load float, ptr %0, align 4, !dbg !61, !noundef !14: {[-1]:Float@float}
11+
%3 = fmul float %2, %2, !dbg !61: {[-1]:Float@float}
12+
ret float %3, !dbg !62: {}

tests/codegen/autodiff/f64.rs renamed to tests/ui/autodiff/f64.rs

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
1-
//@ compile-flags: -Zautodiff=Enable,PrintTAFn=square -C opt-level=3 -Clto=fat
1+
//@ run-pass
2+
//@ compile-flags: -Zautodiff=Enable,PrintTAFn=square -Zautodiff=NoPostopt -C opt-level=3 -Clto=fat -g
23
//@ no-prefer-dynamic
34
//@ needs-enzyme
45
#![feature(autodiff)]
56
use std::autodiff::autodiff_reverse;
67

7-
// CHECK-LABEL: square
8-
// CHECK: square - {[-1]:Float@double} |{[-1]:Pointer}:{}
9-
// CHECK: ptr %x: {[-1]:Pointer, [-1,0]:Float@double}
10-
// CHECK: start
11-
// CHECK: %_2 = load double, ptr %x, align 8, !noundef !3: {[-1]:Float@double}
12-
// CHECK: %_0 = fmul double %_2, %_2: {[-1]:Float@double}
13-
// CHECK: ret double %_0: {}
14-
158
#[autodiff_reverse(d_square, Duplicated, Active)]
169
#[no_mangle]
1710
fn square(x: &f64) -> f64 {

tests/ui/autodiff/f64.stderr

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
analyzing function square
2+
+ knowndata: ptr %0 : {[-1]:Pointer} - {}
3+
+ retdata: {[-1]:Float@double}
4+
updating analysis of val: ptr %0 current: {} new {[-1]:Pointer} from ptr %0 Changed=1 legal=1
5+
updating analysis of val: ptr %0 current: {[-1]:Pointer} new {[-1]:Pointer} from ptr %0 Changed=0 legal=1
6+
updating analysis of val: %3 = fmul double %2, %2, !dbg !385 current: {} new {[-1]:Float@double} from %3 = fmul double %2, %2, !dbg !385 Changed=1 legal=1
7+
updating analysis of val: %3 = fmul double %2, %2, !dbg !385 current: {[-1]:Float@double} new {[-1]:Float@double} from %3 = fmul double %2, %2, !dbg !385 Changed=0 legal=1
8+
updating analysis of val: ptr %0 current: {[-1]:Pointer} new {[-1]:Pointer} from %2 = load double, ptr %0, align 8, !dbg !384, !noundef !14 Changed=0 legal=1
9+
updating analysis of val: %2 = load double, ptr %0, align 8, !dbg !384, !noundef !14 current: {} new {} from %2 = load double, ptr %0, align 8, !dbg !384, !noundef !14 Changed=0 legal=1
10+
updating analysis of val: %2 = load double, ptr %0, align 8, !dbg !384, !noundef !14 current: {} new {[-1]:Float@double} from %3 = fmul double %2, %2, !dbg !385 Changed=1 legal=1
11+
updating analysis of val: %2 = load double, ptr %0, align 8, !dbg !384, !noundef !14 current: {[-1]:Float@double} new {[-1]:Float@double} from %3 = fmul double %2, %2, !dbg !385 Changed=0 legal=1
12+
updating analysis of val: %3 = fmul double %2, %2, !dbg !385 current: {[-1]:Float@double} new {[-1]:Float@double} from %3 = fmul double %2, %2, !dbg !385 Changed=0 legal=1
13+
updating analysis of val: ptr %0 current: {[-1]:Pointer} new {[-1]:Pointer, [-1,0]:Float@double} from %2 = load double, ptr %0, align 8, !dbg !384, !noundef !14 Changed=1 legal=1
14+
updating analysis of val: %2 = load double, ptr %0, align 8, !dbg !384, !noundef !14 current: {[-1]:Float@double} new {[-1]:Float@double} from %2 = load double, ptr %0, align 8, !dbg !384, !noundef !14 Changed=0 legal=1
15+
analyzing function preprocess_square
16+
+ knowndata: ptr %0 : {[-1]:Pointer, [-1,0]:Float@double} - {}
17+
+ retdata: {[-1]:Float@double}
18+
updating analysis of val: ptr %0 current: {} new {[-1]:Pointer, [-1,0]:Float@double} from ptr %0 Changed=1 legal=1
19+
updating analysis of val: ptr %0 current: {[-1]:Pointer, [-1,0]:Float@double} new {[-1]:Pointer, [-1,0]:Float@double} from ptr %0 Changed=0 legal=1
20+
updating analysis of val: %3 = fmul double %2, %2, !dbg !17231 current: {} new {[-1]:Float@double} from %3 = fmul double %2, %2, !dbg !17231 Changed=1 legal=1
21+
updating analysis of val: %3 = fmul double %2, %2, !dbg !17231 current: {[-1]:Float@double} new {[-1]:Float@double} from %3 = fmul double %2, %2, !dbg !17231 Changed=0 legal=1
22+
updating analysis of val: ptr %0 current: {[-1]:Pointer, [-1,0]:Float@double} new {[-1]:Pointer} from %2 = load double, ptr %0, align 8, !dbg !17230, !noundef !14 Changed=0 legal=1
23+
updating analysis of val: %2 = load double, ptr %0, align 8, !dbg !17230, !noundef !14 current: {} new {[-1]:Float@double} from %2 = load double, ptr %0, align 8, !dbg !17230, !noundef !14 Changed=1 legal=1
24+
updating analysis of val: %2 = load double, ptr %0, align 8, !dbg !17230, !noundef !14 current: {[-1]:Float@double} new {[-1]:Float@double} from %3 = fmul double %2, %2, !dbg !17231 Changed=0 legal=1
25+
updating analysis of val: %2 = load double, ptr %0, align 8, !dbg !17230, !noundef !14 current: {[-1]:Float@double} new {[-1]:Float@double} from %3 = fmul double %2, %2, !dbg !17231 Changed=0 legal=1
26+
updating analysis of val: %3 = fmul double %2, %2, !dbg !17231 current: {[-1]:Float@double} new {[-1]:Float@double} from %3 = fmul double %2, %2, !dbg !17231 Changed=0 legal=1
27+
analyzing function square
28+
+ knowndata: ptr %0 : {[-1]:Pointer} - {}
29+
+ retdata: {[-1]:Float@double}
30+
updating analysis of val: ptr %0 current: {} new {[-1]:Pointer} from ptr %0 Changed=1 legal=1
31+
updating analysis of val: ptr %0 current: {[-1]:Pointer} new {[-1]:Pointer} from ptr %0 Changed=0 legal=1
32+
updating analysis of val: %3 = fmul double %2, %2, !dbg !385 current: {} new {[-1]:Float@double} from %3 = fmul double %2, %2, !dbg !385 Changed=1 legal=1
33+
updating analysis of val: %3 = fmul double %2, %2, !dbg !385 current: {[-1]:Float@double} new {[-1]:Float@double} from %3 = fmul double %2, %2, !dbg !385 Changed=0 legal=1
34+
updating analysis of val: ptr %0 current: {[-1]:Pointer} new {[-1]:Pointer} from %2 = load double, ptr %0, align 8, !dbg !384, !noundef !14 Changed=0 legal=1
35+
updating analysis of val: %2 = load double, ptr %0, align 8, !dbg !384, !noundef !14 current: {} new {} from %2 = load double, ptr %0, align 8, !dbg !384, !noundef !14 Changed=0 legal=1
36+
updating analysis of val: %2 = load double, ptr %0, align 8, !dbg !384, !noundef !14 current: {} new {[-1]:Float@double} from %3 = fmul double %2, %2, !dbg !385 Changed=1 legal=1
37+
updating analysis of val: %2 = load double, ptr %0, align 8, !dbg !384, !noundef !14 current: {[-1]:Float@double} new {[-1]:Float@double} from %3 = fmul double %2, %2, !dbg !385 Changed=0 legal=1
38+
updating analysis of val: %3 = fmul double %2, %2, !dbg !385 current: {[-1]:Float@double} new {[-1]:Float@double} from %3 = fmul double %2, %2, !dbg !385 Changed=0 legal=1
39+
updating analysis of val: ptr %0 current: {[-1]:Pointer} new {[-1]:Pointer, [-1,0]:Float@double} from %2 = load double, ptr %0, align 8, !dbg !384, !noundef !14 Changed=1 legal=1
40+
updating analysis of val: %2 = load double, ptr %0, align 8, !dbg !384, !noundef !14 current: {[-1]:Float@double} new {[-1]:Float@double} from %2 = load double, ptr %0, align 8, !dbg !384, !noundef !14 Changed=0 legal=1

tests/ui/autodiff/f64.stdout

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
square - {[-1]:Float@double} |{[-1]:Pointer}:{}
2+
ptr %0: {[-1]:Pointer, [-1,0]:Float@double}
3+
4+
%2 = load double, ptr %0, align 8, !dbg !103, !noundef !14: {[-1]:Float@double}
5+
%3 = fmul double %2, %2, !dbg !104: {[-1]:Float@double}
6+
ret double %3, !dbg !111: {}
7+
square - {[-1]:Float@double} |{[-1]:Pointer, [-1,0]:Float@double}:{}
8+
ptr %0: {[-1]:Pointer, [-1,0]:Float@double}
9+
10+
%2 = load double, ptr %0, align 8, !dbg !103, !noundef !14: {[-1]:Float@double}
11+
%3 = fmul double %2, %2, !dbg !104: {[-1]:Float@double}
12+
ret double %3, !dbg !111: {}

0 commit comments

Comments
 (0)