[PATCH] [x86] Fix compile fail in combineX86ShufflesRecursively function in case of IncomingMask has -1 elements

Robert Khasanov rob.khasanov at gmail.com
Thu Aug 14 08:35:51 PDT 2014


Hi chandlerc, nadav,

Fix compile fail in combineX86ShufflesRecursively function in case of IncomingMask has -1 elements.
If IncomingMask[i] = -1 for some i, push -1 to Mask instead of OpMask[IncomingMask[i]]
PR20540

http://reviews.llvm.org/D4905

Files:
  lib/Target/X86/X86ISelLowering.cpp
  test/CodeGen/X86/pr20540.ll

Index: lib/Target/X86/X86ISelLowering.cpp
===================================================================
--- lib/Target/X86/X86ISelLowering.cpp
+++ lib/Target/X86/X86ISelLowering.cpp
@@ -19325,8 +19325,12 @@
   // Merge this shuffle operation's mask into our accumulated mask. This is
   // a bit tricky as the shuffle may have a different size from the root.
   if (OpMask.size() == IncomingMask.size()) {
-    for (int M : IncomingMask)
-      Mask.push_back(OpMask[M]);
+    for (int M : IncomingMask) {
+      if (M == SM_SentinelZero)
+        Mask.push_back(SM_SentinelZero);
+      else
+        Mask.push_back(OpMask[M]);
+    }
   } else if (OpMask.size() < IncomingMask.size()) {
     assert(IncomingMask.size() % OpMask.size() == 0 &&
            "The smaller number of elements must divide the larger.");
Index: test/CodeGen/X86/pr20540.ll
===================================================================
--- /dev/null
+++ test/CodeGen/X86/pr20540.ll
@@ -0,0 +1,13 @@
+; RUN: llc  < %s -mtriple=x86_64-apple-darwin -march=x86  -mcpu=corei7 | FileCheck %s
+
+declare i32 @llvm.x86.sse2.pmovmskb.128(<16 x i8>)
+
+define void @f_fu_(float* noalias nocapture %RET, <8 x i8> %__mask) {
+  ; CHECK: pshufb
+  %mask8.i.i.i = shufflevector <8 x i8> %__mask, <8 x i8> zeroinitializer, <16 x i32> <i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8, i32 8>
+  %m.i.i.i = call i32 @llvm.x86.sse2.pmovmskb.128(<16 x i8> %mask8.i.i.i)
+  %RET.i = bitcast float* %RET to i32*
+  store i32 %m.i.i.i, i32* %RET.i
+  ret void
+}
+
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D4905.12507.patch
Type: text/x-patch
Size: 1588 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140814/650f2b83/attachment.bin>


More information about the llvm-commits mailing list