summaryrefslogtreecommitdiffstats
path: root/llvm/lib/TableGen/JSONBackend.cpp
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@intel.com>2018-07-11 06:57:42 +0000
committerCraig Topper <craig.topper@intel.com>2018-07-11 06:57:42 +0000
commit02867f0fa3e6bb1586a313a3cf4540f80538b02a (patch)
tree9c33be1549286625bf7a64ac29b52988d1b8e83c /llvm/lib/TableGen/JSONBackend.cpp
parent709f773a8884bb74239aac16d91deea8591a5ede (diff)
downloadbcm5719-llvm-02867f0fa3e6bb1586a313a3cf4540f80538b02a.tar.gz
bcm5719-llvm-02867f0fa3e6bb1586a313a3cf4540f80538b02a.zip
[X86] The TEST instruction is eliminated when BSF/TZCNT is used
Summary: These changes cover the PR#31399. Now the ffs(x) function is lowered to (x != 0) ? llvm.cttz(x) + 1 : 0 and it corresponds to the following llvm code: %cnt = tail call i32 @llvm.cttz.i32(i32 %v, i1 true) %tobool = icmp eq i32 %v, 0 %.op = add nuw nsw i32 %cnt, 1 %add = select i1 %tobool, i32 0, i32 %.op and x86 asm code: bsfl %edi, %ecx addl $1, %ecx testl %edi, %edi movl $0, %eax cmovnel %ecx, %eax In this case the 'test' instruction can't be eliminated because the 'add' instruction modifies the EFLAGS, namely, ZF flag that is set by the 'bsf' instruction when 'x' is zero. We now produce the following code: bsfl %edi, %ecx movl $-1, %eax cmovnel %ecx, %eax addl $1, %eax Patch by Ivan Kulagin Reviewers: davide, craig.topper, spatel, RKSimon Reviewed By: craig.topper Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D48765 llvm-svn: 336768
Diffstat (limited to 'llvm/lib/TableGen/JSONBackend.cpp')
0 files changed, 0 insertions, 0 deletions
OpenPOWER on IntegriCloud