[SVE] Make ConstantFoldGetElementPtr work for scalable vectors of indices
authorDavid Sherwood <david.sherwood@arm.com>
Fri, 19 Jun 2020 13:33:20 +0000 (14:33 +0100)
committerDavid Sherwood <david.sherwood@arm.com>
Thu, 25 Jun 2020 06:28:19 +0000 (07:28 +0100)
commitee26a31e7b02e124d71091d47f2ae624774e5e0a
treed8c42fb90da49471cf2328406fb10be74301a71a
parent4c6548222b3c41d024581d28f42b3f02510bcfe3
[SVE] Make ConstantFoldGetElementPtr work for scalable vectors of indices

This patch fixes a compiler crash that was hit when trying to simplify
the following code:

getelementptr [2 x i64], [2 x i64]* null, i64 0, <vscale x 2 x i64> zeroinitializer

For the case where we have a null pointer value like above, we just
need to ensure we don't assume the indices are always fixed width.

Differential Revision: https://reviews.llvm.org/D82183
llvm/lib/IR/ConstantFold.cpp
llvm/test/Transforms/InstSimplify/gep.ll