1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-10-20 03:23:01 +02:00

[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:
Davide Italiano 2017-08-07 01:49:09 +00:00
parent 7792eb189a
commit aeb942e819

View File

@ -207,13 +207,9 @@ void ReassociatePass::canonicalizeOperands(Instruction *I) {
Value *LHS = I->getOperand(0);
Value *RHS = I->getOperand(1);
unsigned LHSRank = getRank(LHS);
unsigned RHSRank = getRank(RHS);
if (isa<Constant>(RHS))
if (LHS == RHS || isa<Constant>(RHS))
return;
if (isa<Constant>(LHS) || RHSRank < LHSRank)
if (isa<Constant>(LHS) || getRank(RHS) < getRank(LHS))
cast<BinaryOperator>(I)->swapOperands();
}