[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)
commit88d2b5812ae6ac3f4ab3e11107fba2a8751198df
treec9ef0a150bc1d6306981fe429afeba2d40433fc8
parent712af374c19d6f4803a87da94b2f85190e53acf8
[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>

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@223133 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/MachineCSE.cpp
test/CodeGen/AArch64/machine_cse_impdef_killflags.ll [new file with mode: 0644]