On Mon, 15 Jan 2007, Reid Spencer wrote: >> Constant *ConstantExpr::getTrunc(Constant *C, const Type *Ty) { >> - assert(C->getType()->isInteger() && "Trunc operand must be integer"); >> + assert(C->getType()->isIntegral() && "Trunc operand must be integer"); > > This makes no sense. How can you trunc i1 to something smaller? The > rules for trunc are SrcSize > DestSize. If SrcSize is 1 bit, what size > is Dest? 0?
It doesn't have to make sense. >> assert(Ty->isIntegral() && "Trunc produces only integral"); >> assert(C->getType()->getPrimitiveSizeInBits() > >> Ty->getPrimitiveSizeInBits()&& >> "SrcTy must be larger than DestTy for Trunc!"); This assertion already catches the case you care about. The check above is cheaper. >> @@ -1505,7 +1505,7 @@ >> >> Constant *ConstantExpr::getSExt(Constant *C, const Type *Ty) { >> assert(C->getType()->isIntegral() && "SEXt operand must be integral"); >> - assert(Ty->isInteger() && "SExt produces only integer"); >> + assert(Ty->isIntegral() && "SExt produces only integer"); > > This also makes no sense. The destination type cannot be i1. Rules for > SExt are that SrcSize < DestSize. If DestSize is 1 bit, what could > SrcSize be? 0? Likewise. >> @@ -1514,7 +1514,7 @@ >> >> Constant *ConstantExpr::getZExt(Constant *C, const Type *Ty) { >> assert(C->getType()->isIntegral() && "ZEXt operand must be integral"); >> - assert(Ty->isInteger() && "ZExt produces only integer"); >> + assert(Ty->isIntegral() && "ZExt produces only integer"); > > Same issue as for SExt. Likewise. >> assert(C->getType()->getPrimitiveSizeInBits() < >> Ty->getPrimitiveSizeInBits()&& >> "SrcTy must be smaller than DestTy for ZExt!"); >> >> @@ -1649,15 +1649,15 @@ >> case Instruction::Sub: >> case Instruction::Mul: >> assert(C1->getType() == C2->getType() && "Op types should be >> identical!"); >> - assert((C1->getType()->isInteger() || C1->getType()->isFloatingPoint() >> || >> + assert((C1->getType()->isIntegral() || C1->getType()->isFloatingPoint() >> || > > This I was going to talk to you about. This will fix the current CEE > problem, assuming it applies to Instruction::Add as well. It is necessary, but not sufficient. A regression in ConstantRange also had to be fixed (now done). -Chris -- http://nondot.org/sabre/ http://llvm.org/ _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits