File tree 1 file changed +7
-3
lines changed
1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -355,14 +355,18 @@ where
355
355
Op : Fn ( Word , Word ) -> Word ,
356
356
{
357
357
assert_eq ! ( out_vec. len( ) , in_vec. len( ) ) ;
358
- let mut changed = false ;
358
+ let mut changed = 0 ;
359
359
for ( out_elem, in_elem) in iter:: zip ( out_vec, in_vec) {
360
360
let old_val = * out_elem;
361
361
let new_val = op ( old_val, * in_elem) ;
362
362
* out_elem = new_val;
363
- changed |= old_val != new_val;
363
+ // This is essentially equivalent to a != with changed being a bool, but
364
+ // in practice this code gets auto-vectorized by the compiler for most
365
+ // operators. Using != here causes us to generate quite poor code as the
366
+ // compiler tries to go back to a boolean on each loop iteration.
367
+ changed |= old_val ^ new_val;
364
368
}
365
- changed
369
+ changed != 0
366
370
}
367
371
368
372
const SPARSE_MAX : usize = 8 ;
You can’t perform that action at this time.
0 commit comments