[llvm] r273671 - [LICM] Avoid repeating expensive call while promoting loads. NFC

Anna Thomas via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 24 05:38:45 PDT 2016


Author: annat
Date: Fri Jun 24 07:38:45 2016
New Revision: 273671

URL: http://llvm.org/viewvc/llvm-project?rev=273671&view=rev
Log:
[LICM] Avoid repeating expensive call while promoting loads. NFC

Summary:
We can avoid repeating the check `isGuaranteedToExecute` when it's already called once while checking if the alignment can be widened for the load/store being hoisted.

The function is invariant for the same instruction `UI` in `isGuaranteedToExecute(*UI, DT, CurLoop, SafetyInfo);`

Reviewers: hfinkel, eli.friedman

Subscribers: llvm-commits

Differential Revision: http://reviews.llvm.org/D21672

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=273671&r1=273670&r2=273671&view=diff
==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LICM.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LICM.cpp Fri Jun 24 07:38:45 2016
@@ -945,15 +945,16 @@ bool llvm::promoteLoopAccessesToScalars(
         // instruction will be executed, update the alignment.
         // Larger is better, with the exception of 0 being the best alignment.
         unsigned InstAlignment = Store->getAlignment();
-        if ((InstAlignment > Alignment || InstAlignment == 0) && Alignment != 0)
+        if ((InstAlignment > Alignment || InstAlignment == 0) &&
+            Alignment != 0) {
           if (isGuaranteedToExecute(*UI, DT, CurLoop, SafetyInfo)) {
             GuaranteedToExecute = true;
             Alignment = InstAlignment;
           }
-
-        if (!GuaranteedToExecute)
+        } else if (!GuaranteedToExecute) {
           GuaranteedToExecute =
               isGuaranteedToExecute(*UI, DT, CurLoop, SafetyInfo);
+        }
 
         if (!GuaranteedToExecute && !CanSpeculateLoad) {
           CanSpeculateLoad = isDereferenceableAndAlignedPointer(




More information about the llvm-commits mailing list