Re: [llvm-commits] [llvm] r42864 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/2007-10-10-EliminateMemCpy.ll

2007-10-12 Thread Chris Lattner
>>> In general memcpy handling is highly target specific. I'd be wary >>> of doing too >>> much in target-independent code, although I think the general idea >>> here is OK. >> >> I'm expecting target specific code generator to handle this if it >> is handling unaligned memcpy. >> No ? > > Might

Re: [llvm-commits] [llvm] r42864 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/2007-10-10-EliminateMemCpy.ll

2007-10-12 Thread Chris Lattner
On Oct 11, 2007, at 10:46 AM, Dale Johannesen wrote: > You aren't checking alignment when choosing the new pointer type. > Are you sure this works on machines that don't have misaligned load/ > store? The codegen should handle unaligned loads. Devang is setting the alignment of the load corre

Re: [llvm-commits] [llvm] r42864 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/2007-10-10-EliminateMemCpy.ll

2007-10-11 Thread Devang Patel
On Oct 11, 2007, at 3:26 PM, Dan Gohman wrote: > Oops, looking at this a little more, isn't the Size operand always in > straight bytes, and MTy always i8, just because of how llvm.memcpy is > declared? yes. nice catch! > Also, this code can be used for memmove as well as memcpy; since the >

Re: [llvm-commits] [llvm] r42864 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/2007-10-10-EliminateMemCpy.ll

2007-10-11 Thread Devang Patel
On Oct 11, 2007, at 3:08 PM, Dan Gohman wrote: >> + ConstantInt *MemOpLength = >> dyn_cast(CI.getOperand(3)); >> + if (isa(MI)) >> +if (MemOpLength) { > > Can you replace these two if statements with > > if (isa(MI) && MemOpLength) { > > ? > > Then the indentation of what

Re: [llvm-commits] [llvm] r42864 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/2007-10-10-EliminateMemCpy.ll

2007-10-11 Thread Dan Gohman
On Thu, Oct 11, 2007 at 05:08:55PM -0500, Dan Gohman wrote: > > +unsigned Size = MemOpLength->getZExtValue(); > > +unsigned Align = > > cast(CI.getOperand(4))->getZExtValue(); > > +const PointerType *PTy = > > cast(CI.getOperand(1)->getType()); > > +const Type *MTy

Re: [llvm-commits] [llvm] r42864 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/2007-10-10-EliminateMemCpy.ll

2007-10-11 Thread Dan Gohman
> + // If MemCpyInst length is 1/2/4/8 bytes then replace memcpy with > load/store Neat! > + ConstantInt *MemOpLength = dyn_cast(CI.getOperand(3)); > + if (isa(MI)) > +if (MemOpLength) { Can you replace these two if statements with if (isa(MI) && MemOpLength) { ?

Re: [llvm-commits] [llvm] r42864 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/2007-10-10-EliminateMemCpy.ll

2007-10-11 Thread Dale Johannesen
On Oct 11, 2007, at 10:54 AM, Devang Patel wrote: > > On Oct 11, 2007, at 10:46 AM, Dale Johannesen wrote: > >> You aren't checking alignment when choosing the new pointer type. >> Are you sure this works on machines that don't have misaligned >> load/store? >> >> In general memcpy handling is

Re: [llvm-commits] [llvm] r42864 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/2007-10-10-EliminateMemCpy.ll

2007-10-11 Thread Devang Patel
On Oct 11, 2007, at 10:46 AM, Dale Johannesen wrote: > You aren't checking alignment when choosing the new pointer type. > Are you sure this works on machines that don't have misaligned load/ > store? > > In general memcpy handling is highly target specific. I'd be wary > of doing too > much

Re: [llvm-commits] [llvm] r42864 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/2007-10-10-EliminateMemCpy.ll

2007-10-11 Thread Dale Johannesen
You aren't checking alignment when choosing the new pointer type. Are you sure this works on machines that don't have misaligned load/ store? In general memcpy handling is highly target specific. I'd be wary of doing too much in target-independent code, although I think the general idea here

[llvm-commits] [llvm] r42864 - in /llvm/trunk: lib/Transforms/Scalar/InstructionCombining.cpp test/Transforms/InstCombine/2007-10-10-EliminateMemCpy.ll

2007-10-11 Thread Devang Patel
Author: dpatel Date: Thu Oct 11 12:21:57 2007 New Revision: 42864 URL: http://llvm.org/viewvc/llvm-project?rev=42864&view=rev Log: Lower memcpy if it makes sense. Added: llvm/trunk/test/Transforms/InstCombine/2007-10-10-EliminateMemCpy.ll Modified: llvm/trunk/lib/Transforms/Scalar/Instruc