[ConstraintElimination] Do not crash on vector GEP in decomposeGEP
authorBjorn Pettersson <bjorn.a.pettersson@ericsson.com>
Tue, 1 Nov 2022 18:55:23 +0000 (19:55 +0100)
committerBjorn Pettersson <bjorn.a.pettersson@ericsson.com>
Wed, 2 Nov 2022 09:04:11 +0000 (10:04 +0100)
commit44bb4099cd75dfd4800effe98b08ed720d71029a
tree8804fb970ec6b3fdbed33489cbcdcef25c55a2ea
parent9a9b904b871af2ee0b846c31fa1c2570528ce4a4
[ConstraintElimination] Do not crash on vector GEP in decomposeGEP

Commit 359bc5c541ae4b02 caused
 Assertion `isa<To>(Val) && "cast<Ty>() argument of incompatible type!"'
failures in decomposeGEP when the GEP pointer operand is a vector.

Fix is to use DataLayout::getIndexTypeSizeInBits when fetching the
index size, as it will use the scalar type in case of a ptr vector.

Differential Revision: https://reviews.llvm.org/D137185
llvm/lib/Transforms/Scalar/ConstraintElimination.cpp
llvm/test/Transforms/ConstraintElimination/geps-ptrvector.ll [new file with mode: 0644]