// This transformation requires natural loop information...
virtual void getAnalysisUsage(AnalysisUsage &AU) const {
AU.preservesCFG();
- AU.addRequired(LoopInfo::ID);
+ AU.addRequired<LoopInfo>();
}
private:
// the specified instruction types are hoisted.
//
friend class InstVisitor<LICM>;
- void visitUnaryOperator(Instruction &I) {
- if (isLoopInvariant(I.getOperand(0))) hoist(I);
- }
void visitBinaryOperator(Instruction &I) {
if (isLoopInvariant(I.getOperand(0)) && isLoopInvariant(I.getOperand(1)))
hoist(I);
}
-
- void visitCastInst(CastInst &I) { visitUnaryOperator((Instruction&)I); }
+ void visitCastInst(CastInst &I) {
+ if (isLoopInvariant(I.getOperand(0))) hoist((Instruction&)I);
+ }
void visitShiftInst(ShiftInst &I) { visitBinaryOperator((Instruction&)I); }
void visitGetElementPtrInst(GetElementPtrInst &GEPI) {
}
};
- RegisterPass<LICM> X("licm", "Loop Invariant Code Motion");
+ RegisterOpt<LICM> X("licm", "Loop Invariant Code Motion");
}
Pass *createLICMPass() { return new LICM(); }