Skip to content

[ADT] Simplify SparseBitVectorElement::unionWith and friends. NFC. #143775

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jayfoad
Copy link
Contributor

@jayfoad jayfoad commented Jun 11, 2025

No description provided.

@llvmbot
Copy link
Member

llvmbot commented Jun 11, 2025

@llvm/pr-subscribers-llvm-adt

Author: Jay Foad (jayfoad)

Changes

Full diff: https://github.com/llvm/llvm-project/pull/143775.diff

1 Files Affected:

  • (modified) llvm/include/llvm/ADT/SparseBitVector.h (+6-6)
diff --git a/llvm/include/llvm/ADT/SparseBitVector.h b/llvm/include/llvm/ADT/SparseBitVector.h
index 7151af6146e6e..1e6f8b22ca997 100644
--- a/llvm/include/llvm/ADT/SparseBitVector.h
+++ b/llvm/include/llvm/ADT/SparseBitVector.h
@@ -172,10 +172,10 @@ template <unsigned ElementSize = 128> struct SparseBitVectorElement {
   bool unionWith(const SparseBitVectorElement &RHS) {
     bool changed = false;
     for (unsigned i = 0; i < BITWORDS_PER_ELEMENT; ++i) {
-      BitWord old = changed ? 0 : Bits[i];
+      BitWord old = Bits[i];
 
       Bits[i] |= RHS.Bits[i];
-      if (!changed && old != Bits[i])
+      if (old != Bits[i])
         changed = true;
     }
     return changed;
@@ -199,13 +199,13 @@ template <unsigned ElementSize = 128> struct SparseBitVectorElement {
 
     BecameZero = false;
     for (unsigned i = 0; i < BITWORDS_PER_ELEMENT; ++i) {
-      BitWord old = changed ? 0 : Bits[i];
+      BitWord old = Bits[i];
 
       Bits[i] &= RHS.Bits[i];
       if (Bits[i] != 0)
         allzero = false;
 
-      if (!changed && old != Bits[i])
+      if (old != Bits[i])
         changed = true;
     }
     BecameZero = allzero;
@@ -222,13 +222,13 @@ template <unsigned ElementSize = 128> struct SparseBitVectorElement {
 
     BecameZero = false;
     for (unsigned i = 0; i < BITWORDS_PER_ELEMENT; ++i) {
-      BitWord old = changed ? 0 : Bits[i];
+      BitWord old = Bits[i];
 
       Bits[i] &= ~RHS.Bits[i];
       if (Bits[i] != 0)
         allzero = false;
 
-      if (!changed && old != Bits[i])
+      if (old != Bits[i])
         changed = true;
     }
     BecameZero = allzero;

@jayfoad
Copy link
Contributor Author

jayfoad commented Jun 11, 2025

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants