[llvm] [Scalarizer][DirectX] support structs return types (PR #111569)

Farzon Lotfi via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 18 13:04:11 PDT 2024


================
@@ -699,6 +730,20 @@ bool ScalarizerVisitor::splitCall(CallInst &CI) {
   if (isVectorIntrinsicWithOverloadTypeAtArg(ID, -1))
     Tys.push_back(VS->SplitTy);
 
+  if (AreAllVectorsOfMatchingSize) {
+    for (unsigned I = 1; I < CallType->getNumContainedTypes(); I++) {
+      if (isVectorIntrinsicWithStructReturnOverloadAtField(ID, I)) {
+        std::optional<VectorSplit> CurrVS = getVectorSplit(
+            cast<FixedVectorType>(CallType->getContainedType(I)));
+        // This case does not seem to happen, but it is possible for
+        // VectorSplit.NumPacked >= NumElems. If that happens a VectorSplit
+        // is not returned and we will bailout of handling this call.
+        if (!CurrVS)
+          return false;
+        Tys.push_back(CurrVS->SplitTy);
+      }
----------------
farzonl wrote:

`CurrVS->NumPacked != VS->NumPacked`. doesn't seem right. Because  frexp first out param can be half, float, or double. the second out param is  an int 32. 

`NumPacked = ScalarizeMinBits / ElemTy->getScalarSizeInBits()`

By default, we won't notice this break because `ScalarizeMinBits ` is an option parameter set to 0. and its integer division. but if the option `ScalarizeMinBits`  is set high enough we will notice a difference in behavior.

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


More information about the llvm-commits mailing list