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

Paul Walker via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 9 07:27:12 PDT 2025


================
@@ -2641,6 +2641,20 @@ static std::optional<Instruction *> instCombineDMB(InstCombiner &IC,
   return std::nullopt;
 }
 
+static std::optional<Instruction *> instCombinePTrue(InstCombiner &IC,
+                                                     IntrinsicInst &II) {
+  IRBuilder<> Builder(&II);
+  auto Type = cast<VectorType>(II.getType());
+  ConstantInt *Pattern;
+  if (match(II.getOperand(0), m_ConstantInt(Pattern)) &&
+      Pattern->getZExtValue() == AArch64SVEPredPattern::all) {
+    Value *One = ConstantInt::get(Builder.getInt1Ty(), APInt(1, 1));
+    Value *SplatOne = Builder.CreateVectorSplat(Type->getElementCount(), One);
+    return IC.replaceInstUsesWith(II, SplatOne);
----------------
paulwalker-arm wrote:

It's worth trying `Constant::getAllOnesValue(Type)` because for predicates `all 1s` and `1s` are the same thing.

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


More information about the cfe-commits mailing list