forked from OSchip/llvm-project
[Reassociate] Try to bail out early when canonicalizing.
This commit rearranges the checks to avoid calls to getRank() when not needed (e.g. when RHS == LHS). llvm-svn: 310237
This commit is contained in:
parent
305d3164f2
commit
a5cdc22e70
|
@ -207,13 +207,9 @@ void ReassociatePass::canonicalizeOperands(Instruction *I) {
|
||||||
|
|
||||||
Value *LHS = I->getOperand(0);
|
Value *LHS = I->getOperand(0);
|
||||||
Value *RHS = I->getOperand(1);
|
Value *RHS = I->getOperand(1);
|
||||||
unsigned LHSRank = getRank(LHS);
|
if (LHS == RHS || isa<Constant>(RHS))
|
||||||
unsigned RHSRank = getRank(RHS);
|
|
||||||
|
|
||||||
if (isa<Constant>(RHS))
|
|
||||||
return;
|
return;
|
||||||
|
if (isa<Constant>(LHS) || getRank(RHS) < getRank(LHS))
|
||||||
if (isa<Constant>(LHS) || RHSRank < LHSRank)
|
|
||||||
cast<BinaryOperator>(I)->swapOperands();
|
cast<BinaryOperator>(I)->swapOperands();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue