[llvm-commits] [llvm] r122596 - /llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp

Cameron Zwarich zwarich at apple.com
Tue Dec 28 12:46:27 PST 2010


On Dec 28, 2010, at 11:14 AM, Bob Wilson wrote:

> On Dec 28, 2010, at 2:49 AM, Cameron Zwarich wrote:
> 
>> Author: zwarich
>> Date: Tue Dec 28 04:49:33 2010
>> New Revision: 122596
>> 
>> URL: http://llvm.org/viewvc/llvm-project?rev=122596&view=rev
>> Log:
>> Avoid iterating every operand of an instruction in StrongPHIElimination, since
>> we are only interested in the defs when discovering interferences.
>> 
>> This is a 28% speedup running StrongPHIElimination on 403.gcc.
>> 
>> Modified:
>>   llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp
>> 
>> Modified: llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp
>> URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp?rev=122596&r1=122595&r2=122596&view=diff
>> ==============================================================================
>> --- llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp (original)
>> +++ llvm/trunk/lib/CodeGen/StrongPHIElimination.cpp Tue Dec 28 04:49:33 2010
>> @@ -471,10 +471,9 @@
>>    DenseMap<unsigned, unsigned>& ImmediateDominatingParent) {
>>  for (MachineBasicBlock::iterator BBI = MBB.begin(), BBE = MBB.end();
>>  BBI != BBE; ++BBI) {
>> -    for (unsigned i = 0, e = BBI->getNumOperands(); i != e; ++i) {
>> -      MachineOperand& MO = BBI->getOperand(i);
>> -      if (!MO.isReg() || !MO.isDef())
>> -        continue;
>> +    for (MachineInstr::const_mop_iterator I = BBI->operands_begin(),
>> +         E = BBI->operands_end(); I != E && I->isReg() && I->isDef(); ++I) {
>> +      const MachineOperand& MO = *I;
> 
> This is relying on the register def operands being first.  I'm not sure that's always true.  OptionalDefOperands, like cc_out for ARM, may come later in the operand list.

Aren't optional defs only for physical registers? This code is only interested in defs of registers that appear in phis.

Cameron



More information about the llvm-commits mailing list