[llvm-dev] How to create vector pointer type?
Tim Northover via llvm-dev
llvm-dev at lists.llvm.org
Mon Oct 21 09:17:55 PDT 2019
On Mon, 21 Oct 2019 at 05:24, Celine via llvm-dev
<llvm-dev at lists.llvm.org> wrote:
> Then meet the following error:
> Assertion failed: ResultElementType == cast<PointerType>(getType()->getScalarType())->getElementType(), file D:\cygwin64\home\celine\clang-102\llvm\include\llvm/IR/Instructions.h, line 958
Both of your functions look sensible to me, but this assertion is from
within GetElementPtrInst, so it's happening after you've done
something with these types. You probably replaced a Value with a
different one with this new type (or mutated it in place). That leaves
the IR in an inconsistent state E.g. one operand of an add could be
i16 and the other i32, or in this case a GEP thinks it's operating on
an i16* to produce another i16*, but it's actually operating on a <16
x i16>*, which would produce another <16 x i16>*.
If you're trying to change the type of a Value you generally have to
recreate its whole chain of users until you can reunify the types. If
this is vectorizing a loop, for example, the whole loop data-path
would probably need to be recreated with the new vector type, and
surrounded by pointer bitcasts ot <16 x i16>* at the beginning (and
back to i16* at the end if anyone cares about the final pointer).
More information about the llvm-dev