Improve bitop tree optimization

- Remove redundant casting
- Cheaper final XOR parity flip (~/^1 instead of != 0)
- Support XOR reduction of ~XOR nodes
- Don't add redundant masking of terms
- Support unmasked terms
- Add cheaper implementation for single bit only terms
- Ensure result is clean under all circumstances (this fixes current bugs)
This commit is contained in:
Geza Lore
2021-08-18 22:00:13 +01:00
parent fffc63970d
commit 8681861be9
6 changed files with 472 additions and 241 deletions
+15
View File
@@ -895,6 +895,21 @@ uint8_t V3Number::dataByte(int byte) const {
return (edataWord(byte / (VL_EDATASIZE / 8)) >> ((byte * 8) % VL_EDATASIZE)) & 0xff;
}
bool V3Number::isAllZ() const {
for (int i = 0; i < width(); i++) {
if (!bitIsZ(i)) return false;
}
return true;
}
bool V3Number::isAllX() const {
uint32_t mask = hiWordMask();
for (int i = words() - 1; i >= 0; --i) {
const ValueAndX v = m_value[i];
if ((v.m_value & v.m_valueX) ^ mask) return false;
mask = ~0U;
}
return true;
}
bool V3Number::isEqZero() const {
for (int i = 0; i < words(); i++) {
const ValueAndX v = m_value[i];