[llvm-commits] CVS: llvm/lib/Transforms/Scalar/InstructionCombining.cpp
Reid Spencer
reid at x10sys.com
Sun Mar 25 12:32:03 PDT 2007
On Sun, 2007-03-25 at 12:25 -0700, Chris Lattner wrote:
> >
> >>> +/// SubOne - Subtract one from a ConstantInt
> >>> static ConstantInt *SubOne(ConstantInt *C) {
> >>
> >> Shouldn't these use ++/-- on APInt? That seems more efficient.
> >
> > I should really have these functions declare the parameter
> > constant. We
> > don't want to increment the APInt inside C. Either way, a copy of the
> > value is being made.
>
> Right. ConstantInt's are immutable, so it doesn't really need to be
> marked const. I'm saying that the implementation of these methods
> shouldn't build a "1" apint, then add it. Instead, it should just
> increment an apint with ++.
Yup. I've already changed it to:
static ConstantInt *AddOne(ConstantInt *C) {
APInt Val(C->getValue());
return ConstantInt::get(++Val);
}
Reid.
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20070325/44273668/attachment.sig>
More information about the llvm-commits
mailing list