[ConstantFolding] Use FoldBitCast correctly
authorKeno Fischer <keno@alumni.harvard.edu>
Thu, 26 Sep 2019 02:07:51 +0000 (02:07 +0000)
committerKeno Fischer <keno@alumni.harvard.edu>
Thu, 26 Sep 2019 02:07:51 +0000 (02:07 +0000)
commitcea8882254f97ae82867e25e736959d1cfa31896
tree50749cedcfdc835d28ca5e0fc1cd7258dbf17500
parentf0458283d0572eeb8c1c41be4aa717e8f1170aff
[ConstantFolding] Use FoldBitCast correctly

Previously we might attempt to use a BitCast to turn bits into vectors of pointers,
but that requires an inttoptr cast to be legal. Add an assertion to detect the formation of illegal bitcast attempts
early (in the tests, we often constant-fold away the result before getting to this assertion check),
while being careful to still handle the early-return conditions without adding extra complexity in the result.

Patch by Jameson Nash <jameson@juliacomputing.com>.

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

llvm-svn: 372940
llvm/lib/Analysis/ConstantFolding.cpp