[llvm] [SDAG] Fix llvm.modf for ppc_fp128 (attempt two) (PR #127976)
Benjamin Maxwell via llvm-commits
llvm-commits at lists.llvm.org
Thu Feb 20 04:24:14 PST 2025
================
@@ -435,8 +435,21 @@ bool DAGTypeLegalizer::run() {
#endif
PerformExpensiveChecks();
- // If the root changed (e.g. it was a dead load) update the root.
- DAG.setRoot(Dummy.getValue());
+ // Get the value of the original root after type legalization.
+ SDValue Root = Dummy.getValue();
+
+ // Get the current root value, if it's not null combine it with the original
+ // root to prevent it being removed as a dead node.
+ if (SDValue LegalRoot = DAG.getRoot()) {
+ Root = DAG.getNode(ISD::TokenFactor, SDLoc(LegalRoot), MVT::Other, Root,
+ LegalRoot);
+ // The token_factor should not need any legalization (as both inputs have
+ // already been legalized).
+ Root->setNodeId(Processed);
+ }
+
+ // Restore the root.
+ DAG.setRoot(Root);
----------------
MacDue wrote:
Any thoughts? I can't think of an obvious way to avoid the need of the workaround for the expansion of `modf` and `frexp`, and I don't think it's safe to do if LegalizeTypes types just blindly ignores any changes to the root.
https://github.com/llvm/llvm-project/pull/127976
More information about the llvm-commits
mailing list