[llvm-commits] [llvm] r49048 - in /llvm/trunk: lib/Target/X86/X86ISelLowering.cpp lib/Target/X86/X86Subtarget.cpp lib/Target/X86/X86Subtarget.h test/CodeGen/X86/darwin-bzero.ll
Dan Gohman
gohman at apple.com
Tue Apr 1 13:38:36 PDT 2008
Author: djg
Date: Tue Apr 1 15:38:36 2008
New Revision: 49048
URL: http://llvm.org/viewvc/llvm-project?rev=49048&view=rev
Log:
Speculatively micro-optimize memory-zeroing calls on Darwin 10.
Added:
llvm/trunk/test/CodeGen/X86/darwin-bzero.ll
Modified:
llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
llvm/trunk/lib/Target/X86/X86Subtarget.cpp
llvm/trunk/lib/Target/X86/X86Subtarget.h
Modified: llvm/trunk/lib/Target/X86/X86ISelLowering.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86ISelLowering.cpp?rev=49048&r1=49047&r2=49048&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86ISelLowering.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86ISelLowering.cpp Tue Apr 1 15:38:36 2008
@@ -4560,6 +4560,11 @@
// address value and run time information about the CPU.
if ((Align & 3) != 0 ||
(I && I->getValue() > Subtarget->getMaxInlineSizeThreshold())) {
+
+ // Check to see if there is a specialized entry-point for memory zeroing.
+ const char *bzeroEntry = Subtarget->getBZeroEntry();
+ ConstantSDNode *V = dyn_cast<ConstantSDNode>(Op.getOperand(2));
+
MVT::ValueType IntPtr = getPointerTy();
const Type *IntPtrTy = getTargetData()->getIntPtrType();
TargetLowering::ArgListTy Args;
@@ -4567,15 +4572,20 @@
Entry.Node = Op.getOperand(1);
Entry.Ty = IntPtrTy;
Args.push_back(Entry);
- // Extend the unsigned i8 argument to be an int value for the call.
- Entry.Node = DAG.getNode(ISD::ZERO_EXTEND, MVT::i32, Op.getOperand(2));
- Entry.Ty = IntPtrTy;
- Args.push_back(Entry);
+
+ if (!bzeroEntry) {
+ // Extend the unsigned i8 argument to be an int value for the call.
+ Entry.Node = DAG.getNode(ISD::ZERO_EXTEND, MVT::i32, Op.getOperand(2));
+ Entry.Ty = IntPtrTy;
+ Args.push_back(Entry);
+ }
+
Entry.Node = Op.getOperand(3);
Args.push_back(Entry);
+ const char *Name = bzeroEntry ? bzeroEntry : "memset";
std::pair<SDOperand,SDOperand> CallResult =
LowerCallTo(Chain, Type::VoidTy, false, false, false, CallingConv::C,
- false, DAG.getExternalSymbol("memset", IntPtr), Args, DAG);
+ false, DAG.getExternalSymbol(Name, IntPtr), Args, DAG);
return CallResult.second;
}
Modified: llvm/trunk/lib/Target/X86/X86Subtarget.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.cpp?rev=49048&r1=49047&r2=49048&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86Subtarget.cpp (original)
+++ llvm/trunk/lib/Target/X86/X86Subtarget.cpp Tue Apr 1 15:38:36 2008
@@ -53,6 +53,20 @@
return false;
}
+/// This function returns the name of a function which has an interface
+/// like the non-standard bzero function, if such a function exists on
+/// the current subtarget and it is considered prefereable over
+/// memset with zero passed as the second argument. Otherwise it
+/// returns null.
+const char *X86Subtarget::getBZeroEntry() const {
+
+ // Darwin 10 has a __bzero entry point for this purpose.
+ if (getDarwinVers() >= 10)
+ return "__bzero";
+
+ return 0;
+}
+
/// GetCpuIDAndInfo - Execute the specified cpuid and return the 4 values in the
/// specified arguments. If we can't run cpuid on the host, return true.
bool X86::GetCpuIDAndInfo(unsigned value, unsigned *rEAX, unsigned *rEBX,
Modified: llvm/trunk/lib/Target/X86/X86Subtarget.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Target/X86/X86Subtarget.h?rev=49048&r1=49047&r2=49048&view=diff
==============================================================================
--- llvm/trunk/lib/Target/X86/X86Subtarget.h (original)
+++ llvm/trunk/lib/Target/X86/X86Subtarget.h Tue Apr 1 15:38:36 2008
@@ -171,6 +171,12 @@
bool GVRequiresExtraLoad(const GlobalValue* GV, const TargetMachine& TM,
bool isDirectCall) const;
+ /// This function returns the name of a function which has an interface
+ /// like the non-standard bzero function, if such a function exists on
+ /// the current subtarget and it is considered prefereable over
+ /// memset with zero passed as the second argument. Otherwise it
+ /// returns null.
+ const char *getBZeroEntry() const;
};
namespace X86 {
Added: llvm/trunk/test/CodeGen/X86/darwin-bzero.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/CodeGen/X86/darwin-bzero.ll?rev=49048&view=auto
==============================================================================
--- llvm/trunk/test/CodeGen/X86/darwin-bzero.ll (added)
+++ llvm/trunk/test/CodeGen/X86/darwin-bzero.ll Tue Apr 1 15:38:36 2008
@@ -0,0 +1,8 @@
+; RUN: llvm-as < %s | llc -mtriple=i386-apple-darwin10 | grep __bzero
+
+declare void @llvm.memset.i32(i8*, i8, i32, i32)
+
+define void @foo(i8* %p, i32 %len) {
+ call void @llvm.memset.i32(i8* %p, i8 0, i32 %len, i32 1);
+ ret void
+}
More information about the llvm-commits
mailing list