[llvm] [SVE][InstCombine] Delete redundante sel instructions with ptrue (PR #68463)
via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 12 18:14:27 PDT 2023
================
@@ -798,8 +798,30 @@ instCombineConvertFromSVBool(InstCombiner &IC, IntrinsicInst &II) {
return IC.replaceInstUsesWith(II, EarliestReplacement);
}
+static bool isAllActivePredicate(Value *Pred) {
+ // Look through convert.from.svbool(convert.to.svbool(...) chain.
+ Value *UncastedPred;
+ if (match(Pred, m_Intrinsic<Intrinsic::aarch64_sve_convert_from_svbool>(
+ m_Intrinsic<Intrinsic::aarch64_sve_convert_to_svbool>(
+ m_Value(UncastedPred)))))
+ // If the predicate has the same or less lanes than the uncasted
+ // predicate then we know the casting has no effect.
+ if (cast<ScalableVectorType>(Pred->getType())->getMinNumElements() <=
+ cast<ScalableVectorType>(UncastedPred->getType())->getMinNumElements())
+ Pred = UncastedPred;
+
+ return match(Pred, m_Intrinsic<Intrinsic::aarch64_sve_ptrue>(
+ m_ConstantInt<AArch64SVEPredPattern::all>()));
+}
+
static std::optional<Instruction *> instCombineSVESel(InstCombiner &IC,
IntrinsicInst &II) {
+ // svsel(ptrue, x, y) => x
+ auto *OpPredicate = II.getOperand(0);
+ if (isAllActivePredicate(OpPredicate)) {
----------------
vfdff wrote:
Updated the stylistic according comment, thanks
https://github.com/llvm/llvm-project/pull/68463
More information about the llvm-commits
mailing list