[llvm] [Scalarizer][DirectX] support structs return types (PR #111569)
Tex Riddell via llvm-commits
llvm-commits at lists.llvm.org
Thu Oct 17 13:08:21 PDT 2024
================
@@ -667,14 +686,26 @@ bool ScalarizerVisitor::splitBinary(Instruction &I, const Splitter &Split) {
bool ScalarizerVisitor::isTriviallyScalarizable(Intrinsic::ID ID) {
if (isTriviallyVectorizable(ID))
return true;
+ // TODO: Move frexp to isTriviallyVectorizable.
+ // https://github.com/llvm/llvm-project/issues/112408
+ switch (ID) {
+ case Intrinsic::frexp:
+ return true;
+ }
return Intrinsic::isTargetIntrinsic(ID) &&
TTI->isTargetIntrinsicTriviallyScalarizable(ID);
}
/// If a call to a vector typed intrinsic function, split into a scalar call per
/// element if possible for the intrinsic.
bool ScalarizerVisitor::splitCall(CallInst &CI) {
- std::optional<VectorSplit> VS = getVectorSplit(CI.getType());
+ Type *CallType = CI.getType();
+ bool AreAllMatchingVectors = isStructOfMatchingFixedVectors(CallType);
+ std::optional<VectorSplit> VS;
+ if (AreAllMatchingVectors)
+ VS = getVectorSplit(CallType->getContainedType(0));
----------------
tex3d wrote:
`isVectorIntrinsicWithOverloadTypeAtArg` defaults to returning true for `-1` because it's the common case for intrinsic overloads to be based on the return type when it matches the other arguments, but the exceptions are informative. Some of these return true for indices -1 and 0, which means the intrinsic has two overload types, one based on the return type, and one based on the first argument. Another (`is_fpclass`) returns true only for index 0, which means the overload is based on the first argument, not the return type.
This calls `isVectorIntrinsicWithOverloadTypeAtArg` with `-1` to determine whether the first return type in the struct is used in the overload, then (see my reply to the other comment), we just assume any others that don't match the previous type in that struct are also added to the overload. I don't think this is correct for the general case. I think `isVectorIntrinsicWithOverloadTypeAtArg` should be augmented to support individually addressing the fields of the returned struct. One way would be to extend into the negative space for indices: -1, -2, -3 would refer to three fields in a returned struct, in that order.
https://github.com/llvm/llvm-project/pull/111569
More information about the llvm-commits
mailing list