[clang] [llvm] [AArch64][SVE] Instcombine ptrue(all) to splat(i1) (PR #135016)

Matthew Devereau via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 9 12:11:08 PDT 2025


================
@@ -1492,9 +1492,17 @@ static bool isAllActivePredicate(Value *Pred) {
     if (cast<ScalableVectorType>(Pred->getType())->getMinNumElements() <=
         cast<ScalableVectorType>(UncastedPred->getType())->getMinNumElements())
       Pred = UncastedPred;
+  if (match(Pred, m_Intrinsic<Intrinsic::aarch64_sve_ptrue>(
+                      m_ConstantInt<AArch64SVEPredPattern::all>())))
+    return true;
+
+  if (Value *Splat = getSplatValue(Pred)) {
+    auto ConstIdx = dyn_cast<ConstantInt>(Splat);
+    if (ConstIdx->getZExtValue() == 1)
+      return true;
+  }
----------------
MDevereau wrote:

I couldn't see a static method or one in the Constant namespace that took a parameter, so went with
```c++
  auto *C = dyn_cast<Constant>(Pred);
  return (C && C->isAllOnesValue());
``` 
Your other suggestions check out though, thanks.

https://github.com/llvm/llvm-project/pull/135016


More information about the cfe-commits mailing list