[llvm-commits] [llvm] r123549 - /llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

Benjamin Kramer benny.kra at googlemail.com
Sat Jan 15 13:19:37 PST 2011


Author: d0k
Date: Sat Jan 15 15:19:37 2011
New Revision: 123549

URL: http://llvm.org/viewvc/llvm-project?rev=123549&view=rev
Log:
Add an assert so we don't silently miscompile ctpop for bit widths > 128.

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

Modified: llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp?rev=123549&r1=123548&r2=123549&view=diff
==============================================================================
--- llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp (original)
+++ llvm/trunk/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp Sat Jan 15 15:19:37 2011
@@ -2389,6 +2389,7 @@
 }
 
 /// SplatByte - Distribute ByteVal over NumBits bits.
+// FIXME: Move this helper to a common place.
 static APInt SplatByte(unsigned NumBits, uint8_t ByteVal) {
   APInt Val = APInt(NumBits, ByteVal);
   unsigned Shift = 8;
@@ -2410,6 +2411,9 @@
     EVT ShVT = TLI.getShiftAmountTy();
     unsigned Len = VT.getSizeInBits();
 
+    assert(VT.isInteger() && Len <= 128 && Len % 8 == 0 &&
+           "CTPOP not implemented for this type.");
+
     // This is the "best" algorithm from
     // http://graphics.stanford.edu/~seander/bithacks.html#CountBitsSetParallel
 





More information about the llvm-commits mailing list