summaryrefslogtreecommitdiffstats
path: root/llvm/lib/CodeGen/SelectionDAG
diff options
context:
space:
mode:
authorBenjamin Kramer <benny.kra@googlemail.com>2011-01-15 21:19:37 +0000
committerBenjamin Kramer <benny.kra@googlemail.com>2011-01-15 21:19:37 +0000
commitbec03ea725a09c91d13ddc8c4ab63a81762172a3 (patch)
treeed76dd1898d5d90be7649146a22f84dc29a161fc /llvm/lib/CodeGen/SelectionDAG
parent94b2ab3556a6b4f0f78720f494bdb4cff243c419 (diff)
downloadbcm5719-llvm-bec03ea725a09c91d13ddc8c4ab63a81762172a3.tar.gz
bcm5719-llvm-bec03ea725a09c91d13ddc8c4ab63a81762172a3.zip
Add an assert so we don't silently miscompile ctpop for bit widths > 128.
llvm-svn: 123549
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG')
-rw-r--r--llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp4
1 files changed, 4 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
index 3a29424d070..477cf093f10 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeDAG.cpp
@@ -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
OpenPOWER on IntegriCloud