Optimize temporary insertion for single bit replicates in DFG (#8110)

A '{N{bit}}' mask expands to a bit vector where every word is the same
value, obtained by negating the replicated bit. Recomputing that at each
use is no more expensive than loading it
This commit is contained in:
Geza Lore
2026-08-14 14:58:31 +02:00
committed by GitHub
parent 2957939d4b
commit 0a3657517d
+7
View File
@@ -829,6 +829,13 @@ bool DfgVertex::isCheaperThanLoad() const {
const uint32_t msb = lsb + selp->width() - 1; const uint32_t msb = lsb + selp->width() - 1;
return VL_BITWORD_E(msb) == VL_BITWORD_E(lsb); return VL_BITWORD_E(msb) == VL_BITWORD_E(lsb);
} }
// Replication of a single cheap bit. Each word of the result is the same
// mask computed by negating that bit, so recomputing it at each use costs
// no more than the load it replaces.
if (const DfgRep* const repp = cast<DfgRep>()) {
const DfgVertex* const srcp = repp->srcp();
return srcp->width() == 1 && srcp->isCheaperThanLoad();
}
// Zero extend of a cheap vertex - Extend(_) was converted to Concat(0, _) // Zero extend of a cheap vertex - Extend(_) was converted to Concat(0, _)
if (const DfgConcat* const catp = cast<DfgConcat>()) { if (const DfgConcat* const catp = cast<DfgConcat>()) {
if (catp->width() > VL_QUADSIZE) return false; if (catp->width() > VL_QUADSIZE) return false;