mirror of
https://github.com/RPCS3/llvm-mirror.git
synced 2025-01-31 12:41:49 +01:00
[PatternMatch] add matcher for FP infinity; NFC
This commit is contained in:
parent
47d7e3782b
commit
699a46fa8b
@ -570,6 +570,15 @@ inline cstfp_pred_ty<is_nan> m_NaN() {
|
||||
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(); }
|
||||
};
|
||||
|
@ -1091,6 +1091,8 @@ TEST_F(PatternMatchTest, VectorUndefFloat) {
|
||||
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);
|
||||
@ -1099,6 +1101,13 @@ TEST_F(PatternMatchTest, VectorUndefFloat) {
|
||||
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()));
|
||||
@ -1111,6 +1120,13 @@ TEST_F(PatternMatchTest, VectorUndefFloat) {
|
||||
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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user