diff options
author | woruyu <99597449+woruyu@users.noreply.github.com> | 2025-07-07 22:04:54 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2025-07-07 15:04:54 +0100 |
commit | c80fa2364beeca4ad75125afa29de3e20b63fbd3 (patch) | |
tree | f3ef5af0549278181deb085834e75f98640d450d /llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | |
parent | acb4fff866f95762b53560bcf7b3a3667e7a41fd (diff) | |
download | llvm-c80fa2364beeca4ad75125afa29de3e20b63fbd3.zip llvm-c80fa2364beeca4ad75125afa29de3e20b63fbd3.tar.gz llvm-c80fa2364beeca4ad75125afa29de3e20b63fbd3.tar.bz2 |
[DAG] SDPatternMatch m_Zero/m_One/m_AllOnes have inconsistent undef h… (#147044)
### Summary
This PR resolves https://github.com/llvm/llvm-project/issues/146871
This PR resolves https://github.com/llvm/llvm-project/issues/140745
Refactor m_Zero/m_One/m_AllOnes all use struct template function to
match and AllowUndefs=false as default.
Diffstat (limited to 'llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp')
-rw-r--r-- | llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp index a0f4c49..2a8bda5 100644 --- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp +++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAG.cpp @@ -12644,6 +12644,18 @@ bool llvm::isAllOnesOrAllOnesSplat(SDValue N, bool AllowUndefs) { return C && C->isAllOnes() && C->getValueSizeInBits(0) == BitWidth; } +bool llvm::isOnesOrOnesSplat(SDValue N, bool AllowUndefs) { + ConstantSDNode *C = isConstOrConstSplat(N, AllowUndefs); + return C && APInt::isSameValue(C->getAPIntValue(), + APInt(C->getAPIntValue().getBitWidth(), 1)); +} + +bool llvm::isZeroOrZeroSplat(SDValue N, bool AllowUndefs) { + N = peekThroughBitcasts(N); + ConstantSDNode *C = isConstOrConstSplat(N, AllowUndefs, true); + return C && C->isZero(); +} + HandleSDNode::~HandleSDNode() { DropOperands(); } |