[llvm] [X86] Add verifyTargetSDNode for x86 target specific nodes (PR #123589)
Simon Pilgrim via llvm-commits
llvm-commits at lists.llvm.org
Tue Jan 21 06:05:53 PST 2025
================
@@ -61009,3 +61009,31 @@ Align X86TargetLowering::getPrefLoopAlignment(MachineLoop *ML) const {
return Align(1ULL << ExperimentalPrefInnermostLoopAlignment);
return TargetLowering::getPrefLoopAlignment();
}
+
+#ifndef NDEBUG
+void X86TargetLowering::verifyTargetSDNode(const SDNode *N) const {
+ switch (N->getOpcode()) {
+ default:
+ break;
+ case X86ISD::KSHIFTL:
+ case X86ISD::KSHIFTR: {
+ EVT VT = N->getValueType(0);
+ auto *Amt = cast<ConstantSDNode>(N->getOperand(1));
+ assert(Amt->getAPIntValue().ult(VT.getVectorNumElements()) &&
+ "Out of range KSHIFT shift amount");
+ break;
+ }
+ case X86ISD::PSADBW: {
+ EVT VT = N->getValueType(0);
+ SDValue LHS = N->getOperand(0);
+ SDValue RHS = N->getOperand(1);
+ assert((VT == MVT::v2i64 || VT == MVT::v4i64 || VT == MVT::v8i64) &&
+ LHS.getValueType() == RHS.getValueType() &&
+ LHS.getValueSizeInBits() == VT.getSizeInBits() &&
+ LHS.getValueType().getScalarType() == MVT::i8 &&
----------------
RKSimon wrote:
That would only check at selection - it'd be nice to be able to auto generate these checks for verifyTargetSDNode but it'd be a rather large job.
What I'm finding is that verifyTargetSDNode is fantastic for tracing problems, especially during debugging, as its called as part of getNode() - so the assertion occurs in the code stack where the node is created - we have some similar asserts in the node combines / known bits etc. but working out where the node came from isn't always straightforward (or requires trawling through logs).
I'm tempted to remove the equivalent asserts from other locations as verifyTargetSDNode should have caught most cases.
https://github.com/llvm/llvm-project/pull/123589
More information about the llvm-commits
mailing list