[PATCH] Fix assertion with a trunc store to an i1 vector.

Matt Arsenault Matthew.Arsenault at amd.com
Fri Apr 4 18:55:24 PDT 2014


  Fix other assert in ShrinkDemandedOp. It might be better to just fully disable it for vectors, since it seems unlikely that isTruncateFree or isZExtFree would be true for any vectors

http://llvm-reviews.chandlerc.com/D3163

CHANGE SINCE LAST DIFF
  http://llvm-reviews.chandlerc.com/D3163?vs=8063&id=8387#toc

Files:
  lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
  lib/CodeGen/SelectionDAG/TargetLowering.cpp

Index: lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -774,9 +774,16 @@
         // Promote to a byte-sized store with upper bits zero if not
         // storing an integral number of bytes.  For example, promote
         // TRUNCSTORE:i1 X -> TRUNCSTORE:i8 (and X, 1)
+
+        EVT ScalarStVT = StVT.getScalarType();
         EVT NVT = EVT::getIntegerVT(*DAG.getContext(),
-                                    StVT.getStoreSizeInBits());
-        Value = DAG.getZeroExtendInReg(Value, dl, StVT);
+                                    ScalarStVT.getStoreSizeInBits());
+        if (StVT.isVector()) {
+          NVT = EVT::getVectorVT(*DAG.getContext(), NVT,
+                                 StVT.getVectorNumElements());
+        }
+
+        Value = DAG.getZeroExtendInReg(Value, dl, ScalarStVT);
         SDValue Result =
           DAG.getTruncStore(Chain, dl, Value, Ptr, ST->getPointerInfo(),
                             NVT, isVolatile, isNonTemporal, Alignment,
Index: lib/CodeGen/SelectionDAG/TargetLowering.cpp
===================================================================
--- lib/CodeGen/SelectionDAG/TargetLowering.cpp
+++ lib/CodeGen/SelectionDAG/TargetLowering.cpp
@@ -340,8 +340,14 @@
   unsigned SmallVTBits = DemandedSize;
   if (!isPowerOf2_32(SmallVTBits))
     SmallVTBits = NextPowerOf2(SmallVTBits);
+
+  EVT VT = Op.getValueType();
+  unsigned NElts = VT.isVector() ? VT.getVectorNumElements() : 0;
   for (; SmallVTBits < BitWidth; SmallVTBits = NextPowerOf2(SmallVTBits)) {
     EVT SmallVT = EVT::getIntegerVT(*DAG.getContext(), SmallVTBits);
+    if (NElts != 0)
+      SmallVT = EVT::getVectorVT(*DAG.getContext(), SmallVT, NElts);
+
     if (TLI.isTruncateFree(Op.getValueType(), SmallVT) &&
         TLI.isZExtFree(SmallVT, Op.getValueType())) {
       // We found a type with free casts.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D3163.2.patch
Type: text/x-patch
Size: 1982 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20140404/4a301b77/attachment.bin>


More information about the llvm-commits mailing list