@@ -2637,18 +2637,15 @@ Instruction *InstCombinerImpl::visitAnd(BinaryOperator &I) {
26372637 // This is a generous interpretation for noimplicitfloat, this is not a true
26382638 // floating-point operation.
26392639 //
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.
26412641 // TODO: Unify with APInt matcher. This version allows undef unlike m_APInt
26422642 Value *CastOp;
26432643 if (match (Op0, m_ElementWiseBitCast (m_Value (CastOp))) &&
2644- match (Op1, m_MaxSignedValue ()) &&
2644+ CastOp-> getType ()-> isFPOrFPVectorTy () && match (Op1, m_MaxSignedValue ()) &&
26452645 !Builder.GetInsertBlock ()->getParent ()->hasFnAttribute (
26462646 Attribute::NoImplicitFloat)) {
2647- Type *EltTy = CastOp->getType ()->getScalarType ();
2648- if (EltTy->isFloatingPointTy () && EltTy->isIEEE ()) {
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 ());
26522649 }
26532650
26542651 // and(shl(zext(X), Y), SignMask) -> and(sext(X), SignMask)
@@ -4047,21 +4044,18 @@ Instruction *InstCombinerImpl::visitOr(BinaryOperator &I) {
40474044 // the number of instructions. This is still probably a better canonical form
40484045 // as it enables FP value tracking.
40494046 //
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.
40514048 //
40524049 // This is generous interpretation of noimplicitfloat, this is not a true
40534050 // floating-point operation.
40544051 Value *CastOp;
40554052 if (match (Op0, m_ElementWiseBitCast (m_Value (CastOp))) &&
4056- match (Op1, m_SignMask ()) &&
4053+ CastOp-> getType ()-> isFPOrFPVectorTy () && match (Op1, m_SignMask ()) &&
40574054 !Builder.GetInsertBlock ()->getParent ()->hasFnAttribute (
40584055 Attribute::NoImplicitFloat)) {
4059- Type *EltTy = CastOp->getType ()->getScalarType ();
4060- if (EltTy->isFloatingPointTy () && EltTy->isIEEE ()) {
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 ());
40654059 }
40664060
40674061 // (X & C1) | C2 -> X & (C1 | C2) iff (X & C2) == C2
@@ -4851,18 +4845,15 @@ Instruction *InstCombinerImpl::visitXor(BinaryOperator &I) {
48514845 // This is generous interpretation of noimplicitfloat, this is not a true
48524846 // floating-point operation.
48534847 //
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.
48554849 // TODO: Unify with APInt matcher. This version allows undef unlike m_APInt
48564850 Value *CastOp;
48574851 if (match (Op0, m_ElementWiseBitCast (m_Value (CastOp))) &&
4858- match (Op1, m_SignMask ()) &&
4852+ CastOp-> getType ()-> isFPOrFPVectorTy () && match (Op1, m_SignMask ()) &&
48594853 !Builder.GetInsertBlock ()->getParent ()->hasFnAttribute (
48604854 Attribute::NoImplicitFloat)) {
4861- Type *EltTy = CastOp->getType ()->getScalarType ();
4862- if (EltTy->isFloatingPointTy () && EltTy->isIEEE ()) {
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 ());
48664857 }
48674858 }
48684859
0 commit comments