diff options
| author | Mark Rousskov <mark.simulacrum@gmail.com> | 2021-05-04 11:53:57 -0400 |
|---|---|---|
| committer | Mark Rousskov <mark.simulacrum@gmail.com> | 2021-05-04 11:55:18 -0400 |
| commit | 9d4c0944cba409a023f640b3c5e28875bce8fbd9 (patch) | |
| tree | 2bb7032b82472faacbb02d3e921eca6d1912579a | |
| parent | a5f164faad4a2fed606b8160fd7ecd2d5cbba381 (diff) | |
| download | rust-9d4c0944cba409a023f640b3c5e28875bce8fbd9.tar.gz rust-9d4c0944cba409a023f640b3c5e28875bce8fbd9.zip | |
Change bitwise operator to more easily keep data in vector registers
| -rw-r--r-- | compiler/rustc_index/src/bit_set.rs | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/compiler/rustc_index/src/bit_set.rs b/compiler/rustc_index/src/bit_set.rs index d26ab1939e3..df777502c44 100644 --- a/compiler/rustc_index/src/bit_set.rs +++ b/compiler/rustc_index/src/bit_set.rs @@ -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; |
