[llvm-commits] [llvm] r125393 - in /llvm/trunk: lib/VMCore/ConstantFold.cpp test/Transforms/InstCombine/bitcast-vec-uniform.ll test/Transforms/InstCombine/fold-vector-select.ll
Benjamin Kramer
benny.kra at googlemail.com
Sun Feb 13 07:37:33 PST 2011
On 13.02.2011, at 16:16, Rotem, Nadav wrote:
> Hi Benjamin,
>
> Thank you for catching this.
>
> The patch below fixes the problem. If it looks good to you I will commit it.
>
> Thanks,
> Nadav
>
> Details:
> 1. Added a test to reproduce the problem.
> 2. Added a check that the vector is of integer type.
>
>
> Index: ../llvm/test/Transforms/InstCombine/bitcast-vec-uniform.ll
> ===================================================================
> --- ../llvm/test/Transforms/InstCombine/bitcast-vec-uniform.ll (revision 125450)
> +++ ../llvm/test/Transforms/InstCombine/bitcast-vec-uniform.ll (working copy)
> @@ -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-NOT: 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
> +}
>
>
> Index: ../llvm/lib/VMCore/ConstantFold.cpp
> ===================================================================
> --- ../llvm/lib/VMCore/ConstantFold.cpp (revision 125450)
> +++ ../llvm/lib/VMCore/ConstantFold.cpp (working copy)
> @@ -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);
Looks good to me!
More information about the llvm-commits
mailing list