mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-07-28 03:25:23 +00:00
[Reassociate] Canonicalize constants to RHS operand.
Fix a thinko where the RHS was already a constant. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222139 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@@ -332,6 +332,7 @@ unsigned Reassociate::getRank(Value *V) {
|
||||
return ValueRankMap[I] = Rank;
|
||||
}
|
||||
|
||||
// Canonicalize constants to RHS. Otherwise, sort the operands by rank.
|
||||
void Reassociate::canonicalizeOperands(Instruction *I) {
|
||||
assert(isa<BinaryOperator>(I) && "Expected binary operator.");
|
||||
assert(I->isCommutative() && "Expected commutative operator.");
|
||||
@@ -341,7 +342,9 @@ void Reassociate::canonicalizeOperands(Instruction *I) {
|
||||
unsigned LHSRank = getRank(LHS);
|
||||
unsigned RHSRank = getRank(RHS);
|
||||
|
||||
// Canonicalize constants to RHS. Otherwise, sort the operands by rank.
|
||||
if (isa<Constant>(RHS))
|
||||
return;
|
||||
|
||||
if (isa<Constant>(LHS) || RHSRank < LHSRank)
|
||||
cast<BinaryOperator>(I)->swapOperands();
|
||||
}
|
||||
|
Reference in New Issue
Block a user