[PATCH] D78895: [InstCombine][SVE] Fix visitInsertElementInst for scalable type.

Huihui Zhang via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Sun Apr 26 22:19:16 PDT 2020


huihuiz added a comment.

1. Current upstream crash at:

llvm::ShuffleVectorInst::ShuffleVectorInst(llvm::Value *, llvm::Value *, ArrayRef<int>, const llvm::Twine &, llvm::Instruction *): Assertion `isValidOperands(V1, V2, Mask) && "Invalid shuffle vector instruction operands!"' failed.
take test.ll , run opt -S -instcombine test.ll

  define <vscale x 4 x i32> @insertelement_extractelement(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {
    %t0 = extractelement <vscale x 4 x i32> %a, i32 1
    %t1 = insertelement <vscale x 4 x i32> %b, i32 %t0, i32 0
    ret <vscale x 4 x i32> %t1
  }



2. Current upstream is doing wrong fold, trying to fold a chain of insertelement into splat for scalable type. The vector length of scalable type is unknown at compile-time. Therefore a valid sequence of insertelement for fixed-length vector, may not be valid for scalable type to fold into splat.

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

  define <vscale x 4 x float> @insertelement_sequene_may_not_be_splat(float %x) {
    %t0 = insertelement <vscale x 4 x float> undef, float %x, i32 0
    %t1 = insertelement <vscale x 4 x float> %t0, float %x, i32 1
    %t2 = insertelement <vscale x 4 x float> %t1, float %x, i32 2
    %t3 = insertelement <vscale x 4 x float> %t2, float %x, i32 3
    ret <vscale x 4 x float> %t3
  }

currently generating:

  define <vscale x 4 x float> @insertelement_sequene_may_not_be_splat(float %x) {
    %t0 = insertelement <vscale x 4 x float> undef, float %x, i32 0
    %t3 = shufflevector <vscale x 4 x float> %t0, <vscale x 4 x float> undef, <vscale x 4 x i32> zeroinitializer
    ret <vscale x 4 x float> %t3
  }




Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D78895





More information about the llvm-commits mailing list