diff options
| -rw-r--r-- | llvm/lib/Analysis/ConstantFolding.cpp | 2 | ||||
| -rw-r--r-- | llvm/test/Transforms/InstCombine/cast.ll | 7 |
2 files changed, 8 insertions, 1 deletions
diff --git a/llvm/lib/Analysis/ConstantFolding.cpp b/llvm/lib/Analysis/ConstantFolding.cpp index 60b94a903e3..39e422f164c 100644 --- a/llvm/lib/Analysis/ConstantFolding.cpp +++ b/llvm/lib/Analysis/ConstantFolding.cpp @@ -187,7 +187,7 @@ Constant *FoldBitCast(Constant *C, Type *DestTy, const DataLayout &DL) { for (unsigned j = 0; j != Ratio; ++j) { Constant *Src = C->getAggregateElement(SrcElt++); if (Src && isa<UndefValue>(Src)) - Src = Constant::getNullValue(SrcEltTy); + Src = Constant::getNullValue(C->getType()->getVectorElementType()); else Src = dyn_cast_or_null<ConstantInt>(Src); if (!Src) // Reject constantexpr elements. diff --git a/llvm/test/Transforms/InstCombine/cast.ll b/llvm/test/Transforms/InstCombine/cast.ll index 46ae14c85cc..c4990eaa307 100644 --- a/llvm/test/Transforms/InstCombine/cast.ll +++ b/llvm/test/Transforms/InstCombine/cast.ll @@ -1386,3 +1386,10 @@ define i32 @test89() { ; CHECK-NEXT: ret i32 393216 ret i32 bitcast (<2 x i16> <i16 6, i16 undef> to i32) } + +define <2 x i32> @test90() { +; CHECK-LABEL: @test90( +; CHECK: ret <2 x i32> <i32 0, i32 15360> + %tmp6 = bitcast <4 x half> <half undef, half undef, half undef, half 0xH3C00> to <2 x i32> + ret <2 x i32> %tmp6 +} |

