[AArch64] Don't optimize all compare instructions.
authorJuergen Ributzka <juergen@apple.com>
Tue, 18 Nov 2014 21:02:40 +0000 (21:02 +0000)
committerJuergen Ributzka <juergen@apple.com>
Tue, 18 Nov 2014 21:02:40 +0000 (21:02 +0000)
commit50fa2ff5d278fc012ba2942c4c98d678a2ee6348
tree4a9e74f5bd59d2035283c534694badef911e2c94
parentb39e517168db7f94d6515eeb745a5b7625c6d365
[AArch64] Don't optimize all compare instructions.

"optimizeCompareInstr" converts compares (cmp/cmn) into plain sub/add
instructions when the flags are not used anymore. This conversion is valid for
most instructions, but not all. Some instructions that don't set the flags
(e.g. sub with immediate) can set the SP, whereas the flag setting version uses
the same encoding for the "zero" register.

Update the code to also check for the return register before performing the
optimization to make sure that a cmp doesn't suddenly turn into a sub that sets
the stack pointer.

I don't have a test case for this, because it isn't easy to trigger.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@222255 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/AArch64/AArch64InstrInfo.cpp