From: Chris Lattner Date: Mon, 12 Jul 2010 01:19:22 +0000 (+0000) Subject: fix PR7311 by avoiding breaking casts when a bitcast from scalar->vector X-Git-Url: http://plrg.eecs.uci.edu/git/?a=commitdiff_plain;h=dfd3626b477a416040fc4c08d5db3bb85d3500d8;p=oota-llvm.git fix PR7311 by avoiding breaking casts when a bitcast from scalar->vector is involved. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@108117 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/lib/VMCore/Instructions.cpp b/lib/VMCore/Instructions.cpp index a32cb3c871c..381b85faa4c 100644 --- a/lib/VMCore/Instructions.cpp +++ b/lib/VMCore/Instructions.cpp @@ -2006,6 +2006,14 @@ unsigned CastInst::isEliminableCastPair( { 99,99,99,99,99,99,99,99,99,13,99,12 }, // IntToPtr | { 5, 5, 5, 6, 6, 5, 5, 6, 6,11, 5, 1 }, // BitCast -+ }; + + // If either of the casts are a bitcast from scalar to vector, disallow the + // merging. + if ((firstOp == Instruction::BitCast && + isa(SrcTy) != isa(MidTy)) || + (secondOp == Instruction::BitCast && + isa(MidTy) != isa(DstTy))) + return 0; // Disallowed int ElimCase = CastResults[firstOp-Instruction::CastOpsBegin] [secondOp-Instruction::CastOpsBegin]; diff --git a/test/Transforms/InstCombine/cast.ll b/test/Transforms/InstCombine/cast.ll index 77fccdfa52d..102d2f048f1 100644 --- a/test/Transforms/InstCombine/cast.ll +++ b/test/Transforms/InstCombine/cast.ll @@ -638,3 +638,14 @@ define <4 x i32> @test62(<3 x float> %call4) nounwind { ; CHECK-NEXT: ret } +; PR7311 - Don't create invalid IR on scalar->vector cast. +define <2 x float> @test63(i64 %tmp8) nounwind { +entry: + %a = bitcast i64 %tmp8 to <2 x i32> + %vcvt.i = uitofp <2 x i32> %a to <2 x float> + ret <2 x float> %vcvt.i +; CHECK: @test63 +; CHECK: bitcast +; CHECK: uitofp +} +