Fix two-address pass's aggressive instruction commuting heuristics. It's meant
authorEvan Cheng <evan.cheng@apple.com>
Thu, 3 May 2012 01:45:13 +0000 (01:45 +0000)
committerEvan Cheng <evan.cheng@apple.com>
Thu, 3 May 2012 01:45:13 +0000 (01:45 +0000)
commitd99d68bcee8ce91a18c397756c702363e030fd83
tree1b61e12685ff3f767c998a31444d09201f8cc828
parentf12f6dff9784805e8f89309787231c1ec53a8c6e
Fix two-address pass's aggressive instruction commuting heuristics. It's meant
to catch cases like:
 %reg1024<def> = MOV r1
 %reg1025<def> = MOV r0
 %reg1026<def> = ADD %reg1024, %reg1025
 r0            = MOV %reg1026

By commuting ADD, it let coalescer eliminate all of the copies. However, there
was a bug in the heuristics where it ended up commuting the ADD in:

 %reg1024<def> = MOV r0
 %reg1025<def> = MOV 0
 %reg1026<def> = ADD %reg1024, %reg1025
 r0            = MOV %reg1026

That did no benefit but rather ensure the last MOV would not be coalesced.

rdar://11355268

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@156048 91177308-0d34-0410-b5e6-96231b3b80d8
lib/CodeGen/TwoAddressInstructionPass.cpp
test/CodeGen/X86/4char-promote.ll
test/CodeGen/X86/jump_sign.ll