projects
/
platform
/
upstream
/
llvm.git
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
| inline |
side by side
(parent:
305d316
)
[Reassociate] Try to bail out early when canonicalizing.
author
Davide Italiano
<davide@freebsd.org>
Mon, 7 Aug 2017 01:49:09 +0000
(
01:49
+0000)
committer
Davide Italiano
<davide@freebsd.org>
Mon, 7 Aug 2017 01:49:09 +0000
(
01:49
+0000)
This commit rearranges the checks to avoid calls to getRank()
when not needed (e.g. when RHS == LHS).
llvm-svn: 310237
llvm/lib/Transforms/Scalar/Reassociate.cpp
patch
|
blob
|
history
diff --git
a/llvm/lib/Transforms/Scalar/Reassociate.cpp
b/llvm/lib/Transforms/Scalar/Reassociate.cpp
index
29d1ba4
..
404daa7
100644
(file)
--- a/
llvm/lib/Transforms/Scalar/Reassociate.cpp
+++ b/
llvm/lib/Transforms/Scalar/Reassociate.cpp
@@
-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();
}