[PATCH] D14899: fixing return value of performScalarPRE() ignored issue

Wenxiang Qiu via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 20 17:45:43 PST 2015


vincentqiuuu created this revision.
vincentqiuuu added reviewers: joker.eph, reames.
vincentqiuuu added a subscriber: llvm-commits.

The return value of performScalarPRE() at its call site in function bool GVN::processNonLocalLoad(LoadInst *LI) is not taken into account. This patch fixes the issue.

http://reviews.llvm.org/D14899

Files:
  lib/Transforms/Scalar/GVN.cpp

Index: lib/Transforms/Scalar/GVN.cpp
===================================================================
--- lib/Transforms/Scalar/GVN.cpp
+++ lib/Transforms/Scalar/GVN.cpp
@@ -1733,12 +1733,13 @@
   }
 
   // If this load follows a GEP, see if we can PRE the indices before analyzing.
+  bool Changed = false;
   if (GetElementPtrInst *GEP = dyn_cast<GetElementPtrInst>(LI->getOperand(0))) {
     for (GetElementPtrInst::op_iterator OI = GEP->idx_begin(),
                                         OE = GEP->idx_end();
          OI != OE; ++OI)
       if (Instruction *I = dyn_cast<Instruction>(OI->get()))
-        performScalarPRE(I);
+        Changed |= performScalarPRE(I);
   }
 
   // Step 2: Analyze the availability of the load
@@ -1749,7 +1750,7 @@
   // If we have no predecessors that produce a known value for this load, exit
   // early.
   if (ValuesPerBlock.empty())
-    return false;
+    return Changed;
 
   // Step 3: Eliminate fully redundancy.
   //
@@ -1777,9 +1778,10 @@
 
   // Step 4: Eliminate partial redundancy.
   if (!EnablePRE || !EnableLoadPRE)
-    return false;
+    return Changed;
 
-  return PerformLoadPRE(LI, ValuesPerBlock, UnavailableBlocks);
+  Changed |= PerformLoadPRE(LI, ValuesPerBlock, UnavailableBlocks);
+  return Changed;
 }
 
 bool GVN::processAssumeIntrinsic(IntrinsicInst *IntrinsicI) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D14899.40854.patch
Type: text/x-patch
Size: 1341 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20151121/5339a5b9/attachment.bin>


More information about the llvm-commits mailing list