File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -355,14 +355,18 @@ where
355355 Op : Fn ( Word , Word ) -> Word ,
356356{
357357 assert_eq ! ( out_vec. len( ) , in_vec. len( ) ) ;
358- let mut changed = false ;
358+ let mut changed = 0 ;
359359 for ( out_elem, in_elem) in iter:: zip ( out_vec, in_vec) {
360360 let old_val = * out_elem;
361361 let new_val = op ( old_val, * in_elem) ;
362362 * 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;
364368 }
365- changed
369+ changed != 0
366370}
367371
368372const SPARSE_MAX : usize = 8 ;
You can’t perform that action at this time.
0 commit comments