[llvm] f9047ed - LICM: Reorder condition checks

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Tue Mar 3 14:16:10 PST 2020


Author: Matt Arsenault
Date: 2020-03-03T17:15:57-05:00
New Revision: f9047ede589bce390e3115c75656523e085809a4

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

LOG: LICM: Reorder condition checks

Check the fast math flag before the more expensive loop check.

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/llvm/lib/Transforms/Scalar/LICM.cpp b/llvm/lib/Transforms/Scalar/LICM.cpp
index ee436a4b3193..fbb01fe1563e 100644
--- a/llvm/lib/Transforms/Scalar/LICM.cpp
+++ b/llvm/lib/Transforms/Scalar/LICM.cpp
@@ -818,9 +818,8 @@ bool llvm::hoistRegion(DomTreeNode *N, AliasAnalysis *AA, LoopInfo *LI,
 
       // Attempt to remove floating point division out of the loop by
       // converting it to a reciprocal multiplication.
-      if (I.getOpcode() == Instruction::FDiv &&
-          CurLoop->isLoopInvariant(I.getOperand(1)) &&
-          I.hasAllowReciprocal()) {
+      if (I.getOpcode() == Instruction::FDiv && I.hasAllowReciprocal() &&
+          CurLoop->isLoopInvariant(I.getOperand(1))) {
         auto Divisor = I.getOperand(1);
         auto One = llvm::ConstantFP::get(Divisor->getType(), 1.0);
         auto ReciprocalDivisor = BinaryOperator::CreateFDiv(One, Divisor);


        


More information about the llvm-commits mailing list