Skip to content

Commit

Permalink
[LICM] Avoid repeating expensive call while promoting loads. NFC
Browse files Browse the repository at this point in the history
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

llvm-svn: 273671
  • Loading branch information
annamthomas committed Jun 24, 2016
1 parent 3e2c30d commit 6715135
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions llvm/lib/Transforms/Scalar/LICM.cpp
Expand Up @@ -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(
Expand Down

0 comments on commit 6715135

Please sign in to comment.