Add an assert so we don't silently miscompile ctpop for bit widths > 128.
authorBenjamin Kramer <benny.kra@googlemail.com>
Sat, 15 Jan 2011 21:19:37 +0000 (21:19 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Sat, 15 Jan 2011 21:19:37 +0000 (21:19 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123549 91177308-0d34-0410-b5e6-96231b3b80d8

lib/CodeGen/SelectionDAG/LegalizeDAG.cpp

index 3a29424d07010f17f1a1d2ab7f602f7c8814df85..477cf093f106c21bbd2d1910e2f5dcb77a6d8420 100644 (file)
@@ -2389,6 +2389,7 @@ SDValue SelectionDAGLegalize::ExpandBSWAP(SDValue Op, DebugLoc dl) {
 }
 
 /// 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 @@ SDValue SelectionDAGLegalize::ExpandBitCount(unsigned Opc, SDValue Op,
     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