[InstSimplify] Support constant folding to vector of pointers
authorBruno Cardoso Lopes <bruno.cardoso@gmail.com>
Wed, 22 Oct 2014 12:18:48 +0000 (12:18 +0000)
committerBruno Cardoso Lopes <bruno.cardoso@gmail.com>
Wed, 22 Oct 2014 12:18:48 +0000 (12:18 +0000)
commit5165ff9878bba031b95756e2de12d4025da69a92
treecd96e5a2720db7f3253a80b970db27adc3366c9c
parent85460764013c1fa1e9d74b3966ced57719d68b1a
[InstSimplify] Support constant folding to vector of pointers

ConstantFolding crashes when trying to InstSimplify the following load:

@a = private unnamed_addr constant %mst {
     i8* inttoptr (i64 -1 to i8*),
     i8* inttoptr (i64 -1 to i8*)
}, align 8

%x = load <2 x i8*>* bitcast (%mst* @a to <2 x i8*>*), align 8

This patch fix this by adding support to this type of folding:

%x = load <2 x i8*>* bitcast (%mst* @a to <2 x i8*>*), align 8
==> gets folded to:
  %x = <2 x i8*> <i8* inttoptr (i64 -1 to i8*), i8* inttoptr (i64 -1 to i8*)>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@220380 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Analysis/ConstantFolding.cpp
test/Transforms/InstSimplify/vector_ptr_bitcast.ll [new file with mode: 0644]