Skip to content

Commit

Permalink
Change bitwise operator to more easily keep data in vector registers
Browse files Browse the repository at this point in the history
  • Loading branch information
Mark-Simulacrum committed May 4, 2021
1 parent a5f164f commit 9d4c094
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions compiler/rustc_index/src/bit_set.rs
Expand Up @@ -355,14 +355,18 @@ where
Op: Fn(Word, Word) -> Word,
{
assert_eq!(out_vec.len(), in_vec.len());
let mut changed = false;
let mut changed = 0;
for (out_elem, in_elem) in iter::zip(out_vec, in_vec) {
let old_val = *out_elem;
let new_val = op(old_val, *in_elem);
*out_elem = new_val;
changed |= old_val != new_val;
// This is essentially equivalent to a != with changed being a bool, but
// in practice this code gets auto-vectorized by the compiler for most
// operators. Using != here causes us to generate quite poor code as the
// compiler tries to go back to a boolean on each loop iteration.
changed |= old_val ^ new_val;
}
changed
changed != 0
}

const SPARSE_MAX: usize = 8;
Expand Down

0 comments on commit 9d4c094

Please sign in to comment.