[llvm-commits] CVS: llvm/lib/Transforms/IPO/IndMemRemoval.cpp RaiseAllocations.cpp SimplifyLibCalls.cpp

Chris Lattner clattner at apple.com
Tue Dec 12 20:51:43 PST 2006


> @@ -1738,16 +1739,16 @@
>      }
>
>      // isdigit(c)   -> (unsigned)c - '0' <= 9
> -    CastInst* cast = CastInst::createInferredCast(ci->getOperand(1),
> -        Type::UIntTy, ci->getOperand(1)->getName()+".uint", ci);
> +    CastInst* cast = CastInst::createIntegerCast(ci->getOperand(1),
> +        Type::UIntTy, false/*ZExt*/, ci->getOperand(1)->getName() 
> +".uint", ci);
>      BinaryOperator* sub_inst = BinaryOperator::createSub(cast,
>          ConstantInt::get(Type::UIntTy,0x30),
>          ci->getOperand(1)->getName()+".sub",ci);
>      SetCondInst* setcond_inst = new SetCondInst 
> (Instruction::SetLE,sub_inst,
>          ConstantInt::get(Type::UIntTy,9),
>          ci->getOperand(1)->getName()+".cmp",ci);
> -    CastInst* c2 = CastInst::createInferredCast(
> -        setcond_inst, Type::IntTy, ci->getOperand(1)->getName() 
> +".isdigit", ci);
> +    CastInst* c2 = new SExtInst(setcond_inst, Type::IntTy,
> +        ci->getOperand(1)->getName()+".isdigit", ci);

This should be a zext instruction not sext.  isdigit returns 0/1 not  
0/-1.


> @@ -1870,10 +1870,11 @@
>
>      Function *F = SLC.getModule()->getOrInsertFunction(CTTZName,  
> ArgType,
>                                                         ArgType,  
> NULL);
> -    Value *V = CastInst::createInferredCast(
> -        TheCall->getOperand(1), ArgType, "tmp", TheCall);
> +    Value *V = CastInst::createIntegerCast(TheCall->getOperand(1),  
> ArgType,
> +                                           false/*ZExt*/, "tmp",  
> TheCall);
>      Value *V2 = new CallInst(F, V, "tmp", TheCall);
> -    V2 = CastInst::createInferredCast(V2, Type::IntTy, "tmp",  
> TheCall);
> +    V2 = CastInst::createIntegerCast(V2, Type::IntTy, true/*SExt*/,
> +                                     "tmp", TheCall);

This should be zext, not sext.

Why did you choose sext for these?


>      V2 = BinaryOperator::createAdd(V2, ConstantInt::get 
> (Type::IntTy, 1),
>                                     "tmp", TheCall);
>      Value *Cond =
> @@ -2116,9 +2117,11 @@
>  /// inserting the cast before IP, and return the cast.
>  /// @brief Cast a value to a "C" string.
>  Value *CastToCStr(Value *V, Instruction &IP) {
> +  assert(V->getType()->getTypeID() == Type::PointerTyID &&
> +         "Can't cast non-pointer type to C string type");

isa<PointerType>(V->getType()) please.

Thanks Reid,

-Chris






More information about the llvm-commits mailing list