[llvm] 2b70b68 - [GVN] Don't short-circuit load PRE

Nikita Popov via llvm-commits llvm-commits at lists.llvm.org
Sun Aug 22 12:13:08 PDT 2021


Author: Nikita Popov
Date: 2021-08-22T21:12:58+02:00
New Revision: 2b70b68efbd25a46d2c13045b424e2e10ef2379c

URL: https://github.com/llvm/llvm-project/commit/2b70b68efbd25a46d2c13045b424e2e10ef2379c
DIFF: https://github.com/llvm/llvm-project/commit/2b70b68efbd25a46d2c13045b424e2e10ef2379c.diff

LOG: [GVN] Don't short-circuit load PRE

4ad41902e8c7481ccf3cdf6e618dfcd1e1fc10fc changed this code to
propagate Changed if scalar GEP PRE is performed. However, as
implemented this would skip the load PRE entirely if GEP indices
were PREd. Make sure load PRE runs even if Changed is already
true.

This likely has no functional effect as load PRE would then
occur on a later GVN iteration.

Added: 
    

Modified: 
    llvm/lib/Transforms/Scalar/GVN.cpp

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/GVN.cpp b/llvm/lib/Transforms/Scalar/GVN.cpp
index 16368aec7c3f0..79750aec2c5db 100644
--- a/llvm/lib/Transforms/Scalar/GVN.cpp
+++ b/llvm/lib/Transforms/Scalar/GVN.cpp
@@ -1673,8 +1673,11 @@ bool GVN::processNonLocalLoad(LoadInst *Load) {
   if (!isLoadInLoopPREEnabled() && LI && LI->getLoopFor(Load->getParent()))
     return Changed;
 
-  return Changed || PerformLoadPRE(Load, ValuesPerBlock, UnavailableBlocks) ||
-         performLoopLoadPRE(Load, ValuesPerBlock, UnavailableBlocks);
+  if (PerformLoadPRE(Load, ValuesPerBlock, UnavailableBlocks) ||
+      performLoopLoadPRE(Load, ValuesPerBlock, UnavailableBlocks))
+    return true;
+
+  return Changed;
 }
 
 static bool impliesEquivalanceIfTrue(CmpInst* Cmp) {


        


More information about the llvm-commits mailing list