Skip to content

Commit

Permalink
[NFC][llvm][Hexagon] Inclusive Terms remove uses of sanity in Hexagon…
Browse files Browse the repository at this point in the history
… taget

Most changes are rewording comments but there are some assertions that I rephrased.

Reviewed By: kparzysz

Differential Revision: https://reviews.llvm.org/D114132
  • Loading branch information
ZarkoT committed Nov 22, 2021
1 parent 137d347 commit dc9b555
Show file tree
Hide file tree
Showing 12 changed files with 17 additions and 18 deletions.
4 changes: 2 additions & 2 deletions llvm/lib/Target/Hexagon/BitTracker.cpp
Expand Up @@ -214,9 +214,9 @@ bool BT::RegisterCell::meet(const RegisterCell &RC, Register SelfR) {
BT::RegisterCell &BT::RegisterCell::insert(const BT::RegisterCell &RC,
const BitMask &M) {
uint16_t B = M.first(), E = M.last(), W = width();
// Sanity: M must be a valid mask for *this.
// M must be a valid mask for *this.
assert(B < W && E < W);
// Sanity: the masked part of *this must have the same number of bits
// The masked part of *this must have the same number of bits
// as the source.
assert(B > E || E-B+1 == RC.width()); // B <= E => E-B+1 = |RC|.
assert(B <= E || E+(W-B)+1 == RC.width()); // E < B => E+(W-B)+1 = |RC|.
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/Hexagon/HexagonBitTracker.cpp
Expand Up @@ -189,7 +189,7 @@ bool HexagonEvaluator::evaluate(const MachineInstr &MI,

unsigned NumDefs = 0;

// Sanity verification: there should not be any defs with subregisters.
// Basic correctness check: there should not be any defs with subregisters.
for (const MachineOperand &MO : MI.operands()) {
if (!MO.isReg() || !MO.isDef())
continue;
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/Hexagon/HexagonConstExtenders.cpp
Expand Up @@ -1254,7 +1254,7 @@ void HCE::collect(MachineFunction &MF) {

void HCE::assignInits(const ExtRoot &ER, unsigned Begin, unsigned End,
AssignmentMap &IMap) {
// Sanity check: make sure that all extenders in the range [Begin..End)
// Basic correctness: make sure that all extenders in the range [Begin..End)
// share the same root ER.
for (unsigned I = Begin; I != End; ++I)
assert(ER == ExtRoot(Extenders[I].getOp()));
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/Hexagon/HexagonGenInsert.cpp
Expand Up @@ -1501,7 +1501,7 @@ bool HexagonGenInsert::runOnMachineFunction(MachineFunction &MF) {
bool Timing = OptTiming, TimingDetail = Timing && OptTimingDetail;
bool Changed = false;

// Sanity check: one, but not both.
// Verify: one, but not both.
assert(!OptSelectAll0 || !OptSelectHas0);

IFMap.clear();
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/Hexagon/HexagonGenMux.cpp
Expand Up @@ -328,7 +328,7 @@ bool HexagonGenMux::genMuxInBlock(MachineBasicBlock &B) {
unsigned MxOpc = getMuxOpcode(*MX.SrcT, *MX.SrcF);
if (!MxOpc)
continue;
// Basic sanity check: since we are deleting instructions, validate the
// Basic correctness check: since we are deleting instructions, validate the
// iterators. There is a possibility that one of Def1 or Def2 is translated
// to "mux" and being considered for other "mux" instructions.
if (!MX.At->getParent() || !MX.Def1->getParent() || !MX.Def2->getParent())
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/Hexagon/HexagonGenPredicate.cpp
Expand Up @@ -411,7 +411,7 @@ bool HexagonGenPredicate::convertToPredForm(MachineInstr *MI) {
NumOps = 2;
}

// Some sanity: check that def is in operand #0.
// Check that def is in operand #0.
MachineOperand &Op0 = MI->getOperand(0);
assert(Op0.isDef());
RegisterSubReg OutR(Op0);
Expand Down
2 changes: 1 addition & 1 deletion llvm/lib/Target/Hexagon/HexagonHardwareLoops.cpp
Expand Up @@ -1123,7 +1123,7 @@ void HexagonHardwareLoops::removeIfDead(MachineInstr *MI) {
bool HexagonHardwareLoops::convertToHardwareLoop(MachineLoop *L,
bool &RecL0used,
bool &RecL1used) {
// This is just for sanity.
// This is just to confirm basic correctness.
assert(L->getHeader() && "Loop without a header?");

bool Changed = false;
Expand Down
8 changes: 4 additions & 4 deletions llvm/lib/Target/Hexagon/HexagonISelDAGToDAGHVX.cpp
Expand Up @@ -1006,7 +1006,7 @@ static void packSegmentMask(ArrayRef<int> Mask, ArrayRef<unsigned> OutSegMap,

static bool isPermutation(ArrayRef<int> Mask) {
// Check by adding all numbers only works if there is no overflow.
assert(Mask.size() < 0x00007FFF && "Sanity failure");
assert(Mask.size() < 0x00007FFF && "Overflow failure");
int Sum = 0;
for (int Idx : Mask) {
if (Idx == -1)
Expand Down Expand Up @@ -1217,7 +1217,7 @@ OpRef HvxSelector::packs(ShuffleMask SM, OpRef Va, OpRef Vb,
} else if (Seg0 == ~1u) {
Seg0 = SegList[0] != Seg1 ? SegList[0] : SegList[1];
} else {
assert(Seg1 == ~1u); // Sanity
assert(Seg1 == ~1u);
Seg1 = SegList[0] != Seg0 ? SegList[0] : SegList[1];
}
}
Expand Down Expand Up @@ -1265,7 +1265,7 @@ OpRef HvxSelector::packs(ShuffleMask SM, OpRef Va, OpRef Vb,
} else {
// BC or DA: this could be done via valign by SegLen.
// Do nothing here, because valign (if possible) will be generated
// later on (make sure the Seg0 values are as expected, for sanity).
// later on (make sure the Seg0 values are as expected).
assert(Seg0 == 1 || Seg0 == 3);
}
}
Expand Down Expand Up @@ -1414,7 +1414,7 @@ OpRef HvxSelector::shuffs1(ShuffleMask SM, OpRef Va, ResultStack &Results) {
return OpRef::undef(getSingleVT(MVT::i8));

unsigned HalfLen = HwLen / 2;
assert(isPowerOf2_32(HalfLen)); // Sanity.
assert(isPowerOf2_32(HalfLen));

// Handle special case where the output is the same half of the input
// repeated twice, i.e. if Va = AB, then handle the output of AA or BB.
Expand Down
6 changes: 3 additions & 3 deletions llvm/lib/Target/Hexagon/HexagonISelLowering.cpp
Expand Up @@ -2549,7 +2549,8 @@ HexagonTargetLowering::extractVector(SDValue VecV, SDValue IdxV,
// Special case for v{8,4,2}i1 (the only boolean vectors legal in Hexagon
// without any coprocessors).
if (ElemWidth == 1) {
assert(VecWidth == VecTy.getVectorNumElements() && "Sanity failure");
assert(VecWidth == VecTy.getVectorNumElements() &&
"Vector elements should equal vector width size");
assert(VecWidth == 8 || VecWidth == 4 || VecWidth == 2);
// Check if this is an extract of the lowest bit.
if (IdxN) {
Expand Down Expand Up @@ -2863,8 +2864,7 @@ HexagonTargetLowering::LowerCONCAT_VECTORS(SDValue Op,
Scale /= 2;
}

// Another sanity check. At this point there should only be two words
// left, and Scale should be 2.
// At this point there should only be two words left, and Scale should be 2.
assert(Scale == 2 && Words[IdxW].size() == 2);

SDValue WW = DAG.getNode(HexagonISD::COMBINE, dl, MVT::i64,
Expand Down
1 change: 0 additions & 1 deletion llvm/lib/Target/Hexagon/HexagonVectorCombine.cpp
Expand Up @@ -749,7 +749,6 @@ auto AlignVectors::realignGroup(const MoveGroup &Move) const -> bool {
WithMaxAlign.ValTy, Adjust);
int Diff = Start - (OffAtMax + Adjust);
AlignVal = HVC.getConstInt(Diff);
// Sanity.
assert(Diff >= 0);
assert(static_cast<decltype(MinNeeded.value())>(Diff) < MinNeeded.value());
} else {
Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/Hexagon/abi-padding-2.ll
Expand Up @@ -14,7 +14,7 @@
; Test that while passing a 7-byte struct on the stack, the
; size of the struct is 16 bytes including padding since its
; largest member is of type long long. This was being handled
; correctly but is a sanity check against any potential future
; correctly but is a check against any potential future
; regressions.
;

Expand Down
2 changes: 1 addition & 1 deletion llvm/test/CodeGen/Hexagon/pipeliner/swp-phi-start.mir
@@ -1,6 +1,6 @@
# RUN: llc < %s -x mir -march=hexagon -run-pass=modulo-schedule-test -pipeliner-experimental-cg=true | FileCheck %s

# Simple check for this sanity test; ensure all instructions are in stage 0 in
# Simple check for this basic correctness test; ensure all instructions are in stage 0 in
# the prolog and stage 3 in the epilog.

# CHECK-NOT: Stage-3
Expand Down

0 comments on commit dc9b555

Please sign in to comment.