[PATCH] [InstCombine] Fold IntToPtr and PtrToInt into preceding loads.

David Majnemer david.majnemer at gmail.com
Wed May 27 03:04:53 PDT 2015


REPOSITORY
  rL LLVM

================
Comment at: lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp:486-487
@@ -485,1 +485,4 @@
+  // We can do this for BitCastInsts as well as casts from and to pointer types,
+  // as long as those are noops (i.e., the source or dest type have the same
+  // bitwidth as the target's pointers.
   if (LI.hasOneUse())
----------------
Your comment has mismatched parenthesis.

================
Comment at: lib/Transforms/InstCombine/InstCombineLoadStoreAlloca.cpp:489
@@ -485,6 +488,3 @@
   if (LI.hasOneUse())
-    if (auto *BC = dyn_cast<BitCastInst>(LI.user_back())) {
-      LoadInst *NewLoad = combineLoadToNewType(IC, LI, BC->getDestTy());
-      BC->replaceAllUsesWith(NewLoad);
-      IC.EraseInstFromFunction(*BC);
-      return &LI;
+    if(auto* CI = dyn_cast<CastInst>(LI.user_back())) {
+      if (CI->isNoopCast(DL)) {
----------------
Please fix the formatting here

http://reviews.llvm.org/D9152

EMAIL PREFERENCES
  http://reviews.llvm.org/settings/panel/emailpreferences/






More information about the llvm-commits mailing list