[llvm] [RISCV] Generate QC_INSB/QC_INSBI instructions from OR of AND Imm (PR #154023)
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Mon Aug 18 21:22:58 PDT 2025
================
@@ -720,6 +720,63 @@ bool RISCVDAGToDAGISel::trySignedBitfieldInsertInMask(SDNode *Node) {
return true;
}
+// Generate a QC_INSB/QC_INSBI from 'or (and X, MaskImm), OrImm' iff the value
+// being inserted only sets known zero bits.
+bool RISCVDAGToDAGISel::tryBitfieldInsertOpFromOrAndImm(SDNode *Node) {
+ // Supported only in Xqcibm for now.
+ if (!Subtarget->hasVendorXqcibm())
+ return false;
+
+ using namespace SDPatternMatch;
+
+ SDValue And;
+ APInt MaskImm, OrImm;
+ if (!sd_match(Node, m_Or(m_OneUse(m_And(m_Value(And), m_ConstInt(MaskImm))),
+ m_ConstInt(OrImm))))
+ return false;
+
+ // Compute the Known Zero for the AND as this allows us to catch more general
+ // cases than just looking for AND with imm.
+ KnownBits Known = CurDAG->computeKnownBits(Node->getOperand(0));
+
+ // Non-zero in the sense that they're not provably zero, which is the key
+ // point if we want to use this value.
+ APInt NotKnownZero = ~Known.Zero;
----------------
topperc wrote:
NotKnownZero is unused now
https://github.com/llvm/llvm-project/pull/154023
More information about the llvm-commits
mailing list