1 // compile-flags: -C opt-level=3
5 // #71602 reported a simple array comparison just generating a loop.
6 // This was originally fixed by ensuring it generates a single bcmp,
7 // but we now generate it as a load instead. `is_zero_slice` was
8 // tweaked to still test the case of comparison against a slice,
9 // and `is_zero_array` tests the new array-specific behaviour.
11 // CHECK-LABEL: @is_zero_slice
13 pub fn is_zero_slice(data: &[u8; 4]) -> bool {
15 // CHECK-NEXT: %{{.+}} = getelementptr {{.+}}
16 // CHECK-NEXT: %[[BCMP:.+]] = tail call i32 @{{bcmp|memcmp}}({{.+}})
17 // CHECK-NEXT: %[[EQ:.+]] = icmp eq i32 %[[BCMP]], 0
18 // CHECK-NEXT: ret i1 %[[EQ]]
22 // CHECK-LABEL: @is_zero_array
24 pub fn is_zero_array(data: &[u8; 4]) -> bool {
26 // CHECK-NEXT: %[[PTR:.+]] = bitcast [4 x i8]* {{.+}} to i32*
27 // CHECK-NEXT: %[[LOAD:.+]] = load i32, i32* %[[PTR]], align 1
28 // CHECK-NEXT: %[[EQ:.+]] = icmp eq i32 %[[LOAD]], 0
29 // CHECK-NEXT: ret i1 %[[EQ]]