aboutsummaryrefslogtreecommitdiff
path: root/llvm/lib/Analysis/InstructionSimplify.cpp
diff options
context:
space:
mode:
authorPhilip Reames <preames@rivosinc.com>2025-06-16 10:07:56 -0700
committerGitHub <noreply@github.com>2025-06-16 10:07:56 -0700
commit6f9cd79fa2f43b8128be3e4386ee182ad5a843cc (patch)
tree00e550bc83fd8a91ccbba1388195a04bf7cea557 /llvm/lib/Analysis/InstructionSimplify.cpp
parentc62a6138d9d02bcc0fb6660bbed78b4e979fc3dc (diff)
downloadllvm-6f9cd79fa2f43b8128be3e4386ee182ad5a843cc.zip
llvm-6f9cd79fa2f43b8128be3e4386ee182ad5a843cc.tar.gz
llvm-6f9cd79fa2f43b8128be3e4386ee182ad5a843cc.tar.bz2
[InstSimplify] Add basic simplifications for vp.reverse (#144112)
Directly modeled after what we do for vector.reverse, but with restrictions on EVL and mask added.
Diffstat (limited to 'llvm/lib/Analysis/InstructionSimplify.cpp')
-rw-r--r--llvm/lib/Analysis/InstructionSimplify.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp
index e397a22..d1ac8d9 100644
--- a/llvm/lib/Analysis/InstructionSimplify.cpp
+++ b/llvm/lib/Analysis/InstructionSimplify.cpp
@@ -6969,6 +6969,23 @@ static Value *simplifyIntrinsic(CallBase *Call, Value *Callee,
}
return nullptr;
}
+ case Intrinsic::experimental_vp_reverse: {
+ Value *Vec = Call->getArgOperand(0);
+ Value *Mask = Call->getArgOperand(1);
+ Value *EVL = Call->getArgOperand(2);
+
+ Value *X;
+ // vp.reverse(vp.reverse(X)) == X (with all ones mask and matching EVL)
+ if (match(Mask, m_AllOnes()) &&
+ match(Vec, m_Intrinsic<Intrinsic::experimental_vp_reverse>(
+ m_Value(X), m_AllOnes(), m_Specific(EVL))))
+ return X;
+
+ // vp.reverse(splat(X)) -> splat(X) (regardless of mask and EVL)
+ if (isSplatValue(Vec))
+ return Vec;
+ return nullptr;
+ }
default:
return nullptr;
}