File tree 1 file changed +33
-0
lines changed
1 file changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ //@ compile-flags: -O -Z merge-functions=disabled
2
+ #![ crate_type = "lib" ]
3
+
4
+ // This tests that LLVM can optimize based on the niches in the source or
5
+ // destination types for casts.
6
+
7
+ // CHECK-LABEL: @u32_index
8
+ #[ no_mangle]
9
+ pub fn u32_index ( c : u32 ) -> [ bool ; 10 ] {
10
+ let mut array = [ false ; 10 ] ;
11
+
12
+ let index = ( c | 1 ) . leading_zeros ( ) as usize / 4 - 2 ;
13
+
14
+ // CHECK: call core::panicking::panic
15
+ array[ index as usize ] = true ;
16
+
17
+ array
18
+ }
19
+
20
+ // CHECK-LABEL: @char_as_u32_index
21
+ #[ no_mangle]
22
+ pub fn char_as_u32_index ( c : char ) -> [ bool ; 10 ] {
23
+ let c = c as u32 ;
24
+
25
+ let mut array = [ false ; 10 ] ;
26
+
27
+ let index = ( c | 1 ) . leading_zeros ( ) as usize / 4 - 2 ;
28
+
29
+ // CHECK-NOT: call core::panicking::panic
30
+ array[ index as usize ] = true ;
31
+
32
+ array
33
+ }
You can’t perform that action at this time.
0 commit comments