[PATCH] D81620: [SVE] Make getSplatValue work for some scalable vector splats

Christopher Tetreault via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jun 10 16:08:29 PDT 2020


ctetreau created this revision.
Herald added subscribers: llvm-commits, psnobl, rkruppe, hiraditya, tschuett.
Herald added a reviewer: efriedma.
Herald added a project: LLVM.

Make getSplatValue work for scalable vector splats of the form returned
by ConstantVector::getSplat()


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D81620

Files:
  llvm/lib/IR/Constants.cpp


Index: llvm/lib/IR/Constants.cpp
===================================================================
--- llvm/lib/IR/Constants.cpp
+++ llvm/lib/IR/Constants.cpp
@@ -1518,6 +1518,22 @@
     return CV->getSplatValue();
   if (const ConstantVector *CV = dyn_cast<ConstantVector>(this))
     return CV->getSplatValue(AllowUndefs);
+
+  // Check if this is a constant expression splat of the form returned by
+  // ConstantVector::getSplat()
+  Constant *SplatVal = nullptr;
+  ConstantInt *Index = nullptr;
+
+  match(this,
+        m_Shuffle(m_InsertElt(m_Undef(), m_Constant(SplatVal), m_ConstantInt()),
+                  m_Undef()));
+
+  if (Index && Index->getValue() == 0) {
+    if (SplatVal) {
+      return SplatVal;
+    }
+  }
+
   return nullptr;
 }
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D81620.269989.patch
Type: text/x-patch
Size: 761 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200610/2a1c3062/attachment.bin>


More information about the llvm-commits mailing list