diff options
author | Sanjay Patel <spatel@rotateright.com> | 2019-05-24 00:13:58 +0000 |
---|---|---|
committer | Sanjay Patel <spatel@rotateright.com> | 2019-05-24 00:13:58 +0000 |
commit | 8869a98e82552ef698112df840575693780802a4 (patch) | |
tree | 3075426e6bbc5c0db6c728947cbbd6b508568ec8 /llvm/lib/Analysis/InstructionSimplify.cpp | |
parent | 3e15f833819d6e18988c62e877637258e649808c (diff) | |
download | bcm5719-llvm-8869a98e82552ef698112df840575693780802a4.tar.gz bcm5719-llvm-8869a98e82552ef698112df840575693780802a4.zip |
[InstSimplify] fold insertelement-of-extractelement
This was partly handled in InstCombine (only the constant
index case), so delete that and zap it more generally in
InstSimplify.
llvm-svn: 361576
Diffstat (limited to 'llvm/lib/Analysis/InstructionSimplify.cpp')
-rw-r--r-- | llvm/lib/Analysis/InstructionSimplify.cpp | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/llvm/lib/Analysis/InstructionSimplify.cpp b/llvm/lib/Analysis/InstructionSimplify.cpp index 6e421dcaa73..1f8245d30f6 100644 --- a/llvm/lib/Analysis/InstructionSimplify.cpp +++ b/llvm/lib/Analysis/InstructionSimplify.cpp @@ -4016,6 +4016,12 @@ Value *llvm::SimplifyInsertElementInst(Value *Vec, Value *Val, Value *Idx, if (isa<UndefValue>(Val)) return Vec; + // If we are extracting a value from a vector, then inserting it into the same + // place, that's the input vector: + // insertelt Vec, (extractelt Vec, Idx), Idx --> Vec + if (match(Val, m_ExtractElement(m_Specific(Vec), m_Specific(Idx)))) + return Vec; + return nullptr; } |