Skip to content

Conversation

@Rajveer100
Copy link
Member

@Rajveer100 Rajveer100 commented Mar 2, 2025

No description provided.

@llvmbot llvmbot added the llvm:SelectionDAG SelectionDAGISel as well label Mar 2, 2025
@llvmbot
Copy link
Member

llvmbot commented Mar 2, 2025

@llvm/pr-subscribers-llvm-selectiondag

Author: Rajveer Singh Bharadwaj (Rajveer100)

Changes

Resolves #129034


Full diff: https://github.com/llvm/llvm-project/pull/129431.diff

1 Files Affected:

  • (modified) llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (+7)
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index 8c51cb3af6142..805c1eec6cac0 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -8528,6 +8528,13 @@ SDValue DAGCombiner::MatchFunnelPosNeg(SDValue N0, SDValue N1, SDValue Pos,
       return DAG.getNode(ISD::FSHL, DL, VT, N0, N1.getOperand(0), Pos);
     }
 
+    SDValue X1, Y;
+    if (sd_match(N1, m_Srl(X1, m_SpecificInt(1))) &&
+        sd_match(InnerNeg, m_Xor(Y, m_SpecificInt(EltBits - 1))) &&
+        Y == InnerPos && TLI.isOperationLegalOrCustom(ISD::FSHL, VT)) {
+      return DAG.getNode(ISD::FSHL, DL, VT, N0, N1.getOperand(0), Pos);
+    }
+
     // fold (or (shl (shl x0, 1), (xor y, 31)), (srl x1, y))
     //   -> (fshr x0, x1, y)
     if (IsBinOpImm(N0, ISD::SHL, 1) &&

@Rajveer100
Copy link
Member Author

@RKSimon
I am not quite sure if this is in the right direction.

@dtcxzyw dtcxzyw requested a review from RKSimon March 2, 2025 16:06

SDValue X1, Y;
if (sd_match(N1, m_Srl(X1, m_SpecificInt(1))) &&
sd_match(InnerNeg, m_Xor(Y, m_SpecificInt(EltBits - 1))) &&
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can remove Y and use m_Specific(InnerPos)

InnerPos == InnerNeg.getOperand(0) &&
TLI.isOperationLegalOrCustom(ISD::FSHL, VT)) {
return DAG.getNode(ISD::FSHL, DL, VT, N0, N1.getOperand(0), Pos);
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be removed entirely

if (sd_match(N1, m_Srl(X1, m_SpecificInt(1))) &&
sd_match(InnerNeg, m_Xor(Y, m_SpecificInt(EltBits - 1))) &&
Y == InnerPos && TLI.isOperationLegalOrCustom(ISD::FSHL, VT)) {
return DAG.getNode(ISD::FSHL, DL, VT, N0, N1.getOperand(0), Pos);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

N1.getOperand(0) -> X1

}

SDValue X1, Y;
if (sd_match(N1, m_Srl(X1, m_SpecificInt(1))) &&
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

X1 -> m_Value(X1)

@RKSimon RKSimon closed this Mar 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

llvm:SelectionDAG SelectionDAGISel as well

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants