[llvm] [AArch64][SVE] Implement demanded bits for @llvm.aarch64.sve.cntp (PR #168714)
Matthew Devereau via llvm-commits
llvm-commits at lists.llvm.org
Wed Nov 19 09:41:17 PST 2025
================
@@ -19443,20 +19443,38 @@ AArch64TargetLowering::BuildSREMPow2(SDNode *N, const APInt &Divisor,
return CSNeg;
}
-static std::optional<unsigned> IsSVECntIntrinsic(SDValue S) {
+static bool IsSVECntIntrinsic(SDValue S) {
switch(getIntrinsicID(S.getNode())) {
default:
break;
case Intrinsic::aarch64_sve_cntb:
- return 8;
case Intrinsic::aarch64_sve_cnth:
- return 16;
case Intrinsic::aarch64_sve_cntw:
- return 32;
case Intrinsic::aarch64_sve_cntd:
- return 64;
+ case Intrinsic::aarch64_sve_cntp:
+ return true;
+ }
+ return false;
+}
+
+// Returns the maximum (scalable) value that can be returned by an SVE count
+// intrinsic. The supported intrinsics are covered by IsSVECntIntrinsic.
+static ElementCount getMaxValueForSVECntIntrinsic(SDValue Op) {
+ Intrinsic::ID IID = getIntrinsicID(Op.getNode());
+ if (IID == Intrinsic::aarch64_sve_cntp)
+ return Op.getOperand(1).getValueType().getVectorElementCount();
+ switch (IID) {
+ case Intrinsic::aarch64_sve_cntd:
+ return ElementCount::getScalable(2);
+ case Intrinsic::aarch64_sve_cntw:
+ return ElementCount::getScalable(4);
+ case Intrinsic::aarch64_sve_cnth:
+ return ElementCount::getScalable(8);
+ case Intrinsic::aarch64_sve_cntb:
+ return ElementCount::getScalable(16);
+ default:
+ llvm_unreachable("unexpected intrininc");
----------------
MDevereau wrote:
```suggestion
llvm_unreachable("Unexpected intrinsic");
```
https://github.com/llvm/llvm-project/pull/168714
More information about the llvm-commits
mailing list