[llvm] [SelectionDAG] powi and ldexp libcalls deal with signed int arguments (PR #213673)

via llvm-commits llvm-commits at lists.llvm.org
Mon Aug 3 06:36:53 PDT 2026


llvmorg-github-actions[bot] wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-selectiondag

Author: Simonas Kazlauskas (nagisa)

<details>
<summary>Changes</summary>

While investigating a sign extension problem on an off-tree target that needs extension of 32-bit integer argument to 64-bit register when passed as an argument, I found that `__powisf2` was being passed zero-extended despite the argument being a signed `int`. I narrowed this down to the fact that `shouldSignExtendTypeInLibCall` was being passed `false` for `IsSigned` for the `int` argument in these libcalls.

Other libcalls (not an exhaustive review) such as the `XINT_TO_FP` family do set the `IsSigned` value here.

I would write an unit test, but I'm not familiar with any in-tree target that would help me expose this problem… None of the existing in-tree tests are otherwise affected to the best of my knowledge.

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


1 Files Affected:

- (modified) llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp (+1) 


``````````diff
diff --git a/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp b/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
index d0a29b5365daa..226da8ac24436 100644
--- a/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
+++ b/llvm/lib/CodeGen/SelectionDAG/LegalizeFloatTypes.cpp
@@ -764,6 +764,7 @@ SDValue DAGTypeLegalizer::SoftenFloatRes_ExpOp(SDNode *N) {
   EVT OpsVT[2] = { N->getOperand(0 + Offset).getValueType(),
                    N->getOperand(1 + Offset).getValueType() };
   CallOptions.setTypeListBeforeSoften(OpsVT, N->getValueType(0));
+  CallOptions.setIsSigned();
   std::pair<SDValue, SDValue> Tmp = TLI.makeLibCall(DAG, LC, NVT, Ops,
                                                     CallOptions, SDLoc(N),
                                                     Chain);

``````````

</details>


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


More information about the llvm-commits mailing list