[DAG] SelectionDAG::MaskedElementsAreZero - assert we're calling with a vector. NFCI.
authorSimon Pilgrim <llvm-dev@redking.me.uk>
Fri, 16 Jul 2021 11:05:05 +0000 (12:05 +0100)
committerSimon Pilgrim <llvm-dev@redking.me.uk>
Fri, 16 Jul 2021 16:43:35 +0000 (17:43 +0100)
Add an assertion that we've calling MaskedElementsAreZero with a vector op and that the DemandedElts arg is a matching width.

Makes the error a lot easier to grok when something else accidentally gets used.

llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp

index e194e1b..8886a2d 100644 (file)
@@ -2450,6 +2450,10 @@ bool SelectionDAG::MaskedValueIsZero(SDValue V, const APInt &Mask,
 /// use this predicate to simplify operations downstream.
 bool SelectionDAG::MaskedElementsAreZero(SDValue Op, const APInt &DemandedElts,
                                          unsigned Depth) const {
+  assert(Op.getValueType().isFixedLengthVector() &&
+         Op.getValueType().getVectorNumElements() ==
+             DemandedElts.getBitWidth() &&
+         "MaskedElementsAreZero vector size mismatch");
   unsigned BitWidth = Op.getScalarValueSizeInBits();
   APInt DemandedBits = APInt::getAllOnesValue(BitWidth);
   return MaskedValueIsZero(Op, DemandedBits, DemandedElts, Depth);