Check alignment of loads when deciding whether it is safe to execute them
unconditionally.  Besides checking the offset, also check that the underlying
object is aligned as much as the load itself.


git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@94875 91177308-0d34-0410-b5e6-96231b3b80d8
diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp
index 9c18452..6e70952 100644
--- a/lib/Transforms/Scalar/GVN.cpp
+++ b/lib/Transforms/Scalar/GVN.cpp
@@ -1651,7 +1651,8 @@
   if (!allSingleSucc &&
       // FIXME: REEVALUTE THIS.
       !isSafeToLoadUnconditionally(LoadPtr,
-                                   UnavailablePred->getTerminator(), TD)) {
+                                   UnavailablePred->getTerminator(),
+                                   LI->getAlignment(), TD)) {
     assert(NewInsts.empty() && "Should not have inserted instructions");
     return false;
   }