[PATCH] D94142: [IR] Allow scalable vectors in structs to support intrinsics returning multiple values.

Craig Topper via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Jan 13 16:52:08 PST 2021


craig.topper added inline comments.


================
Comment at: llvm/lib/IR/Type.cpp:398
+    if (auto *STy = dyn_cast<StructType>(Ty))
+      if (STy->containsScalableVectorType())
+        return true;
----------------
sdesmalen wrote:
> This line made me realise there's currently no test for the nested case (struct containing a struct with a scalable vector). I'm not sure if this could lead to any complications, for example in CopyTo/FromParts that tries to breaks down the aggregate when passing values to a different basic block.
> Is this something you've tried?
I tried something like this

```
define i32 @foo({ {<vscale x 2 x i32>, <vscale x 2 x i32>}, i32 } %x, <vscale x 2 x i32>* %y, <vscale x 2 x i32>* %z) {                                                                                                                   
entry:                                                                                                                                                                                                                                    
  br label %return                                                                                                                                                                                                                        
                                                                                                                                                                                                                                          
return:                                                                                                                                                                                                                                   
  %a = extractvalue { {<vscale x 2 x i32>, <vscale x 2 x i32>}, i32 } %x, 1                                                                                                                                                               
  %b = extractvalue { {<vscale x 2 x i32>, <vscale x 2 x i32>}, i32 } %x, 0, 0                                                                                                                                                            
  %c = extractvalue { {<vscale x 2 x i32>, <vscale x 2 x i32>}, i32 } %x, 0, 1                                                                                                                                                            
  store <vscale x 2 x i32> %b, <vscale x 2 x i32>* %y                                                                                                                                                                                     
  store <vscale x 2 x i32> %c, <vscale x 2 x i32>* %z                                                                                                                                                                                     
                                                                                                                                                                                                                                          
  ret i32 %a                                                                                                                                                                                                                              
} 
```

The struct gets recursively broken down by ComputeValueVTs. With the fix to ignore struct layout when Offsets is null that I put in https://reviews.llvm.org/D94286, it was able to break it down without issue.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D94142/new/

https://reviews.llvm.org/D94142



More information about the llvm-commits mailing list