@@ -2637,18 +2637,15 @@ Instruction *InstCombinerImpl::visitAnd(BinaryOperator &I) {
2637
2637
// This is a generous interpretation for noimplicitfloat, this is not a true
2638
2638
// floating-point operation.
2639
2639
//
2640
- // Assumes any IEEE-represented type has the sign bit in the high bit.
2640
+ // Assumes any floating point type has the sign bit in the high bit.
2641
2641
// TODO: Unify with APInt matcher. This version allows undef unlike m_APInt
2642
2642
Value *CastOp;
2643
2643
if (match (Op0, m_ElementWiseBitCast (m_Value (CastOp))) &&
2644
- match (Op1, m_MaxSignedValue ()) &&
2644
+ CastOp-> getType ()-> isFPOrFPVectorTy () && match (Op1, m_MaxSignedValue ()) &&
2645
2645
!Builder.GetInsertBlock ()->getParent ()->hasFnAttribute (
2646
2646
Attribute::NoImplicitFloat)) {
2647
- Type *EltTy = CastOp->getType ()->getScalarType ();
2648
- if (EltTy->isIEEELikeFPTy ()) {
2649
- Value *FAbs = Builder.CreateUnaryIntrinsic (Intrinsic::fabs , CastOp);
2650
- return new BitCastInst (FAbs, I.getType ());
2651
- }
2647
+ Value *FAbs = Builder.CreateUnaryIntrinsic (Intrinsic::fabs , CastOp);
2648
+ return new BitCastInst (FAbs, I.getType ());
2652
2649
}
2653
2650
2654
2651
// and(shl(zext(X), Y), SignMask) -> and(sext(X), SignMask)
@@ -4047,21 +4044,18 @@ Instruction *InstCombinerImpl::visitOr(BinaryOperator &I) {
4047
4044
// the number of instructions. This is still probably a better canonical form
4048
4045
// as it enables FP value tracking.
4049
4046
//
4050
- // Assumes any IEEE-represented type has the sign bit in the high bit.
4047
+ // Assumes any floating point type has the sign bit in the high bit.
4051
4048
//
4052
4049
// This is generous interpretation of noimplicitfloat, this is not a true
4053
4050
// floating-point operation.
4054
4051
Value *CastOp;
4055
4052
if (match (Op0, m_ElementWiseBitCast (m_Value (CastOp))) &&
4056
- match (Op1, m_SignMask ()) &&
4053
+ CastOp-> getType ()-> isFPOrFPVectorTy () && match (Op1, m_SignMask ()) &&
4057
4054
!Builder.GetInsertBlock ()->getParent ()->hasFnAttribute (
4058
4055
Attribute::NoImplicitFloat)) {
4059
- Type *EltTy = CastOp->getType ()->getScalarType ();
4060
- if (EltTy->isIEEELikeFPTy ()) {
4061
- Value *FAbs = Builder.CreateUnaryIntrinsic (Intrinsic::fabs , CastOp);
4062
- Value *FNegFAbs = Builder.CreateFNeg (FAbs);
4063
- return new BitCastInst (FNegFAbs, I.getType ());
4064
- }
4056
+ Value *FAbs = Builder.CreateUnaryIntrinsic (Intrinsic::fabs , CastOp);
4057
+ Value *FNegFAbs = Builder.CreateFNeg (FAbs);
4058
+ return new BitCastInst (FNegFAbs, I.getType ());
4065
4059
}
4066
4060
4067
4061
// (X & C1) | C2 -> X & (C1 | C2) iff (X & C2) == C2
@@ -4851,18 +4845,15 @@ Instruction *InstCombinerImpl::visitXor(BinaryOperator &I) {
4851
4845
// This is generous interpretation of noimplicitfloat, this is not a true
4852
4846
// floating-point operation.
4853
4847
//
4854
- // Assumes any IEEE-represented type has the sign bit in the high bit.
4848
+ // Assumes any floating point type has the sign bit in the high bit.
4855
4849
// TODO: Unify with APInt matcher. This version allows undef unlike m_APInt
4856
4850
Value *CastOp;
4857
4851
if (match (Op0, m_ElementWiseBitCast (m_Value (CastOp))) &&
4858
- match (Op1, m_SignMask ()) &&
4852
+ CastOp-> getType ()-> isFPOrFPVectorTy () && match (Op1, m_SignMask ()) &&
4859
4853
!Builder.GetInsertBlock ()->getParent ()->hasFnAttribute (
4860
4854
Attribute::NoImplicitFloat)) {
4861
- Type *EltTy = CastOp->getType ()->getScalarType ();
4862
- if (EltTy->isIEEELikeFPTy ()) {
4863
- Value *FNeg = Builder.CreateFNeg (CastOp);
4864
- return new BitCastInst (FNeg, I.getType ());
4865
- }
4855
+ Value *FNeg = Builder.CreateFNeg (CastOp);
4856
+ return new BitCastInst (FNeg, I.getType ());
4866
4857
}
4867
4858
}
4868
4859
0 commit comments