File tree Expand file tree Collapse file tree 2 files changed +33
-1
lines changed
tests/compiletests/ui/lang/core/intrinsics Expand file tree Collapse file tree 2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change 11// Test black_box intrinsic
22// build-pass
3+ // compile-flags: -C llvm-args=--disassemble-fn=black_box::disassemble
34
45#![ allow( internal_features) ]
56#![ feature( core_intrinsics) ]
@@ -9,7 +10,14 @@ use core::hint::black_box;
910use spirv_std:: spirv;
1011
1112#[ spirv( compute( threads( 1 ) ) ) ]
12- pub fn main ( ) {
13+ pub fn main ( #[ spirv( descriptor_set = 0 , binding = 0 , storage_buffer) ] out : & mut [ u32 ] ) {
14+ let result = disassemble ( ) ;
15+ for i in 0 ..result. len ( ) {
16+ out[ i] = result[ i] ;
17+ }
18+ }
19+
20+ pub fn disassemble ( ) -> [ u32 ; 8 ] {
1321 // Test with various types
1422 let x = 42i32 ;
1523 let y = black_box ( x) ;
@@ -26,4 +34,15 @@ pub fn main() {
2634 // Test with references
2735 let data = 100u32 ;
2836 let ref_data = black_box ( & data) ;
37+
38+ [
39+ y as u32 ,
40+ f32:: to_bits ( b) ,
41+ w[ 0 ] ,
42+ w[ 1 ] ,
43+ w[ 2 ] ,
44+ w[ 3 ] ,
45+ result,
46+ * ref_data,
47+ ]
2948}
Original file line number Diff line number Diff line change 11warning: black_box intrinsic does not prevent optimization in Rust GPU
22
3+ %1 = OpFunction %2 None %3
4+ %4 = OpLabel
5+ OpLine %5 34 17
6+ %6 = OpIAdd %7 %8 %9
7+ OpLine %5 40 5
8+ %10 = OpBitcast %7 %11
9+ OpLine %12 1092 17
10+ %13 = OpBitcast %7 %14
11+ OpLine %5 40 4
12+ %15 = OpCompositeConstruct %2 %10 %13 %16 %17 %18 %19 %6 %20
13+ OpNoLine
14+ OpReturnValue %15
15+ OpFunctionEnd
316warning: 1 warning emitted
417
You can’t perform that action at this time.
0 commit comments