summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNadav Rotem <nadav.rotem@intel.com>2011-02-13 15:45:34 +0000
committerNadav Rotem <nadav.rotem@intel.com>2011-02-13 15:45:34 +0000
commit27b848afb0ec0f2acb3ebab3a56ec1f3074ebb3d (patch)
treebc5b09e3135ae977abbca6e205529491a5153d34
parentd5f0b1148aea2d79ee15257348491a930ec04f8e (diff)
downloadbcm5719-llvm-27b848afb0ec0f2acb3ebab3a56ec1f3074ebb3d.tar.gz
bcm5719-llvm-27b848afb0ec0f2acb3ebab3a56ec1f3074ebb3d.zip
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
-rw-r--r--llvm/lib/VMCore/ConstantFold.cpp3
-rw-r--r--llvm/test/Transforms/InstCombine/bitcast-vec-uniform.ll18
2 files changed, 19 insertions, 2 deletions
diff --git a/llvm/lib/VMCore/ConstantFold.cpp b/llvm/lib/VMCore/ConstantFold.cpp
index 0ec343f07d2..1b50c4aa9dd 100644
--- a/llvm/lib/VMCore/ConstantFold.cpp
+++ b/llvm/lib/VMCore/ConstantFold.cpp
@@ -43,7 +43,8 @@ using namespace llvm;
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:
diff --git a/llvm/test/Transforms/InstCombine/bitcast-vec-uniform.ll b/llvm/test/Transforms/InstCombine/bitcast-vec-uniform.ll
index 1fba1632693..ef428894e72 100644
--- a/llvm/test/Transforms/InstCombine/bitcast-vec-uniform.ll
+++ b/llvm/test/Transforms/InstCombine/bitcast-vec-uniform.ll
@@ -1,14 +1,30 @@
-; RUN: opt < %s -instcombine -S | not grep bitcast
+; RUN: opt < %s -instcombine -S | FileCheck %s
+; CHECK: @a
+; CHECK-NOT: bitcast
+; CHECK: ret
define <4 x i32> @a(<1 x i64> %y) {
%c = bitcast <2 x i64> <i64 0, i64 0> to <4 x i32>
ret <4 x i32> %c
}
+; CHECK: @b
+; CHECK: bitcast
+; CHECK: ret
+
define <4 x i32> @b(<1 x i64> %y) {
%c = bitcast <2 x i64> <i64 -1, i64 -1> to <4 x i32>
ret <4 x i32> %c
}
+; CHECK: @foo
+; CHECK: bitcast
+
+; from MultiSource/Benchmarks/Bullet
+define <2 x float> @foo() {
+ %cast = bitcast i64 -1 to <2 x float>
+ ret <2 x float> %cast
+}
+
OpenPOWER on IntegriCloud