[PATCH] D102842: [Verifier] Fail on invalid indices in {insert,extract} vector intrinsics

Joe Ellis via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu May 20 05:22:01 PDT 2021


joechrisellis created this revision.
joechrisellis added reviewers: david-arm, sdesmalen, cameron.mcinally, DavidTruby.
Herald added subscribers: dexonsmith, hiraditya.
joechrisellis requested review of this revision.
Herald added a project: LLVM.
Herald added a subscriber: llvm-commits.

The langref (llvm/docs/LangRef.rst) specifies the following for the
llvm.experimental.vector.insert intrinsic:

  ``idx`` represents the starting element number at which ``subvec``
  will be inserted. ``idx`` must be a constant multiple of
  ``subvec``'s known minimum vector length.

and the following for the llvm.experimental.vector.extract intrinsic:

  The ``idx`` specifies the starting element number within ``vec``
  from which a subvector is extracted. ``idx`` must be a constant
  multiple of the known-minimum vector length of the result type.

These conditions were not previously enforced in the verifier, meaning
that the implementation was not entirely consistent with the langref. In
some circumstances, invalid indices were permitted silently, and in
other circumstances, an undef was spawned where a verifier error would
have been preferred.

This patch adds more checks to the verifier to ensure that these
constraints are not violated. It also updates existing tests to make
sure that they abide by the use of the intrinsic documented in the
langref.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D102842

Files:
  llvm/lib/IR/Verifier.cpp
  llvm/lib/Transforms/InstCombine/InstCombineCalls.cpp
  llvm/test/CodeGen/AArch64/sve-extract-vector.ll
  llvm/test/CodeGen/AArch64/sve-insert-vector.ll
  llvm/test/Transforms/InstCombine/canonicalize-vector-extract.ll
  llvm/test/Transforms/InstCombine/canonicalize-vector-insert.ll
  llvm/test/Verifier/insert-extract-intrinsics-invalid.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D102842.346704.patch
Type: text/x-patch
Size: 16897 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210520/1cc2f023/attachment.bin>


More information about the llvm-commits mailing list