[llvm] [DAG][X86]added shrd in combineor for bzhiq+shlq+or (PR #125734)

Phoebe Wang via llvm-commits llvm-commits at lists.llvm.org
Thu Mar 20 00:57:37 PDT 2025


================
@@ -51887,6 +51887,47 @@ static SDValue combineOr(SDNode *N, SelectionDAG &DAG,
     }
   }
 
+  if (!Subtarget.isSHLDSlow()) {
+    using namespace llvm::SDPatternMatch;
+    APInt MaskConst, ShlConst;
+    SDValue A, B;
+    if (sd_match(N, m_Or(m_Shl(m_Value(B), m_ConstInt(ShlConst)),
+                         m_And(m_Value(A), m_ConstInt(MaskConst))))) {
+      uint64_t ShiftValue = ShlConst.getZExtValue();
+      if (MaskConst.isMask(ShiftValue) && (A.getOpcode() == ISD::CopyFromReg) &&
+          (B.getOpcode() == ISD::CopyFromReg)) {
----------------
phoebewang wrote:

Why do we need to check CopyFromReg?

https://github.com/llvm/llvm-project/pull/125734


More information about the llvm-commits mailing list