[llvm] r199966 - [LPM] Fix a logic error in LICM spotted by inspection.

Chandler Carruth chandlerc at gmail.com
Thu Jan 23 18:24:47 PST 2014


Author: chandlerc
Date: Thu Jan 23 20:24:47 2014
New Revision: 199966

URL: http://llvm.org/viewvc/llvm-project?rev=199966&view=rev
Log:
[LPM] Fix a logic error in LICM spotted by inspection.

We completely skipped promotion in LICM if the loop has a preheader or
dedicated exits, but not *both*. We hoist if there is a preheader, and
sink if there are dedicated exits, but either hoisting or sinking can
move loop invariant code out of the loop!

I have no idea if this has a practical consequence. If anyone has ideas
for a test case, let me know.

Modified:
    llvm/trunk/lib/Transforms/Scalar/LICM.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/LICM.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LICM.cpp?rev=199966&r1=199965&r2=199966&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LICM.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LICM.cpp Thu Jan 23 20:24:47 2014
@@ -273,7 +273,7 @@ bool LICM::runOnLoop(Loop *L, LPPassMana
 
   // Now that all loop invariants have been removed from the loop, promote any
   // memory references to scalars that we can.
-  if (!DisablePromotion && Preheader && L->hasDedicatedExits()) {
+  if (!DisablePromotion && (Preheader || L->hasDedicatedExits())) {
     SmallVector<BasicBlock *, 8> ExitBlocks;
     SmallVector<Instruction *, 8> InsertPts;
 





More information about the llvm-commits mailing list