Allow MachineCSE to coalesce trivial subregister copies the same way that it coalesce...
authorAndrew Trick <atrick@apple.com>
Tue, 17 Dec 2013 04:50:45 +0000 (04:50 +0000)
committerAndrew Trick <atrick@apple.com>
Tue, 17 Dec 2013 04:50:45 +0000 (04:50 +0000)
commitc4c5a1d526cc3dcb140a1f74f52bfd7f8f1a9442
treed7f7203eea7a5e1d7c088b51a267635fb5c38ec3
parent8b81765f7386975762d9abe7d521a277d7ffdfec
Allow MachineCSE to coalesce trivial subregister copies the same way that it coalesces normal copies.

Without this, MachineCSE is powerless to handle redundant operations with truncated source operands.

This required fixing the 2-addr pass to handle tied subregisters. It isn't clear what combinations of subregisters can legally be tied, but the simple case of truncated source operands is now safely handled:

     %vreg11<def> = COPY %vreg1:sub_32bit; GR32:%vreg11 GR64:%vreg1
     %vreg12<def> = COPY %vreg2:sub_32bit; GR32:%vreg12 GR64:%vreg2
     %vreg13<def,tied1> = ADD32rr %vreg11<tied0>, %vreg12<kill>, %EFLAGS<imp-def>

Test case: cse-add-with-overflow.ll.

This exposed an existing bug in
PPCInstrInfo::commuteInstruction. Thanks to Rafael for the test case:
PowerPC/crash.ll.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@197465 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/MachineCSE.cpp
lib/CodeGen/TwoAddressInstructionPass.cpp
lib/Target/PowerPC/PPCInstrInfo.cpp
lib/Target/R600/SIInstrInfo.cpp
test/CodeGen/X86/cmov.ll
test/CodeGen/X86/cse-add-with-overflow.ll [new file with mode: 0644]