[PATCH] D101986: [InstSimplify] Remove redundant {insert,extract}_vector intrinsic chains

Paul Walker via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Tue May 18 08:35:34 PDT 2021


paulwalker-arm added inline comments.


================
Comment at: llvm/lib/Analysis/InstructionSimplify.cpp:5741-5747
+    // (insert_vector _, (extract_vector X, 0), 0) -> X
+    unsigned IdxN = cast<ConstantInt>(Idx)->getZExtValue();
+    Value *X = nullptr;
+    if (match(SubVec, m_Intrinsic<Intrinsic::experimental_vector_extract>(
+                          m_Value(X), m_Zero())) &&
+        IdxN == 0 && X->getType() == ReturnType)
+      return X;
----------------
Are you sure this transform is correct?  I would have thought the following are safe:
```
(insert_vector X, (extract_vector X, 0), 0) -> X
(insert_vector undef, (extract_vector X, 0), 0) -> X
```
when `X->getType() == ReturnType` but nothing else.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D101986/new/

https://reviews.llvm.org/D101986



More information about the cfe-commits mailing list