[llvm] [SDAG] Honor signed arguments in floating point libcalls (PR #109134)

Timothy Pearson via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 20 08:24:03 PDT 2024


================
@@ -2205,7 +2205,24 @@ void SelectionDAGLegalize::ExpandFPLibCall(SDNode* Node,
     Results.push_back(Tmp.first);
     Results.push_back(Tmp.second);
   } else {
-    SDValue Tmp = ExpandLibCall(LC, Node, false).first;
+    bool IsSignedArgument = false;
+    switch (LC) {
+    case RTLIB::LDEXP_F32:
+    case RTLIB::LDEXP_F64:
+    case RTLIB::LDEXP_F80:
+    case RTLIB::LDEXP_F128:
+    case RTLIB::LDEXP_PPCF128:
+      IsSignedArgument = true;
+      break;
+    case RTLIB::FREXP_F32:
+    case RTLIB::FREXP_F64:
+    case RTLIB::FREXP_F80:
+    case RTLIB::FREXP_F128:
+    case RTLIB::FREXP_PPCF128:
+      IsSignedArgument = true;
+      break;
----------------
tpearson-ssc wrote:

> It has an int* out argument, but not sure how that would come in here

I wanted to be thorough, I figured if there was a potential for sign/zero extension confusion in argument passing there could be similar potential for confusion in the return path.  The test case I put together basically runs frexp and attempts to extend the value stored in the i32 pointer back out to an i64.

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


More information about the llvm-commits mailing list