[llvm] 5f05c2f - [CGP] remove duplicate function for finding a splat shuffle; NFC

Sanjay Patel via llvm-commits llvm-commits at lists.llvm.org
Mon May 11 13:36:24 PDT 2020


Author: Sanjay Patel
Date: 2020-05-11T16:36:07-04:00
New Revision: 5f05c2f59a7fc666605a74e8616af17da8efa132

URL: https://github.com/llvm/llvm-project/commit/5f05c2f59a7fc666605a74e8616af17da8efa132
DIFF: https://github.com/llvm/llvm-project/commit/5f05c2f59a7fc666605a74e8616af17da8efa132.diff

LOG: [CGP] remove duplicate function for finding a splat shuffle; NFC

Added: 
    

Modified: 
    llvm/lib/CodeGen/CodeGenPrepare.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/CodeGen/CodeGenPrepare.cpp b/llvm/lib/CodeGen/CodeGenPrepare.cpp
index eceee30c532f..881366c58986 100644
--- a/llvm/lib/CodeGen/CodeGenPrepare.cpp
+++ b/llvm/lib/CodeGen/CodeGenPrepare.cpp
@@ -6415,18 +6415,6 @@ bool CodeGenPrepare::optimizeSelectInst(SelectInst *SI) {
   return true;
 }
 
-static bool isBroadcastShuffle(ShuffleVectorInst *SVI) {
-  ArrayRef<int> Mask(SVI->getShuffleMask());
-  int SplatElem = -1;
-  for (unsigned i = 0; i < Mask.size(); ++i) {
-    if (SplatElem != -1 && Mask[i] != -1 && Mask[i] != SplatElem)
-      return false;
-    SplatElem = Mask[i];
-  }
-
-  return true;
-}
-
 /// Some targets have expensive vector shifts if the lanes aren't all the same
 /// (e.g. x86 only introduced "vpsllvd" and friends with AVX2). In these cases
 /// it's often worth sinking a shufflevector splat down to its use so that
@@ -6440,7 +6428,7 @@ bool CodeGenPrepare::optimizeShuffleVectorInst(ShuffleVectorInst *SVI) {
 
   // We only expect better codegen by sinking a shuffle if we can recognise a
   // constant splat.
-  if (!isBroadcastShuffle(SVI))
+  if (getSplatIndex(SVI->getShuffleMask()) < 0)
     return false;
 
   // InsertedShuffles - Only insert a shuffle in each block once.


        


More information about the llvm-commits mailing list