[llvm] [AMDGPU][LibCallSimplify] Use target type's float-semantics in `ConstantFP::get` (PR #213721)

Steffen Larsen via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 6 03:29:09 PDT 2026


Juan Manuel Martinez =?utf-8?q?Caamaño?= <juamarti at amd.com>,
Juan Manuel Martinez =?utf-8?q?Caamaño?=,
Juan Manuel Martinez =?utf-8?q?Caamaño?Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/213721 at github.com>


================
@@ -2017,16 +2023,10 @@ bool AMDGPULibCalls::evaluateCall(CallInst *aCI, const FuncInfo &FInfo) {
     }
   }
 
-  Constant *nval0 = nullptr, *nval1 = nullptr;
-  if (FuncVecSize == 1) {
-    nval0 = ConstantFP::get(aCI->getType(), Val0[0]);
-    if (hasTwoResults)
-      nval1 = ConstantFP::get(aCI->getType(), Val1[0]);
-  } else {
-    nval0 = getConstantFloatVector(Val0, aCI->getType());
-    if (hasTwoResults)
-      nval1 = getConstantFloatVector(Val1, aCI->getType());
-  }
+  Constant *nval0 = getConstantFloat(Val0, aCI->getType());
+  Constant *nval1 = nullptr;
+  if (hasTwoResults)
+    nval1 = getConstantFloat(Val1, aCI->getType());
----------------
steffenlarsen wrote:

> In the end, I've ended up sinking `nval1` closer to its user. Then we have just an assignment and no need for the ternary (it user is guarded by `hasTwoResults`).

Solid improvement. ⭐ 

> I didn't add the `const` because the code gets slightly awkward. Since the pointer is `const`, but not the pointee.

Understandable, it gets very ugly very fast with pointers. I think having moved it to a more controlled use-site is much better anyway, so I can live without the const.

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


More information about the llvm-commits mailing list