Index: llvm/lib/Analysis/VectorUtils.cpp =================================================================== --- llvm/lib/Analysis/VectorUtils.cpp +++ llvm/lib/Analysis/VectorUtils.cpp @@ -22,6 +22,7 @@ #include "llvm/IR/Constants.h" #include "llvm/IR/GetElementPtrTypeIterator.h" #include "llvm/IR/IRBuilder.h" +#include "llvm/IR/IntrinsicsAArch64.h" #include "llvm/IR/PatternMatch.h" #include "llvm/IR/Value.h" #include "llvm/Support/CommandLine.h" @@ -413,6 +414,14 @@ return isSplatValue(X, Index, Depth) && isSplatValue(Y, Index, Depth) && isSplatValue(Z, Index, Depth); + // aarch64_sve_ptrue(31) is an all true predicate i.e. splat(i1 1). + if (match(V, m_Intrinsic(m_SpecificInt(31)))) + return true; + + // aarch64_sve_dup_x is splat operation. + if (match(V, m_Intrinsic())) + return true; + // TODO: Add support for unary ops (fneg), casts, intrinsics (overflow ops). return false; Index: llvm/test/Transforms/InstSimplify/named-vector-shuffle-reverse.ll =================================================================== --- llvm/test/Transforms/InstSimplify/named-vector-shuffle-reverse.ll +++ llvm/test/Transforms/InstSimplify/named-vector-shuffle-reverse.ll @@ -22,4 +22,27 @@ ret %rev } +define @splat_ptrue_intr_reverse() { +; CHECK-LABEL: @splat_ptrue_intr_reverse( +; CHECK-NEXT: [[SPLAT:%.*]] = call @llvm.aarch64.sve.ptrue.nxv4i1(i32 31) +; CHECK-NEXT: ret [[SPLAT]] +; + %splat = call @llvm.aarch64.sve.ptrue.nxv4i1(i32 31) + %rev = tail call @llvm.experimental.vector.reverse.nxv4i1( %splat) + ret %rev +} + +define @splat_dupx_intr_reverse(i32 %a) { +; CHECK-LABEL: @splat_dupx_intr_reverse( +; CHECK-NEXT: [[SPLAT:%.*]] = call @llvm.aarch64.sve.dup.x.nxv4i32(i32 [[A:%.*]]) +; CHECK-NEXT: ret [[SPLAT]] +; + %splat= call @llvm.aarch64.sve.dup.x.nxv4i32(i32 %a) + %rev = tail call @llvm.experimental.vector.reverse.nxv4i32( %splat) + ret %rev +} + +declare @llvm.aarch64.sve.ptrue.nxv4i1(i32 %pattern) +declare @llvm.aarch64.sve.dup.x.nxv4i32(i32) +declare @llvm.experimental.vector.reverse.nxv4i1() declare @llvm.experimental.vector.reverse.nxv4i32()