[PATCH] D78267: [InstCombine][SVE] Fix visitExtractElementInst for scalable type.

Huihui Zhang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Apr 15 21:17:28 PDT 2020


huihuiz created this revision.
huihuiz added reviewers: sdesmalen, efriedma, spatel, nikic.
huihuiz added a project: LLVM.
Herald added subscribers: psnobl, rkruppe, hiraditya, tschuett.
huihuiz added a comment.

Current upstream crash at llvm/include/llvm/ADT/APInt.h:1437: void llvm::APInt::setBit(unsigned int): Assertion `BitPosition < BitWidth && "BitPosition out of range"' failed.

take test.ll, run: opt -S -instcombine test.ll

  define i32 @extractelement_maybe_out_of_range(<vscale x 4 x i32> %a) {
    %r = extractelement <vscale x 4 x i32> %a, i64 4
    ret i32 %r
  }


This patch fix the following issues in InstCombiner::visitExtractElementInst

1. Skip for scalable type when transformation relys on fixed size element number.
2. Fix out-of-range calculation, index should be unsigned less than (ult) element count, instead of unsigned less than or equal (ule).

TODO:
ShuffleVectorInst::ShuffleMask need to be able to handle scalable type.
For VectorUtils::findScalarElement, temporarily skip scalable type if in-range information
can not be determined at compile-time.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D78267

Files:
  llvm/lib/Analysis/VectorUtils.cpp
  llvm/lib/Transforms/InstCombine/InstCombineVectorOps.cpp
  llvm/test/Transforms/InstCombine/vscale_extractelement.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D78267.257948.patch
Type: text/x-patch
Size: 11259 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20200416/5b59137a/attachment.bin>


More information about the llvm-commits mailing list