[llvm-commits] CAST patch: #3: lib/Transforms (except instcombine)

Chris Lattner clattner at apple.com
Tue Nov 21 07:55:12 PST 2006


On Nov 20, 2006, at 11:40 PM, Reid Spencer wrote:

> Some questions ..
>
> On Mon, 2006-11-20 at 14:48 -0800, Chris Lattner wrote:
>
>>
>> @@ -1173,11 +1172,11 @@ static void ShrinkGlobalToBoolean(Global
>>
>>
>>
>>        std::string Name = LI->getName(); LI->setName("");
>>        LoadInst *NLI = new LoadInst(NewGV, Name+".b", LI);
>>        Value *NSI;
>>        if (IsOneZero)
>> -        NSI = new CastInst(NLI, LI->getType(), Name, LI);
>> +        NSI = CastInst::getCast(NLI, LI->getType(), Name, LI);
>>        else
>>          NSI = new SelectInst(NLI, OtherVal, InitVal, Name, LI);
>>
>>
>> This cast is always a zext, please be explicit.
>
> What if LI->getType() is BoolTy? You can't ZExt Bool to Bool.

The code above checks that the constants are constantIntegers IIRC.   
If you're seeing cases where you get a bool there, form a bitconvert  
or don't make a cast.

-Chris



More information about the llvm-commits mailing list