Skip to content

Commit 447c75a

Browse files
committed
Feature intrinsics in cg tests
1 parent 10a7c45 commit 447c75a

File tree

5 files changed

+18
-14
lines changed

5 files changed

+18
-14
lines changed

tests/codegen/autodiff/batched.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
// reduce this test to only match the first lines and the ret instructions.
1111

1212
#![feature(autodiff)]
13+
#![feature(intrinsics)]
1314

1415
use std::autodiff::autodiff_forward;
1516

tests/codegen/autodiff/generic.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
//@ no-prefer-dynamic
33
//@ needs-enzyme
44
#![feature(autodiff)]
5+
#![feature(intrinsics)]
56

67
use std::autodiff::autodiff_reverse;
78

tests/codegen/autodiff/identical_fnc.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
// We also explicetly test that we keep running merge_function after AD, by checking for two
1111
// identical function calls in the LLVM-IR, while having two different calls in the Rust code.
1212
#![feature(autodiff)]
13+
#![feature(intrinsics)]
1314

1415
use std::autodiff::autodiff_reverse;
1516

tests/codegen/autodiff/inline.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
//@ needs-enzyme
44

55
#![feature(autodiff)]
6+
#![feature(intrinsics)]
67

78
use std::autodiff::autodiff_reverse;
89

tests/codegen/autodiff/sret.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
// We therefore use this test to verify some of our sret handling.
99

1010
#![feature(autodiff)]
11+
#![feature(intrinsics)]
1112

1213
use std::autodiff::autodiff_reverse;
1314

@@ -17,26 +18,25 @@ fn primal(x: f32, y: f32) -> f64 {
1718
(x * x * y) as f64
1819
}
1920

20-
// CHECK:define internal fastcc void @_ZN4sret2df17h93be4316dd8ea006E(ptr dead_on_unwind noalias nocapture noundef nonnull writable writeonly align 8 dereferenceable(16) initializes((0, 16)) %_0, float noundef %x, float noundef %y)
21-
// CHECK-NEXT:start:
22-
// CHECK-NEXT: %0 = tail call fastcc { double, float, float } @diffeprimal(float %x, float %y)
23-
// CHECK-NEXT: %.elt = extractvalue { double, float, float } %0, 0
24-
// CHECK-NEXT: store double %.elt, ptr %_0, align 8
25-
// CHECK-NEXT: %_0.repack1 = getelementptr inbounds nuw i8, ptr %_0, i64 8
26-
// CHECK-NEXT: %.elt2 = extractvalue { double, float, float } %0, 1
27-
// CHECK-NEXT: store float %.elt2, ptr %_0.repack1, align 8
28-
// CHECK-NEXT: %_0.repack3 = getelementptr inbounds nuw i8, ptr %_0, i64 12
29-
// CHECK-NEXT: %.elt4 = extractvalue { double, float, float } %0, 2
30-
// CHECK-NEXT: store float %.elt4, ptr %_0.repack3, align 4
31-
// CHECK-NEXT: ret void
32-
// CHECK-NEXT:}
21+
// CHECK: define internal fastcc { double, float, float } @diffeprimal(float noundef %x, float noundef %y)
22+
// CHECK-NEXT: invertstart:
23+
// CHECK-NEXT: %_4 = fmul float %x, %x
24+
// CHECK-NEXT: %_3 = fmul float %_4, %y
25+
// CHECK-NEXT: %_0 = fpext float %_3 to double
26+
// CHECK-NEXT: %0 = fadd fast float %y, %y
27+
// CHECK-NEXT: %1 = fmul fast float %0, %x
28+
// CHECK-NEXT: %2 = insertvalue { double, float, float } undef, double %_0, 0
29+
// CHECK-NEXT: %3 = insertvalue { double, float, float } %2, float %1, 1
30+
// CHECK-NEXT: %4 = insertvalue { double, float, float } %3, float %_4, 2
31+
// CHECK-NEXT: ret { double, float, float } %4
32+
// CHECK-NEXT: }
3333

3434
fn main() {
3535
let x = std::hint::black_box(3.0);
3636
let y = std::hint::black_box(2.5);
3737
let scalar = std::hint::black_box(1.0);
3838
let (r1, r2, r3) = df(x, y, scalar);
39-
// 3*3*1.5 = 22.5
39+
// 3*3*2.5 = 22.5
4040
assert_eq!(r1, 22.5);
4141
// 2*x*y = 2*3*2.5 = 15.0
4242
assert_eq!(r2, 15.0);

0 commit comments

Comments
 (0)