[PATCH] [GVN] Perform Scalar PRE on gep indices that feed loads before doing Load PRE

Daniel Berlin dberlin at dberlin.org
Thu Nov 13 12:37:43 PST 2014


LGTM modulo one comment

================
Comment at: lib/Transforms/Scalar/GVN.cpp:2447
@@ -2442,3 +2446,3 @@
 
-    // Don't perform PRE on a landing pad.
-    if (CurrentBlock->isLandingPad()) continue;
+  if (isa<AllocaInst>(CurInst) || isa<LoadInst>(CurInst) ||
+      isa<TerminatorInst>(CurInst) || isa<PHINode>(CurInst) ||
----------------
If you are going to add LoadInst, you might as well add all the memory ops (anything where getOpCode() > MemoryOpsBegin && getOpCode < MemoryOpsEnd. If you do this, i'd add isMemoryOp to instruction.h alongside isBinaryOp, etc)

http://reviews.llvm.org/D6103






More information about the llvm-commits mailing list