Skip to content

Commit 603ec71

Browse files
committed
KnownBits: address review; more concise
1 parent 901b6e5 commit 603ec71

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

llvm/lib/Support/KnownBits.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -807,14 +807,13 @@ KnownBits KnownBits::mul(const KnownBits &LHS, const KnownBits &RHS,
807807
// fit in the bitwidth (it must not overflow).
808808
bool HasOverflow;
809809
APInt Result = MaxLHS.umul_ov(MaxRHS, HasOverflow);
810-
bool NegResult = LHS.isNegative() ^ RHS.isNegative();
811810
unsigned LeadZ = 0, LeadO = 0;
812811
if (!HasOverflow) {
812+
if (LHS.isNegative() == RHS.isNegative())
813+
LeadZ = Result.countLeadingZeros();
813814
// Do not set leading ones unless the result is known to be non-zero.
814-
if (NegResult && LHS.isNonZero() && RHS.isNonZero())
815+
else if (LHS.isNonZero() && RHS.isNonZero())
815816
LeadO = (-Result).countLeadingOnes();
816-
else if (!NegResult)
817-
LeadZ = Result.countLeadingZeros();
818817
}
819818

820819
// The result of the bottom bits of an integer multiply can be

0 commit comments

Comments
 (0)