File tree 2 files changed +16
-27
lines changed
2 files changed +16
-27
lines changed Original file line number Diff line number Diff line change 75
75
}
76
76
}
77
77
78
- // Use an equal-pointer optimization when types are `Eq`
79
- // We can't make `A` and `B` the same type because `min_specialization` won't
80
- // allow it.
81
- impl < A , B > SlicePartialEq < B > for [ A ]
82
- where
83
- A : MarkerEq < B > ,
84
- {
85
- default fn equal ( & self , other : & [ B ] ) -> bool {
86
- if self . len ( ) != other. len ( ) {
87
- return false ;
88
- }
89
-
90
- // While performance would suffer if `guaranteed_eq` just returned `false`
91
- // for all arguments, correctness and return value of this function are not affected.
92
- if self . as_ptr ( ) . guaranteed_eq ( other. as_ptr ( ) as * const A ) {
93
- return true ;
94
- }
95
-
96
- self . iter ( ) . zip ( other. iter ( ) ) . all ( |( x, y) | x == y)
97
- }
98
- }
99
-
100
78
// Use memcmp for bytewise equality when the types allow
101
79
impl < A , B > SlicePartialEq < B > for [ A ]
102
80
where
@@ -107,11 +85,6 @@ where
107
85
return false ;
108
86
}
109
87
110
- // While performance would suffer if `guaranteed_eq` just returned `false`
111
- // for all arguments, correctness and return value of this function are not affected.
112
- if self . as_ptr ( ) . guaranteed_eq ( other. as_ptr ( ) as * const A ) {
113
- return true ;
114
- }
115
88
// SAFETY: `self` and `other` are references and are thus guaranteed to be valid.
116
89
// The two slices have been checked to have the same size above.
117
90
unsafe {
Original file line number Diff line number Diff line change
1
+ // compile-flags: -C opt-level=3
2
+
3
+ #![ crate_type = "lib" ]
4
+
5
+ // #71602: check that slice equality just generates a single bcmp
6
+
7
+ // CHECK-LABEL: @is_zero_slice
8
+ #[ no_mangle]
9
+ pub fn is_zero_slice ( data : & [ u8 ; 4 ] ) -> bool {
10
+ // CHECK: start:
11
+ // CHECK-NEXT: %{{.+}} = getelementptr {{.+}}
12
+ // CHECK-NEXT: %[[BCMP:.+]] = tail call i32 @{{bcmp|memcmp}}({{.+}})
13
+ // CHECK-NEXT: %[[EQ:.+]] = icmp eq i32 %[[BCMP]], 0
14
+ // CHECK-NEXT: ret i1 %[[EQ]]
15
+ * data == [ 0 ; 4 ]
16
+ }
You can’t perform that action at this time.
0 commit comments