[llvm-commits] [llvm] r161728 - in /llvm/trunk: lib/CodeGen/MachineCSE.cpp test/CodeGen/X86/lsr-loop-exit-cond.ll test/CodeGen/X86/machine-cse.ll
Benjamin Kramer
benny.kra at gmail.com
Sat Aug 11 13:44:40 PDT 2012
On 11.08.2012, at 22:09, Jakob Stoklund Olesen <stoklund at 2pi.dk> wrote:
>
> On Aug 11, 2012, at 12:05 PM, Benjamin Kramer <benny.kra at googlemail.com> wrote:
>
>> Author: d0k
>> Date: Sat Aug 11 14:05:13 2012
>> New Revision: 161728
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=161728&view=rev
>> Log:
>> PR13578: Teach MachineCSE that instructions that use a constant register can be CSE'd safely.
>>
>> This is common e.g. when doing rip-relative addressing on x86_64.
>
> Nice.
>
>> - for (MCRegAliasIterator AI(Reg, TRI, true); AI.isValid(); ++AI)
>> - PhysRefs.insert(*AI);
>> + for (MCRegAliasIterator AI(Reg, TRI, true); AI.isValid(); ++AI) {
>> + // Reading constant physregs is ok.
>> + if (!MRI->isConstantPhysReg(*AI, *MBB->getParent()))
>> + PhysRefs.insert(*AI);
>
> It's safe to swap 'if' and 'for' here. The isConstantPhysReg() function already checks all aliases.
Fixed in r161729. Thanks Jakob!
- Ben
More information about the llvm-commits
mailing list