summaryrefslogtreecommitdiff
path: root/include
diff options
context:
space:
mode:
authorRichard Sandiford <rsandifo@linux.vnet.ibm.com>2013-08-20 09:38:48 +0000
committerRichard Sandiford <rsandifo@linux.vnet.ibm.com>2013-08-20 09:38:48 +0000
commit8c20158fb0e1e5d747077f065eb0170c5af1fbfa (patch)
treea5028d38ab70ecdac91c2e7d4cb257931f18e978 /include
parent74e81aae7c07b0619a77a5a0a56fdb954ce4b8fd (diff)
downloadllvm-8c20158fb0e1e5d747077f065eb0170c5af1fbfa.tar.gz
llvm-8c20158fb0e1e5d747077f065eb0170c5af1fbfa.tar.bz2
llvm-8c20158fb0e1e5d747077f065eb0170c5af1fbfa.tar.xz
[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
Diffstat (limited to 'include')
-rw-r--r--include/llvm/Target/TargetLibraryInfo.h1
-rw-r--r--include/llvm/Target/TargetSelectionDAGInfo.h12
2 files changed, 13 insertions, 0 deletions
diff --git a/include/llvm/Target/TargetLibraryInfo.h b/include/llvm/Target/TargetLibraryInfo.h
index 50b16a355d..9111cb1ff0 100644
--- a/include/llvm/Target/TargetLibraryInfo.h
+++ b/include/llvm/Target/TargetLibraryInfo.h
@@ -701,6 +701,7 @@ public:
case LibFunc::exp2: case LibFunc::exp2f: case LibFunc::exp2l:
case LibFunc::memcmp: case LibFunc::strcmp: case LibFunc::strcpy:
case LibFunc::stpcpy: case LibFunc::strlen: case LibFunc::strnlen:
+ case LibFunc::memchr:
return true;
}
return false;
diff --git a/include/llvm/Target/TargetSelectionDAGInfo.h b/include/llvm/Target/TargetSelectionDAGInfo.h
index 138ff48196..3474ee493e 100644
--- a/include/llvm/Target/TargetSelectionDAGInfo.h
+++ b/include/llvm/Target/TargetSelectionDAGInfo.h
@@ -109,6 +109,18 @@ public:
return std::make_pair(SDValue(), SDValue());
}
+ /// EmitTargetCodeForMemchr - Emit target-specific code that performs a
+ /// memchr, in cases where that is faster than a libcall. The first
+ /// returned SDValue is the result of the memchr and the second is
+ /// the chain. Both SDValues can be null if a normal libcall should
+ /// be used.
+ virtual std::pair<SDValue, SDValue>
+ EmitTargetCodeForMemchr(SelectionDAG &DAG, SDLoc dl, SDValue Chain,
+ SDValue Src, SDValue Char, SDValue Length,
+ MachinePointerInfo SrcPtrInfo) const {
+ return std::make_pair(SDValue(), SDValue());
+ }
+
/// EmitTargetCodeForStrcpy - Emit target-specific code that performs a
/// strcpy or stpcpy, in cases where that is faster than a libcall.
/// The first returned SDValue is the result of the copy (the start