mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-25 00:24:26 +00:00
Give the Reassociate pass a bit more flexibility and autonomy when optimizing expressions.
Particularly, it addresses cases where Reassociate breaks Subtracts but then fails to optimize combinations like I1 + -I2 where I1 and I2 have the same rank and are identical. Patch by Dmitri Shtilman. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@219092 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -1034,13 +1034,23 @@ static unsigned FindInOperandList(SmallVectorImpl<ValueEntry> &Ops, unsigned i,
|
||||
Value *X) {
|
||||
unsigned XRank = Ops[i].Rank;
|
||||
unsigned e = Ops.size();
|
||||
for (unsigned j = i+1; j != e && Ops[j].Rank == XRank; ++j)
|
||||
for (unsigned j = i+1; j != e && Ops[j].Rank == XRank; ++j) {
|
||||
if (Ops[j].Op == X)
|
||||
return j;
|
||||
if (Instruction *I1 = dyn_cast<Instruction>(Ops[j].Op))
|
||||
if (Instruction *I2 = dyn_cast<Instruction>(X))
|
||||
if (I1->isIdenticalTo(I2))
|
||||
return j;
|
||||
}
|
||||
// Scan backwards.
|
||||
for (unsigned j = i-1; j != ~0U && Ops[j].Rank == XRank; --j)
|
||||
for (unsigned j = i-1; j != ~0U && Ops[j].Rank == XRank; --j) {
|
||||
if (Ops[j].Op == X)
|
||||
return j;
|
||||
if (Instruction *I1 = dyn_cast<Instruction>(Ops[j].Op))
|
||||
if (Instruction *I2 = dyn_cast<Instruction>(X))
|
||||
if (I1->isIdenticalTo(I2))
|
||||
return j;
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user