[canonicalize] Teach InstCombine to canonicalize loads which are only
authorChandler Carruth <chandlerc@gmail.com>
Thu, 22 Jan 2015 05:08:12 +0000 (05:08 +0000)
committerChandler Carruth <chandlerc@gmail.com>
Thu, 22 Jan 2015 05:08:12 +0000 (05:08 +0000)
commitb778cbc0c8f1d970ae30e0ffb4eed17ca2bb294a
treea1e19ebf2c4f9f8ebe77597344a8c8b92fa50882
parent3f6dea4864a6ba90e004946278dd6291991507b9
[canonicalize] Teach InstCombine to canonicalize loads which are only
ever stored to always use a legal integer type if one is available.

Regardless of whether this particular type is good or bad, it ensures we
don't get weird differences in generated code (and resulting
performance) from "equivalent" patterns that happen to end up using
a slightly different type.

After some discussion on llvmdev it seems everyone generally likes this
canonicalization. However, there may be some parts of LLVM that handle
it poorly and need to be fixed. I have at least verified that this
doesn't impede GVN and instcombine's store-to-load forwarding powers in
any obvious cases. Subtle cases are exactly what we need te flush out if
they remain.

Also note that this IR pattern should already be hitting LLVM from Clang
at least because it is exactly the IR which would be produced if you
used memcpy to copy a pointer or floating point between memory instead
of a variable.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@226781 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp
test/Transforms/InstCombine/load.ll
test/Transforms/InstCombine/struct-assign-tbaa.ll