[llvm-commits] [llvm] r164684 - in /llvm/trunk: lib/Transforms/Utils/SimplifyCFG.cpp test/Transforms/SimplifyCFG/switch_to_lookup_table.ll
Duncan Sands
baldrick at free.fr
Wed Sep 26 06:38:18 PDT 2012
Hi Hans, thanks for doing this.
> diff --git a/include/llvm/IRBuilder.h b/include/llvm/IRBuilder.h
> index ff64660..3f2abc2 100644
> --- a/include/llvm/IRBuilder.h
> +++ b/include/llvm/IRBuilder.h
> @@ -995,6 +995,32 @@ public:
> Value *CreateSExt(Value *V, Type *DestTy, const Twine &Name = "") {
> return CreateCast(Instruction::SExt, V, DestTy, Name);
> }
> + /// CreateZExtOrTrunc - Create a ZExt or Trunc from the integer value V to
> + /// DestTy. Return the value untouched if the type of V is already DestTy.
> + Value *CreateZExtOrTrunc(Value *V, IntegerType *DestTy,
> + const Twine &Name = "") {
> + assert(isa<IntegerType>(V->getType()) && "Can only ZExt integer values!");
How about: Can only zero extend integer values!
> + IntegerType *IntTy = cast<IntegerType>(V->getType());
> + if (IntTy->getBitWidth() < DestTy->getBitWidth())
> + return CreateZExt(V, DestTy, Name);
> + else if (IntTy->getBitWidth() > DestTy->getBitWidth())
No need for "else" because the previous line returns (style).
> + return CreateTrunc(V, DestTy, Name);
> + else
Likewise.
Analogous comments for the sext version.
Otherwise LGTM.
Ciao, Duncan.
More information about the llvm-commits
mailing list