Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

[DAGCombiner] Remove hasOneUse check from sext+sext_inreg to sext_inreg combine #140207

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 16, 2025

Conversation

Pierre-vh
Copy link
Contributor

The hasOneUseCheck does not really add anything and makes the combine too
restrictive. Upcoming patches benefit from removing the hasOneUse check.

Copy link
Contributor Author

Pierre-vh commented May 16, 2025

@Pierre-vh Pierre-vh requested review from arsenm, jayfoad and shiltian May 16, 2025 07:22
@Pierre-vh Pierre-vh marked this pull request as ready for review May 16, 2025 07:23
@llvmbot llvmbot added the llvm:SelectionDAG SelectionDAGISel as well label May 16, 2025
@llvmbot
Copy link
Member

llvmbot commented May 16, 2025

@llvm/pr-subscribers-llvm-selectiondag

Author: Pierre van Houtryve (Pierre-vh)

Changes

The hasOneUseCheck does not really add anything and makes the combine too
restrictive. Upcoming patches benefit from removing the hasOneUse check.


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

1 Files Affected:

  • (modified) llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp (+1-1)
diff --git a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
index d6e288a59b2ee..79949bb6d37a0 100644
--- a/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/DAGCombiner.cpp
@@ -14101,7 +14101,7 @@ SDValue DAGCombiner::visitSIGN_EXTEND(SDNode *N) {
       }
 
       // If the trunc wasn't legal, try to fold to (sext_inreg (anyext x))
-      if ((!LegalTypes || TLI.isTypeLegal(VT)) && N0.hasOneUse()) {
+      if (!LegalTypes || TLI.isTypeLegal(VT)) {
         SDValue ExtSrc = DAG.getAnyExtOrTrunc(N00, DL, VT);
         return DAG.getNode(ISD::SIGN_EXTEND_INREG, DL, VT, ExtSrc,
                            N0->getOperand(1));

@@ -14101,7 +14101,7 @@ SDValue DAGCombiner::visitSIGN_EXTEND(SDNode *N) {
}

// If the trunc wasn't legal, try to fold to (sext_inreg (anyext x))
if ((!LegalTypes || TLI.isTypeLegal(VT)) && N0.hasOneUse()) {
if (!LegalTypes || TLI.isTypeLegal(VT)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

There are no test changes, but in the next PR some tests would regress without it, in particular s_test_smed3_i8_pat_0 would have a mix of s_sext_i32_i8 and s_bfe + s_sext_i32_i16 chained together.

Copy link
Contributor

@arsenm arsenm left a comment

Choose a reason for hiding this comment

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

The above truncate case also doesn't have the hasOneUse check

Copy link
Contributor Author

Pierre-vh commented May 16, 2025

Merge activity

  • May 16, 4:09 AM EDT: A user started a stack merge that includes this pull request via Graphite.
  • May 16, 4:20 AM EDT: Graphite rebased this pull request as part of a merge.
  • May 16, 4:23 AM EDT: Graphite rebased this pull request as part of a merge.
  • May 16, 4:25 AM EDT: @Pierre-vh merged this pull request with Graphite.

@Pierre-vh Pierre-vh force-pushed the users/pierre-vh/minmax-dag-i16-promo branch 2 times, most recently from 9ed6224 to c0fbfb3 Compare May 16, 2025 08:14
Base automatically changed from users/pierre-vh/minmax-dag-i16-promo to main May 16, 2025 08:16
@Pierre-vh Pierre-vh force-pushed the users/pierre-vh/sext-comb-hasoneuse branch from aa2e1c7 to cd12b2c Compare May 16, 2025 08:19
…eg combine

The hasOneUseCheck does not really add anything and makes the combine too
restrictive. Upcoming patches benefit from removing the hasOneUse check.
@Pierre-vh Pierre-vh force-pushed the users/pierre-vh/sext-comb-hasoneuse branch from cd12b2c to bb86037 Compare May 16, 2025 08:22
@Pierre-vh Pierre-vh merged commit 5e7bc5e into main May 16, 2025
6 of 9 checks passed
@Pierre-vh Pierre-vh deleted the users/pierre-vh/sext-comb-hasoneuse branch May 16, 2025 08:25
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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.