X86: If we have an instruction that sets a flag and a zero test on the input of that...
authorBenjamin Kramer <benny.kra@googlemail.com>
Wed, 14 May 2014 16:14:45 +0000 (16:14 +0000)
committerBenjamin Kramer <benny.kra@googlemail.com>
Wed, 14 May 2014 16:14:45 +0000 (16:14 +0000)
commit202be0631841c7bdab1818d1c218765a5a4f99e8
treed1ee8a2ae771951fb07d6651d1e3812ae1457a2d
parentf6741d6bddcba58a602c653d789c508b712ab6c8
X86: If we have an instruction that sets a flag and a zero test on the input of that instruction try to eliminate the test.

For example
tzcntl %edi, %ebx
testl %edi, %edi
je .label

can be rewritten into
tzcntl %edi, %ebx
jb  .label

A minor complication is that tzcnt sets CF instead of ZF when the input
is zero, we have to rewrite users of the flags from ZF to CF. Currently
we recognize patterns using lzcnt, tzcnt and popcnt.

Differential Revision: http://reviews.llvm.org/D3454

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@208788 91177308-0d34-0410-b5e6-96231b3b80d8
lib/Target/X86/X86InstrInfo.cpp
test/CodeGen/X86/peep-test-4.ll