Skip to content

Commit 2b3f20e

Browse files
committed
two minor changes: switch to the standard ValueToValueMapTy
map from ValueMapper.h (giving us access to its utilities) and add a fastpath in the loop rotation code, avoiding expensive ssa updator manipulation for values with nothing to update. llvm-svn: 123057
1 parent b35635e commit 2b3f20e

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

llvm/lib/Transforms/Scalar/LoopRotation.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@
2121
#include "llvm/Transforms/Utils/Local.h"
2222
#include "llvm/Transforms/Utils/BasicBlockUtils.h"
2323
#include "llvm/Transforms/Utils/SSAUpdater.h"
24+
#include "llvm/Transforms/Utils/ValueMapper.h"
2425
#include "llvm/Support/CommandLine.h"
2526
#include "llvm/Support/Debug.h"
2627
#include "llvm/ADT/Statistic.h"
27-
#include "llvm/ADT/SmallVector.h"
2828
using namespace llvm;
2929

3030
#define MAX_HEADER_SIZE 16
@@ -177,7 +177,7 @@ bool LoopRotate::rotateLoop(Loop *Lp, LPPassManager &LPM) {
177177
// Begin by walking OrigHeader and populating ValueMap with an entry for
178178
// each Instruction.
179179
BasicBlock::iterator I = OrigHeader->begin(), E = OrigHeader->end();
180-
DenseMap<const Value *, Value *> ValueMap;
180+
ValueToValueMapTy ValueMap;
181181

182182
// For PHI nodes, the value available in OldPreHeader is just the
183183
// incoming value from OldPreHeader.
@@ -233,6 +233,11 @@ bool LoopRotate::rotateLoop(Loop *Lp, LPPassManager &LPM) {
233233
Value *OrigHeaderVal = I;
234234
Value *OrigPreHeaderVal = ValueMap[OrigHeaderVal];
235235

236+
// If there are no uses of the value (e.g. because it returns void), there
237+
// is nothing to rewrite.
238+
if (OrigHeaderVal->use_empty() && OrigPreHeaderVal->use_empty())
239+
continue;
240+
236241
// The value now exits in two versions: the initial value in the preheader
237242
// and the loop "next" value in the original header.
238243
SSA.Initialize(OrigHeaderVal->getType(), OrigHeaderVal->getName());

0 commit comments

Comments
 (0)