[llvm-commits] [llvm] r53556 - /llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp

Duncan Sands baldrick at free.fr
Mon Jul 14 10:32:02 PDT 2008


Author: baldrick
Date: Mon Jul 14 12:32:02 2008
New Revision: 53556

URL: http://llvm.org/viewvc/llvm-project?rev=53556&view=rev
Log:
An INSERT_VECTOR_ELT can insert a larger value
than the vector element type.  Don't forget to
handle this when the insertion index is not a
constant.

Modified:
    llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp?rev=53556&r1=53555&r2=53556&view=diff

==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeVectorTypes.cpp Mon Jul 14 12:32:02 2008
@@ -360,13 +360,14 @@
 
   // Spill the vector to the stack.
   MVT VecVT = Vec.getValueType();
+  MVT EltVT = VecVT.getVectorElementType();
   SDOperand StackPtr = DAG.CreateStackTemporary(VecVT);
   SDOperand Store = DAG.getStore(DAG.getEntryNode(), Vec, StackPtr, NULL, 0);
 
-  // Store the new element.
-  SDOperand EltPtr = GetVectorElementPointer(StackPtr,
-                                             VecVT.getVectorElementType(), Idx);
-  Store = DAG.getStore(Store, Elt, EltPtr, NULL, 0);
+  // Store the new element.  This may be larger than the vector element type,
+  // so use a truncating store.
+  SDOperand EltPtr = GetVectorElementPointer(StackPtr, EltVT, Idx);
+  Store = DAG.getTruncStore(Store, Elt, EltPtr, NULL, 0, EltVT);
 
   // Reload the vector from the stack.
   SDOperand Load = DAG.getLoad(VecVT, Store, StackPtr, NULL, 0);





More information about the llvm-commits mailing list