[PATCH] Hoist load based on alias analysis

Gerolf Hoflehner ghoflehner at apple.com
Mon Oct 27 12:46:42 PDT 2014


Does the new implementation catch any cases the old one didn't? There is extra cost by walking the range of instruction twice, and perhaps a small change would have the same effect.

================
Comment at: lib/Transforms/Scalar/MergedLoadStoreMotion.cpp:265
@@ +264,3 @@
+    BasicBlock *BB0 = Load0->getParent();
+    if (Load0->IsIndenticalToWhenDefefined(Load1) &&
+        !isLoadHoistBarrierInRange(BB1->front(), *Load1, Load1) &&
----------------
Typo. Did you mean IsIdenticalToDefined()? Or IsIdendicalLoad()?

================
Comment at: lib/Transforms/Scalar/MergedLoadStoreMotion.cpp:267
@@ +266,3 @@
+        !isLoadHoistBarrierInRange(BB1->front(), *Load1, Load1) &&
+        !isLoadHoistBarrierInRange(BB0->front(), *Load0, Load0)) {
+      return Load1;
----------------
Are you checking the range for load0 twice? See overall comment.

================
Comment at: lib/Transforms/Scalar/MergedLoadStoreMotion.cpp:371
@@ -393,1 +370,3 @@
+    LoadInst *L0 = dyn_cast<LoadInst>(I);
+    if (!L0 || !L0->isSimple() || L0->isUsedOutsideOfBlock(Succ0))
       continue;
----------------
The optimization should work when one load is used outside the block. The optimization can work when both loads are used outside but we have to deal with the PHI nodes accordingly.

http://reviews.llvm.org/D5991






More information about the llvm-commits mailing list