aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/CodeGen/ExpandVectorPredication.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'llvm/lib/CodeGen/ExpandVectorPredication.cpp')
-rw-r--r--llvm/lib/CodeGen/ExpandVectorPredication.cpp51
1 files changed, 5 insertions, 46 deletions
diff --git a/llvm/lib/CodeGen/ExpandVectorPredication.cpp b/llvm/lib/CodeGen/ExpandVectorPredication.cpp
index fe95a27..ffe879f 100644
--- a/llvm/lib/CodeGen/ExpandVectorPredication.cpp
+++ b/llvm/lib/CodeGen/ExpandVectorPredication.cpp
@@ -368,52 +368,11 @@ Value *CachingVPExpander::expandPredicationToFPCall(
static Value *getNeutralReductionElement(const VPReductionIntrinsic &VPI,
Type *EltTy) {
- bool Negative = false;
- unsigned EltBits = EltTy->getScalarSizeInBits();
- Intrinsic::ID VID = VPI.getIntrinsicID();
- switch (VID) {
- default:
- llvm_unreachable("Expecting a VP reduction intrinsic");
- case Intrinsic::vp_reduce_add:
- case Intrinsic::vp_reduce_or:
- case Intrinsic::vp_reduce_xor:
- case Intrinsic::vp_reduce_umax:
- return Constant::getNullValue(EltTy);
- case Intrinsic::vp_reduce_mul:
- return ConstantInt::get(EltTy, 1, /*IsSigned*/ false);
- case Intrinsic::vp_reduce_and:
- case Intrinsic::vp_reduce_umin:
- return ConstantInt::getAllOnesValue(EltTy);
- case Intrinsic::vp_reduce_smin:
- return ConstantInt::get(EltTy->getContext(),
- APInt::getSignedMaxValue(EltBits));
- case Intrinsic::vp_reduce_smax:
- return ConstantInt::get(EltTy->getContext(),
- APInt::getSignedMinValue(EltBits));
- case Intrinsic::vp_reduce_fmax:
- case Intrinsic::vp_reduce_fmaximum:
- Negative = true;
- [[fallthrough]];
- case Intrinsic::vp_reduce_fmin:
- case Intrinsic::vp_reduce_fminimum: {
- bool PropagatesNaN = VID == Intrinsic::vp_reduce_fminimum ||
- VID == Intrinsic::vp_reduce_fmaximum;
- FastMathFlags Flags = VPI.getFastMathFlags();
- const fltSemantics &Semantics = EltTy->getFltSemantics();
- return (!Flags.noNaNs() && !PropagatesNaN)
- ? ConstantFP::getQNaN(EltTy, Negative)
- : !Flags.noInfs()
- ? ConstantFP::getInfinity(EltTy, Negative)
- : ConstantFP::get(EltTy,
- APFloat::getLargest(Semantics, Negative));
- }
- case Intrinsic::vp_reduce_fadd:
- return ConstantExpr::getBinOpIdentity(
- Instruction::FAdd, EltTy, false,
- VPI.getFastMathFlags().noSignedZeros());
- case Intrinsic::vp_reduce_fmul:
- return ConstantFP::get(EltTy, 1.0);
- }
+ Intrinsic::ID RdxID = *VPI.getFunctionalIntrinsicID();
+ FastMathFlags FMF;
+ if (isa<FPMathOperator>(VPI))
+ FMF = VPI.getFastMathFlags();
+ return getReductionIdentity(RdxID, EltTy, FMF);
}
Value *