Skip to content

Commit 684fa5a

Browse files
committed
Be more accurate
llvm-svn: 12464
1 parent 10a8d73 commit 684fa5a

File tree

1 file changed

+15
-4
lines changed

1 file changed

+15
-4
lines changed

llvm/lib/Transforms/Scalar/GCSE.cpp

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,11 @@ Instruction *GCSE::EliminateCSE(Instruction *I, Instruction *Other) {
223223
Instruction *Second = I != First ? I : Other; // Get iterator to second inst
224224
BI = Second;
225225

226+
if (isa<LoadInst>(Second))
227+
++NumLoadRemoved; // Keep track of loads eliminated
228+
if (isa<CallInst>(Second))
229+
++NumCallRemoved; // Keep track of calls eliminated
230+
226231
// Destroy Second, using First instead.
227232
ReplaceInstWithInst(First, BI);
228233
Ret = First;
@@ -231,9 +236,19 @@ Instruction *GCSE::EliminateCSE(Instruction *I, Instruction *Other) {
231236
// dominates the other instruction, we can simply use it
232237
//
233238
} else if (DomSetInfo->dominates(BB1, BB2)) { // I dom Other?
239+
if (isa<LoadInst>(Other))
240+
++NumLoadRemoved; // Keep track of loads eliminated
241+
if (isa<CallInst>(Other))
242+
++NumCallRemoved; // Keep track of calls eliminated
243+
234244
ReplaceInstWithInst(I, Other);
235245
Ret = I;
236246
} else if (DomSetInfo->dominates(BB2, BB1)) { // Other dom I?
247+
if (isa<LoadInst>(I))
248+
++NumLoadRemoved; // Keep track of loads eliminated
249+
if (isa<CallInst>(I))
250+
++NumCallRemoved; // Keep track of calls eliminated
251+
237252
ReplaceInstWithInst(Other, I);
238253
Ret = Other;
239254
} else {
@@ -266,10 +281,6 @@ Instruction *GCSE::EliminateCSE(Instruction *I, Instruction *Other) {
266281
return 0;
267282
}
268283

269-
if (isa<LoadInst>(Ret))
270-
++NumLoadRemoved; // Keep track of loads eliminated
271-
if (isa<CallInst>(Ret))
272-
++NumCallRemoved; // Keep track of calls eliminated
273284
++NumInstRemoved; // Keep track of number of instructions eliminated
274285

275286
// Add all users of Ret to the worklist...

0 commit comments

Comments
 (0)