Skip to content

Commit d163f9c

Browse files
committed
[ValueTracking] Address review comments.
1 parent 5939b6f commit d163f9c

File tree

2 files changed

+15
-16
lines changed

2 files changed

+15
-16
lines changed

llvm/include/llvm/IR/PatternMatch.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1837,7 +1837,7 @@ template <typename Op_t> struct ElementWiseBitCast_match {
18371837
ElementWiseBitCast_match(const Op_t &OpMatch) : Op(OpMatch) {}
18381838

18391839
template <typename OpTy> bool match(OpTy *V) {
1840-
BitCastInst *I = dyn_cast<BitCastInst>(V);
1840+
auto *I = dyn_cast<BitCastInst>(V);
18411841
if (!I)
18421842
return false;
18431843
Type *SrcType = I->getSrcTy();

llvm/lib/Analysis/ValueTracking.cpp

Lines changed: 14 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1111,9 +1111,9 @@ static void computeKnownBitsFromOperator(const Operator *I,
11111111
break;
11121112
}
11131113

1114-
Value *V;
1114+
const Value *V;
11151115
// Handle bitcast from floating point to integer.
1116-
if (match(const_cast<Operator *>(I), m_ElementWiseBitCast(m_Value(V))) &&
1116+
if (match(I, m_ElementWiseBitCast(m_Value(V))) &&
11171117
V->getType()->isFPOrFPVectorTy()) {
11181118
KnownFPClass Result = computeKnownFPClass(V, fcAllFlags, Depth + 1, Q);
11191119
if (Result.SignBit) {
@@ -1126,19 +1126,18 @@ static void computeKnownBitsFromOperator(const Operator *I,
11261126
Type *FPType = V->getType()->getScalarType();
11271127
if (FPType->isIEEELikeFPTy()) {
11281128
int MantissaWidth = FPType->getFPMantissaWidth();
1129-
if (MantissaWidth != -1) {
1130-
if (Result.isKnownOnly(fcInf)) {
1131-
Known.Zero.setLowBits(MantissaWidth);
1132-
Known.One.setBits(MantissaWidth, BitWidth - 1);
1133-
} else if (Result.isKnownOnly(fcZero)) {
1134-
Known.Zero.setLowBits(BitWidth - 1);
1135-
} else if (Result.isKnownOnly(fcInf | fcNan)) {
1136-
Known.One.setBits(MantissaWidth, BitWidth - 1);
1137-
} else if (Result.isKnownOnly(fcSubnormal | fcZero)) {
1138-
Known.Zero.setBits(MantissaWidth, BitWidth - 1);
1139-
} else if (Result.isKnownOnly(fcInf | fcZero)) {
1140-
Known.Zero.setLowBits(MantissaWidth);
1141-
}
1129+
assert(MantissaWidth != -1 && "Invalid mantissa width");
1130+
if (Result.isKnownOnly(fcInf)) {
1131+
Known.Zero.setLowBits(MantissaWidth);
1132+
Known.One.setBits(MantissaWidth, BitWidth - 1);
1133+
} else if (Result.isKnownOnly(fcZero)) {
1134+
Known.Zero.setLowBits(BitWidth - 1);
1135+
} else if (Result.isKnownOnly(fcInf | fcNan)) {
1136+
Known.One.setBits(MantissaWidth, BitWidth - 1);
1137+
} else if (Result.isKnownOnly(fcSubnormal | fcZero)) {
1138+
Known.Zero.setBits(MantissaWidth, BitWidth - 1);
1139+
} else if (Result.isKnownOnly(fcInf | fcZero)) {
1140+
Known.Zero.setLowBits(MantissaWidth);
11421141
}
11431142
}
11441143

0 commit comments

Comments
 (0)