Skip to content
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

[LLVM][SelectionDAGBuilder] Add initial DAG for target("aarch64.svcount") constants to the node cache. #126089

Closed
wants to merge 1 commit into from

Conversation

dlee992
Copy link

@dlee992 dlee992 commented Feb 6, 2025

#126089 forgot to update NodeMap when building the initial DAG, which could result in duplicate identical nodes.

Copy link

github-actions bot commented Feb 6, 2025

Thank you for submitting a Pull Request (PR) to the LLVM Project!

This PR will be automatically labeled and the relevant teams will be notified.

If you wish to, you can add reviewers by using the "Reviewers" section on this page.

If this is not working for you, it is probably because you do not have write permissions for the repository. In which case you can instead tag reviewers by name in a comment by using @ followed by their GitHub username.

If you have received no comments on your PR for a week, you can request a review by "ping"ing the PR by adding a comment “Ping”. The common courtesy "ping" rate is once a week. Please remember that you are asking for valuable time from other developers.

If you have further questions, they may be answered by the LLVM GitHub User Guide.

You can also ask questions in a comment on this PR, on the LLVM Discord or on the forums.

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

llvmbot commented Feb 6, 2025

@llvm/pr-subscribers-llvm-selectiondag

Author: Da Li (李达) (dlee992)

Changes

As title.
This PR comes from the discussion here: #69321 (comment).
I am willing to address any further comments/suggestions!

cc @paulwalker-arm


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

1 Files Affected:

  • (modified) llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp (+3-2)
diff --git a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
index 4e1ce6af3abc84..2c175ff621bea0 100644
--- a/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
@@ -1893,8 +1893,9 @@ SDValue SelectionDAGBuilder::getValueImpl(const Value *V) {
 
     if (VT == MVT::aarch64svcount) {
       assert(C->isNullValue() && "Can only zero this target type!");
-      return DAG.getNode(ISD::BITCAST, getCurSDLoc(), VT,
-                         DAG.getConstant(0, getCurSDLoc(), MVT::nxv16i1));
+      return NodeMap[V] =
+                 DAG.getNode(ISD::BITCAST, getCurSDLoc(), VT,
+                             DAG.getConstant(0, getCurSDLoc(), MVT::nxv16i1));
     }
 
     if (VT.isRISCVVectorTuple()) {

@paulwalker-arm
Copy link
Collaborator

@dlee992 - Would you like me to merge this PR?

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.

Testcase?

@paulwalker-arm
Copy link
Collaborator

paulwalker-arm commented Feb 11, 2025

Is a test case necessary? It's an obvious non-breaking omission that I wouldn't have written a test case for if I had not originally omitted the code.

@arsenm
Copy link
Contributor

arsenm commented Feb 11, 2025

Description needs to be fixed, I don't understand the point of this and commit message reading shouldn't require parsing through some other thread

@dlee992
Copy link
Author

dlee992 commented Feb 11, 2025

I think this PR doesn't need a new testcase, since #69321 has added the needed test cases.

I updated the PR description, hope it's good to go.

@arsenm
Copy link
Contributor

arsenm commented Feb 11, 2025

The description still doesn't state what issue this is solving

@paulwalker-arm paulwalker-arm changed the title [SVE ACLE] Add NodeMap[V] for svcount in SelectionDAGBuilder [LLVM][SelectionDAGBuilder] Add initial DAG for target("aarch64.svcount") constants to the node cache. Feb 11, 2025
@topperc
Copy link
Collaborator

topperc commented Feb 12, 2025

Wouldn't SelectionDAG CSE the duplicate nodes anyway? So at best this is probably a cheaper cache than the FoldingSet used for CSE?

@topperc
Copy link
Collaborator

topperc commented Feb 12, 2025

Both of the callers of ValueImpl write the return value to NodeMap. Now I'm not sure why there are any writes to NodeMap in this function.

Copy link
Collaborator

@topperc topperc left a comment

Choose a reason for hiding this comment

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

I don't think this patch is needed and I'm going to remove the other NodeMap updates from getValueImpl. Patch #126849

@dlee992
Copy link
Author

dlee992 commented Feb 12, 2025

Both of the callers of ValueImpl write the return value to NodeMap. Now I'm not sure why there are any writes to NodeMap in this function.

I think you're right! I will close this wrong patch.

@dlee992 dlee992 closed this Feb 12, 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.

5 participants