[PATCH] D37803: [X86] When applying the shuffle-to-zero-extend transformation on floating point, bitcast to integer first.

Ayman Musa via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Sep 13 06:12:36 PDT 2017


aymanmus created this revision.

Fix issue described in PR34577 <https://bugs.llvm.org/show_bug.cgi?id=34577>.


https://reviews.llvm.org/D37803

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


Index: test/CodeGen/X86/pr34577.ll
===================================================================
--- /dev/null
+++ test/CodeGen/X86/pr34577.ll
@@ -0,0 +1,10 @@
+; RUN: llc -mattr=+avx2 -mtriple=x86_64-unknown %s
+
+define internal fastcc <8 x float> @test(<8 x float> %inp0, <8 x float> %inp1, <8 x float> %inp2) #0 {
+entry:
+  %shuf0 = shufflevector <8 x float> %inp0, <8 x float> %inp2, <8 x i32> <i32 1, i32 10, i32 11, i32 13, i32 2, i32 13, i32 5, i32 0>
+  %sel = select <8 x i1> <i1 false, i1 true, i1 true, i1 false, i1 true, i1 false, i1 true, i1 false>, <8 x float> %shuf0, <8 x float> zeroinitializer
+  %shuf1 = shufflevector <8 x float> zeroinitializer, <8 x float> %sel, <8 x i32> <i32 6, i32 11, i32 6, i32 15, i32 12, i32 11, i32 1, i32 3>
+  %shuf2 = shufflevector <8 x float> %inp1, <8 x float> %shuf1, <8 x i32> <i32 15, i32 10, i32 7, i32 2, i32 12, i32 undef, i32 3, i32 2>
+  ret <8 x float> %shuf2
+}
Index: lib/Target/X86/X86ISelLowering.cpp
===================================================================
--- lib/Target/X86/X86ISelLowering.cpp
+++ lib/Target/X86/X86ISelLowering.cpp
@@ -27153,13 +27153,18 @@
       }
       if (Match) {
         unsigned SrcSize = std::max(128u, NumDstElts * MaskEltSize);
-        SrcVT = MVT::getVectorVT(MaskVT.getScalarType(), SrcSize / MaskEltSize);
-        if (SrcVT != MaskVT)
+        MVT ScalarTy = MaskVT.isInteger() ? MaskVT.getScalarType() :
+                                            MVT::getIntegerVT(MaskEltSize);
+        SrcVT = MVT::getVectorVT(ScalarTy, SrcSize / MaskEltSize);
+
+        if (SrcVT.getSizeInBits() != MaskVT.getSizeInBits()) {
           V1 = extractSubVector(V1, 0, DAG, DL, SrcSize);
+          Shuffle = unsigned(X86ISD::VZEXT);
+        } else
+          Shuffle = unsigned(ISD::ZERO_EXTEND_VECTOR_INREG);
+
         DstVT = MVT::getIntegerVT(Scale * MaskEltSize);
         DstVT = MVT::getVectorVT(DstVT, NumDstElts);
-        Shuffle = SrcVT != MaskVT ? unsigned(X86ISD::VZEXT)
-                                  : unsigned(ISD::ZERO_EXTEND_VECTOR_INREG);
         return true;
       }
     }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D37803.115020.patch
Type: text/x-patch
Size: 2110 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20170913/46bd3baa/attachment.bin>


More information about the llvm-commits mailing list