Skip to content

Add support for scalable vectors#1247

Draft
zhengyang92 wants to merge 1 commit intoAliveToolkit:masterfrom
zhengyang92:sve
Draft

Add support for scalable vectors#1247
zhengyang92 wants to merge 1 commit intoAliveToolkit:masterfrom
zhengyang92:sve

Conversation

@zhengyang92
Copy link
Copy Markdown
Contributor

@zhengyang92 zhengyang92 commented Oct 7, 2025

This patch adds the support for scalable vectors.

In this patch,

  • Alive2 generates SMT terms for scalable vectors based on a global vscale factor declared in util/config.h. For example, a scalable vector of type <vscale x 2 x i2> creates eight i2 integers when vscale=4.
  • The default vscale factor is set 2 and it can be adjusted by the command line arguments inalive and alive-tv.
  • The elements of VectorType is set to vscale * min_elements at the time when the VectorType is created. The min_elements field in VectorType serves solely for IR printer.
  • The llvm2alive is able to take scalable vector types.
  • The parser of scalable vector types for alive is implemented, check the test cases.
  • The llvm.vscale() returns the vscale factor.
  • For the mask vectors of shufflevectors, replicate by vscale when the arguments are scalable vectors.

With this patch, Alive2 can validate non-trivial cases with loops as shown in tests/alive-tv/vector/scalable/insert-loop*.ll.

@nunoplopes please let me know what you think.

CC @regehr

@zhengyang92 zhengyang92 force-pushed the sve branch 2 times, most recently from ec810ce to fcb27d2 Compare October 7, 2025 06:46
@nunoplopes
Copy link
Copy Markdown
Member

vscale needs to be an SMT variable.
If this can be set at run time (I don't know), then it goes to State. If the program can't change it, it goes to the type system.

@zhengyang92
Copy link
Copy Markdown
Contributor Author

zhengyang92 commented Oct 7, 2025 via email

- Add VScale instruction for llvm.vscale() intrinsic
- Store vscale as a shared SMT variable (VectorType::getVScaleVar)
- Expose vscale expr via Function::getVScaleExpr()
- Bind vscale as a verification precondition in TransformVerify::exec()
- Add vscale constraints in VectorType::getTypeConstraints()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants