Fix a regression from r125393;
It caused a crash in MultiSource/Benchmarks/Bullet.
Opt hit an assertion with "opt -std-compile-opts" because
Constant::getAllOnesValue doesn't know how to handle floats.
This patch added a test to reproduce the problem and a check that the
destination vector is of integer type.
Thank you Benjamin!
llvm-svn: 125459
diff --git a/llvm/lib/VMCore/ConstantFold.cpp b/llvm/lib/VMCore/ConstantFold.cpp
index 0ec343f..1b50c4a 100644
--- a/llvm/lib/VMCore/ConstantFold.cpp
+++ b/llvm/lib/VMCore/ConstantFold.cpp
@@ -43,7 +43,8 @@
static Constant *BitCastConstantVector(ConstantVector *CV,
const VectorType *DstTy) {
- if (CV->isAllOnesValue()) return Constant::getAllOnesValue(DstTy);
+ if (CV->isAllOnesValue() && DstTy->getElementType()->isIntegerTy())
+ return Constant::getAllOnesValue(DstTy);
if (CV->isNullValue()) return Constant::getNullValue(DstTy);
// If this cast changes element count then we can't handle it here: