Skip to content

Commit 45ccf91

Browse files
committed
Auto merge of #84915 - Mark-Simulacrum:bitset-xor-eq, r=jackh726
Retain data in vectorized registers for longer This seems to be a mild performance improvement on the keccak crate at least, though not sure it'll show up more broadly.
2 parents ae8b84b + 9d4c094 commit 45ccf91

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

compiler/rustc_index/src/bit_set.rs

+7-3
Original file line numberDiff line numberDiff 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

368372
const SPARSE_MAX: usize = 8;

0 commit comments

Comments
 (0)