[PATCH] D101900: [InstCombine] Fold extractelement + vector GEP with one use

Sander de Smalen via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 6 03:18:36 PDT 2021


sdesmalen added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp:434
+    } else if (auto *GEP = dyn_cast<GetElementPtrInst>(I)) {
+      auto *VecType = dyn_cast<VectorType>(GEP->getType());
+      if (VecType && IndexC && GEP->hasOneUse()) {
----------------
Isn't the type of GEP guaranteed to be of type VectorType?


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp:440
+          // Find out why we have a vector result - there are possibilities:
+          //  1. We have a scalar pointer and a vector of indices, or
+          //  2. We have a vector of pointers and a scalar index, or
----------------
Does this need to be limited to a vector of indices that is also a splat?


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp:480
       // Restrict the following transformation to fixed-length vector.
-      if (isa<FixedVectorType>(SVI->getType()) && isa<ConstantInt>(Index)) {
-        int SrcIdx =
-            SVI->getMaskValue(cast<ConstantInt>(Index)->getZExtValue());
+      if (isa<FixedVectorType>(SVI->getType()) && IndexC) {
+        int SrcIdx = SVI->getMaskValue(IndexC->getZExtValue());
----------------
unnecessary change.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D101900



More information about the llvm-commits mailing list