InstCombine: Don't allow turning vector-of-pointer loads into vector-of-integer.
authorBenjamin Kramer <benny.kra@googlemail.com>
Thu, 19 Sep 2013 20:59:04 +0000 (20:59 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Thu, 19 Sep 2013 20:59:04 +0000 (20:59 +0000)
The code below can't handle any pointers. PR17293.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@191036 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
test/Transforms/InstCombine/bitcast.ll

index 88e16e97250588b37d1b5bc5cda591592a14730c..0a0727e0fa346fc2f24c5b14fa4ee9d5117af4e6 100644 (file)
@@ -318,7 +318,8 @@ static Instruction *InstCombineLoadCast(InstCombiner &IC, LoadInst &LI,
             SrcPTy->isVectorTy()) &&
           // Do not allow turning this into a load of an integer, which is then
           // casted to a pointer, this pessimizes pointer analysis a lot.
-          (SrcPTy->isPointerTy() == LI.getType()->isPointerTy()) &&
+          (SrcPTy->isPtrOrPtrVectorTy() ==
+           LI.getType()->isPtrOrPtrVectorTy()) &&
           IC.getDataLayout()->getTypeSizeInBits(SrcPTy) ==
                IC.getDataLayout()->getTypeSizeInBits(DestPTy)) {
 
index 4ef87909cff201dd9946db79af27b043a9fa4692..c7a520bcf360bacb2a485852068370b7344c30f3 100644 (file)
@@ -144,3 +144,13 @@ define <2 x i16> @BitcastInsert(i32 %a) {
 ; CHECK-LABEL: @BitcastInsert(
 ; CHECK: bitcast i32 %a to <2 x i16>
 }
+
+; PR17293
+define <2 x i64> @test7(<2 x i8*>* %arg) nounwind {
+  %cast = bitcast <2 x i8*>* %arg to <2 x i64>*
+  %load = load <2 x i64>* %cast, align 16
+  ret <2 x i64> %load
+; CHECK: @test7
+; CHECK: bitcast
+; CHECK: load
+}