return cstfp_pred_ty<is_nan>();
}
+struct is_inf {
+ bool isValue(const APFloat &C) { return C.isInfinity(); }
+};
+/// Match a positive or negative infinity FP constant.
+/// For vectors, this includes constants with undefined elements.
+inline cstfp_pred_ty<is_inf> m_Inf() {
+ return cstfp_pred_ty<is_inf>();
+}
+
struct is_any_zero_fp {
bool isValue(const APFloat &C) { return C.isZero(); }
};
Constant *VectorUndef = UndefValue::get(VectorTy);
Constant *ScalarZero = Constant::getNullValue(ScalarTy);
Constant *VectorZero = Constant::getNullValue(VectorTy);
+ Constant *ScalarPosInf = ConstantFP::getInfinity(ScalarTy, false);
+ Constant *ScalarNegInf = ConstantFP::getInfinity(ScalarTy, true);
SmallVector<Constant *, 4> Elems;
Elems.push_back(ScalarUndef);
Elems.push_back(ScalarZero);
Constant *VectorZeroUndef = ConstantVector::get(Elems);
+ SmallVector<Constant *, 4> InfElems;
+ InfElems.push_back(ScalarPosInf);
+ InfElems.push_back(ScalarNegInf);
+ InfElems.push_back(ScalarUndef);
+ InfElems.push_back(ScalarPosInf);
+ Constant *VectorInfUndef = ConstantVector::get(InfElems);
+
EXPECT_TRUE(match(ScalarUndef, m_Undef()));
EXPECT_TRUE(match(VectorUndef, m_Undef()));
EXPECT_FALSE(match(ScalarZero, m_Undef()));
EXPECT_TRUE(match(VectorZero, m_AnyZeroFP()));
EXPECT_TRUE(match(VectorZeroUndef, m_AnyZeroFP()));
+ EXPECT_FALSE(match(ScalarUndef, m_Inf()));
+ EXPECT_FALSE(match(VectorUndef, m_Inf()));
+ EXPECT_FALSE(match(VectorZeroUndef, m_Inf()));
+ EXPECT_TRUE(match(ScalarPosInf, m_Inf()));
+ EXPECT_TRUE(match(ScalarNegInf, m_Inf()));
+ EXPECT_TRUE(match(VectorInfUndef, m_Inf()));
+
const APFloat *C;
// Regardless of whether undefs are allowed,
// a fully undef constant does not match.