[llvm-commits] [llvm] r119458 - /llvm/trunk/lib/Analysis/ScalarEvolution.cpp

Duncan Sands baldrick at free.fr
Tue Nov 16 20:18:45 PST 2010


Author: baldrick
Date: Tue Nov 16 22:18:45 2010
New Revision: 119458

URL: http://llvm.org/viewvc/llvm-project?rev=119458&view=rev
Log:
Have ScalarEvolution use SimplifyInstruction rather than hasConstantValue.
While there, add a note about an inefficiency I noticed.

Modified:
    llvm/trunk/lib/Analysis/ScalarEvolution.cpp

Modified: llvm/trunk/lib/Analysis/ScalarEvolution.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Analysis/ScalarEvolution.cpp?rev=119458&r1=119457&r2=119458&view=diff
==============================================================================
--- llvm/trunk/lib/Analysis/ScalarEvolution.cpp (original)
+++ llvm/trunk/lib/Analysis/ScalarEvolution.cpp Tue Nov 16 22:18:45 2010
@@ -69,6 +69,7 @@
 #include "llvm/Operator.h"
 #include "llvm/Analysis/ConstantFolding.h"
 #include "llvm/Analysis/Dominators.h"
+#include "llvm/Analysis/InstructionSimplify.h"
 #include "llvm/Analysis/LoopInfo.h"
 #include "llvm/Analysis/ValueTracking.h"
 #include "llvm/Assembly/Writer.h"
@@ -2874,7 +2875,10 @@
   // PHI's incoming blocks are in a different loop, in which case doing so
   // risks breaking LCSSA form. Instcombine would normally zap these, but
   // it doesn't have DominatorTree information, so it may miss cases.
-  if (Value *V = PN->hasConstantValue(DT)) {
+  if (Value *V = SimplifyInstruction(PN, TD, DT)) {
+    // TODO: The following check is suboptimal.  For example, it is pointless
+    // if V is a constant.  Since the problematic case is if V is defined inside
+    // a deeper loop, it would be better to check for that directly.
     bool AllSameLoop = true;
     Loop *PNLoop = LI->getLoopFor(PN->getParent());
     for (size_t i = 0, e = PN->getNumIncomingValues(); i != e; ++i)





More information about the llvm-commits mailing list