From 6d0a0a462732328ff97855d06144d6e9d9629486 Mon Sep 17 00:00:00 2001 From: Anna Thomas Date: Fri, 24 Jun 2016 12:38:45 +0000 Subject: [PATCH] [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 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@273671 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/LICM.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Transforms/Scalar/LICM.cpp b/lib/Transforms/Scalar/LICM.cpp index b67bd24ecb8..de1691d5052 100644 --- a/lib/Transforms/Scalar/LICM.cpp +++ b/lib/Transforms/Scalar/LICM.cpp @@ -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( -- 2.50.1