llvm-project/llvm/test/Analysis/ConstantFolding
Bjorn Pettersson 1c043a9f28 [ConstantFolding] Avoid assert when folding ptrtoint of vectorized GEP
Summary:
Got asserts in llvm::CastInst::getCastOpcode saying:
`DestBits == SrcBits && "Illegal cast to vector (wrong type or size)"' failed.

Problem seemed to be that llvm::ConstantFoldCastInstruction did
not handle ptrtoint cast of a getelementptr returning a vector
correctly. I assume such situations are quite rare, since the
GEP needs to be considered as a constant value (base pointer
being null).
The solution used here is to simply avoid the constant fold
of ptrtoint when the value is a vector. It is not supported,
and by bailing out we do not fail on assertions later on.

Reviewers: craig.topper, majnemer, davide, filcab, efriedma

Reviewed By: efriedma

Subscribers: efriedma, filcab, llvm-commits

Differential Revision: https://reviews.llvm.org/D38546

llvm-svn: 316430
2017-10-24 12:08:11 +00:00
..
cast-vector.ll [ConstantFolding] Avoid assert when folding ptrtoint of vectorized GEP 2017-10-24 12:08:11 +00:00
gep-constanfolding-error.ll [InstSimplify] Constant fold the new GEP in SimplifyGEPInst. 2017-06-06 10:17:14 +00:00
gep.ll
timeout.ll [ConstantFolding] Fix to prevent constant folding having to repeatedly scan operands. NFCI 2017-03-21 10:17:39 +00:00
vectorgep-crash.ll [ConstantFolding] Fix vector GEPs harder 2016-12-21 17:34:21 +00:00