File tree Expand file tree Collapse file tree 2 files changed +10
-15
lines changed
llvm/lib/Transforms/Vectorize Expand file tree Collapse file tree 2 files changed +10
-15
lines changed Original file line number Diff line number Diff line change @@ -845,23 +845,13 @@ bool VPlanTransforms::handleMaxMinNumReductions(VPlan &Plan) {
845845 if (!MinMaxR)
846846 return nullptr ;
847847
848- auto *RepR = dyn_cast<VPReplicateRecipe>(MinMaxR);
849- if (!isa<VPWidenIntrinsicRecipe>(MinMaxR) &&
850- !(RepR && isa<IntrinsicInst>(RepR->getUnderlyingInstr ())))
848+ // Check that MinMaxR is a VPWidenIntrinsicRecipe or VPReplicateRecipe
849+ // with an intrinsic that matches the reduction kind.
850+ Intrinsic::ID ExpectedIntrinsicID =
851+ getMinMaxReductionIntrinsicOp (RedPhiR->getRecurrenceKind ());
852+ if (!match (MinMaxR, m_Intrinsic (ExpectedIntrinsicID)))
851853 return nullptr ;
852854
853- #ifndef NDEBUG
854- Intrinsic::ID RdxIntrinsicId =
855- RedPhiR->getRecurrenceKind () == RecurKind::FMaxNum ? Intrinsic::maxnum
856- : Intrinsic::minnum;
857- assert (((isa<VPWidenIntrinsicRecipe>(MinMaxR) &&
858- cast<VPWidenIntrinsicRecipe>(MinMaxR)->getVectorIntrinsicID () ==
859- RdxIntrinsicId) ||
860- (RepR && cast<IntrinsicInst>(RepR->getUnderlyingInstr ())
861- ->getIntrinsicID () == RdxIntrinsicId)) &&
862- " Intrinsic did not match recurrence kind" );
863- #endif
864-
865855 if (MinMaxR->getOperand (0 ) == RedPhiR)
866856 return MinMaxR->getOperand (1 );
867857
Original file line number Diff line number Diff line change @@ -856,6 +856,11 @@ template <Intrinsic::ID IntrID> inline IntrinsicID_match m_Intrinsic() {
856856 return IntrinsicID_match (IntrID);
857857}
858858
859+ // / Match intrinsic calls with a runtime intrinsic ID.
860+ inline IntrinsicID_match m_Intrinsic (Intrinsic::ID IntrID) {
861+ return IntrinsicID_match (IntrID);
862+ }
863+
859864template <Intrinsic::ID IntrID, typename T0>
860865inline typename m_Intrinsic_Ty<T0>::Ty m_Intrinsic (const T0 &Op0) {
861866 return m_CombineAnd (m_Intrinsic<IntrID>(), m_Argument<0 >(Op0));
You can’t perform that action at this time.
0 commit comments