Skip to content

Commit e6ac3af

Browse files
committed
rounder: Fix invalid creation of zero-size bit-vector.
This fixes an issue where the rounder attempts to generate a bit-vector of size 0 in fixedPositionRound() when converting an FP to an unsigned BV of size 1. This has been submitted as PR martin-cs#9.
1 parent 22d993d commit e6ac3af

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

core/rounder.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,8 +212,13 @@ namespace symfpu {
212212
ubv roundedSignificand(conditionalIncrement<t>(roundUp, extractedSignificand));
213213

214214
ubv overflowBit(roundedSignificand.extract(targetWidth, targetWidth) & ubv(roundUp));
215-
ubv carryUpMask((overflowBit | ubv(knownLeadingOne)).append(ubv::zero(targetWidth - 1))); // Cheaper than conditional shift
216-
215+
// Cheaper than conditional shift
216+
ubv carryUpMask(overflowBit | ubv(knownLeadingOne));
217+
if (targetWidth > 1)
218+
{
219+
carryUpMask = carryUpMask.append(ubv::zero(targetWidth - 1));
220+
}
221+
217222
// Build result
218223
significandRounderResult<t> result(roundedSignificand.extract(targetWidth-1,0) | carryUpMask,
219224
overflowBit.isAllOnes());

0 commit comments

Comments
 (0)