[llvm] [SDAG] Add missing float type legalizations for FMODF (PR #128055)

Eli Friedman via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 27 11:55:57 PST 2025


================
@@ -2616,6 +2624,18 @@ bool SelectionDAG::expandMultipleResultFPLibCall(
 
   auto [Call, CallChain] = TLI->LowerCallTo(CLI);
 
+  if (CallRetResNo && !Node->hasAnyUseOfValue(*CallRetResNo)) {
+    // This is needed for x87, which uses a floating-point stack. If (for
----------------
efriedma-quic wrote:

Say you have "ISD::COMPLEX_FDIV", where only the real result is used, and you want to lower it to _complex_fdiv_fp80.  You end up with:

callseq_begin
call _complex_fdiv_fp80
callseq_end
copyfromreg fp0
copyfromreg fp1
use_fp0

the first five nodes are chained together; use_fp0 isn't chained to anything.  So the "copyfromreg fp1" has no uses of either its chain or its value, so it gets deleted.

------

That said, I don't think chain_barrier will actively cause any problems.  If you want to land this without going deeper, please leave a comment referencing this conversation in the code, so if someone revisits later they have context.

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


More information about the llvm-commits mailing list