[SystemZ] Use SRST to optimize memchr
authorRichard Sandiford <rsandifo@linux.vnet.ibm.com>
Tue, 20 Aug 2013 09:38:48 +0000 (09:38 +0000)
committerRichard Sandiford <rsandifo@linux.vnet.ibm.com>
Tue, 20 Aug 2013 09:38:48 +0000 (09:38 +0000)
commit8c20158fb0e1e5d747077f065eb0170c5af1fbfa
treea5028d38ab70ecdac91c2e7d4cb257931f18e978
parent74e81aae7c07b0619a77a5a0a56fdb954ce4b8fd
[SystemZ] Use SRST to optimize memchr

SystemZTargetLowering::emitStringWrapper() previously loaded the character
into R0 before the loop and made R0 live on entry.  I'd forgotten that
allocatable registers weren't allowed to be live across blocks at this stage,
and it confused LiveVariables enough to cause a miscompilation of f3 in
memchr-02.ll.

This patch instead loads R0 in the loop and leaves LICM to hoist it
after RA.  This is actually what I'd tried originally, but I went for
the manual optimisation after noticing that R0 often wasn't being hoisted.
This bug forced me to go back and look at why, now fixed as r188774.

We should also try to optimize null checks so that they test the CC result
of the SRST directly.  The select between null and the SRST GPR result could
then usually be deleted as dead.

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@188779 91177308-0d34-0410-b5e6-96231b3b80d8
include/llvm/Target/TargetLibraryInfo.h
include/llvm/Target/TargetSelectionDAGInfo.h
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.cpp
lib/CodeGen/SelectionDAG/SelectionDAGBuilder.h
lib/Target/SystemZ/SystemZ.h
lib/Target/SystemZ/SystemZISelLowering.cpp
lib/Target/SystemZ/SystemZSelectionDAGInfo.cpp
lib/Target/SystemZ/SystemZSelectionDAGInfo.h
test/CodeGen/SystemZ/memchr-01.ll [new file with mode: 0644]
test/CodeGen/SystemZ/memchr-02.ll [new file with mode: 0644]