[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 01:04:49 PDT 2026
Juan Manuel Martinez =?utf-8?q?CaamaƱo?= <juamarti at amd.com>
Message-ID:
In-Reply-To: <llvm.org/llvm/llvm-project/pull/213721 at github.com>
================
@@ -814,6 +814,12 @@ static Constant *getConstantFloatVector(const ArrayRef<APFloat> Values,
APF.convert(FltSem, APFloat::rmNearestTiesToEven, &Unused);
ConstValues.push_back(ConstantFP::get(ElemTy, APF));
}
+
+ if (!Ty->isVectorTy()) {
+ assert(Values.size() == 1 && "Expected exactly one constant value");
----------------
steffenlarsen wrote:
This may be even better as a generalized check at the beginning of the function, e.g.:
```c++
assert(Values.size() == Ty->isVectorTy() ? dyn_cast<VectorType>(Ty)->getElementCount() : 1, "Unexpected number of constant values.");
```
This wouldn't work for scalable vectors (though I'm not sure we even support those here), so it could also be made into a couple of asserts:
```c++
assert(Ty->isSingleValueType(), "Type must either be a scalar or a vector.");
assert(!Ty->isVectorType() || Ty->isScalableTy() || Values.size() == cast<FixedVectorType>(Ty)->getNumElements(), "Unexpected number of constant values.");
assert(Ty->isVectorType() || Values.size() == 1, "Expected exactly one constant value");
```
https://github.com/llvm/llvm-project/pull/213721
More information about the llvm-commits
mailing list