Canonicalize addrspacecast ConstExpr between different pointer types
authorJingyue Wu <jingyue@google.com>
Sun, 15 Jun 2014 21:40:57 +0000 (21:40 +0000)
committerJingyue Wu <jingyue@google.com>
Sun, 15 Jun 2014 21:40:57 +0000 (21:40 +0000)
commitf6eb7e3175aa0bb69152196bff69beade5fb8f38
tree4f815a74850babac547bcb3b1160935480d88c20
parentf9ef37a9861424efefcca5695c195521ccf31f4a
Canonicalize addrspacecast ConstExpr between different pointer types

As a follow-up to r210375 which canonicalizes addrspacecast
instructions, this patch canonicalizes addrspacecast constant
expressions.

Given clang uses ConstantExpr::getAddrSpaceCast to emit addrspacecast
cosntant expressions, this patch is also a step towards having the
frontend emit canonicalized addrspacecasts.

Piggyback a minor refactor in InstCombineCasts.cpp

Update three affected tests in addrspacecast-alias.ll,
access-non-generic.ll and constant-fold-gep.ll and added one new test in
constant-fold-address-space-pointer.ll

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@211004 91177308-0d34-0410-b5e6-96231b3b80d8
lib/IR/ConstantFold.cpp
lib/IR/Constants.cpp
lib/Transforms/InstCombine/InstCombineCasts.cpp
test/Assembler/addrspacecast-alias.ll
test/CodeGen/NVPTX/access-non-generic.ll
test/Other/constant-fold-gep.ll
test/Transforms/InstCombine/constant-fold-address-space-pointer.ll