[Sparc] Use ANDN instead of AND if constant can be encoded more efficiently
authorDaniel Cederman <cederman@gaisler.com>
Thu, 30 Aug 2018 14:05:26 +0000 (14:05 +0000)
committerDaniel Cederman <cederman@gaisler.com>
Thu, 30 Aug 2018 14:05:26 +0000 (14:05 +0000)
commit8f0bf6c19af03da36dbcca969f3500fdd4619df9
tree3f23fab24bc836649ce7a76ecf81710733f0ec8a
parent201f892b3b597f24287ab6a712a286e25a45a7d9
[Sparc] Use ANDN instead of AND if constant can be encoded more efficiently

Summary:
In the case of (and reg, constant) or (or reg, constant), it can be
beneficial to use a ANDNrr/ORNrr instruction instead of ANDrr/ORrr,
if the complement of the constant can be encoded using a single SETHI
instruction instead of a SETHI/ORri pair.

If the constant has more than one use, it is probably better to keep it
in its original form.

Reviewers: jyknight, venkatra

Reviewed By: jyknight

Subscribers: fedor.sergeev, jrtc27, llvm-commits

Differential Revision: https://reviews.llvm.org/D50964

llvm-svn: 341069
llvm/lib/Target/Sparc/SparcInstrInfo.td
llvm/test/CodeGen/SPARC/sethiandn.ll [new file with mode: 0644]