[llvm-commits] [llvm] r125459 - in /llvm/trunk: lib/VMCore/ConstantFold.cpp test/Transforms/InstCombine/bitcast-vec-uniform.ll
Nadav Rotem
nadav.rotem at intel.com
Sun Feb 13 07:45:34 PST 2011
Author: nadav
Date: Sun Feb 13 09:45:34 2011
New Revision: 125459
URL: http://llvm.org/viewvc/llvm-project?rev=125459&view=rev
Log:
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!
Modified:
llvm/trunk/lib/VMCore/ConstantFold.cpp
llvm/trunk/test/Transforms/InstCombine/bitcast-vec-uniform.ll
Modified: llvm/trunk/lib/VMCore/ConstantFold.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/VMCore/ConstantFold.cpp?rev=125459&r1=125458&r2=125459&view=diff
==============================================================================
--- llvm/trunk/lib/VMCore/ConstantFold.cpp (original)
+++ llvm/trunk/lib/VMCore/ConstantFold.cpp Sun Feb 13 09:45:34 2011
@@ -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:
Modified: llvm/trunk/test/Transforms/InstCombine/bitcast-vec-uniform.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/InstCombine/bitcast-vec-uniform.ll?rev=125459&r1=125458&r2=125459&view=diff
==============================================================================
--- llvm/trunk/test/Transforms/InstCombine/bitcast-vec-uniform.ll (original)
+++ llvm/trunk/test/Transforms/InstCombine/bitcast-vec-uniform.ll Sun Feb 13 09:45:34 2011
@@ -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
+}
+
More information about the llvm-commits
mailing list