[PATCH] D97397: [InstCombine] Add a combine for a shuffle of identical bitcasts

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Feb 24 09:32:09 PST 2021


lebedev.ri edited reviewers, added: lebedev.ri; removed: spatel, dmgreen, SjoerdMeijer, fhahn.
lebedev.ri added inline comments.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp:2297
+  Value *X, *Y;
+  if (match(LHS, m_BitCast(m_Value(X))) && match(RHS, m_BitCast(m_Value(Y))) &&
+      X->getType()->isVectorTy() &&
----------------
One of the original bitcasts needs to be one-use, else we'll increase instruction count.


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp:2299
+      X->getType()->isVectorTy() &&
+      cast<FixedVectorType>(X->getType())->getNumElements() == VWidth &&
+      X->getType() == Y->getType()) {
----------------
Can we do anything for the case where we have element count mismatches?


================
Comment at: llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp:2301
+      X->getType() == Y->getType()) {
+    Value *V = Builder.CreateShuffleVector(X, Y, SVI.getShuffleMask());
+    return new BitCastInst(V, SVI.getType());
----------------



Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D97397



More information about the llvm-commits mailing list