[MachineCSE] Clear kill-flag on registers imp-def'd by the CSE'd instruction.
authorAhmed Bougacha <ahmed.bougacha@gmail.com>
Tue, 2 Dec 2014 18:09:51 +0000 (18:09 +0000)
committerAhmed Bougacha <ahmed.bougacha@gmail.com>
Tue, 2 Dec 2014 18:09:51 +0000 (18:09 +0000)
commit54b7d334c7d1c5e0a28f91852fdbeae2da464565
tree54bb62a6c350224ae0cd93c01f9212b01efa39eb
parentf7a104254aa1d9cb26136accce3dbf5aca2233b2
[MachineCSE] Clear kill-flag on registers imp-def'd by the CSE'd instruction.

Go through implicit defs of CSMI and MI, and clear the kill flags on
their uses in all the instructions between CSMI and MI.
We might have made some of the kill flags redundant, consider:
  subs  ... %NZCV<imp-def>        <- CSMI
  csinc ... %NZCV<imp-use,kill>   <- this kill flag isn't valid anymore
  subs  ... %NZCV<imp-def>        <- MI, to be eliminated
  csinc ... %NZCV<imp-use,kill>
Since we eliminated MI, and reused a register imp-def'd by CSMI
(here %NZCV), that register, if it was killed before MI, should have
that kill flag removed, because it's lifetime was extended.

Also, add an exhaustive testcase for the motivating example.

Reviewed by: Juergen Ributzka <juergen@apple.com>

llvm-svn: 223133
llvm/lib/CodeGen/MachineCSE.cpp
llvm/test/CodeGen/AArch64/machine_cse_impdef_killflags.ll [new file with mode: 0644]