On Dec 5, 2006, at 11:58 AM, Reid Spencer wrote: > On Tue, 2006-12-05 at 11:52 -0800, Chris Lattner wrote: >>> SCEVHandle SCEVTruncateExpr::get(const SCEVHandle &Op, const Type >>> *Ty) { >>> if (SCEVConstant *SC = dyn_cast<SCEVConstant>(Op)) >>> - return SCEVUnknown::get(ConstantExpr::getCast(SC->getValue(), >>> Ty)); >>> + return SCEVUnknown::get( >>> + ConstantExpr::getTruncOrBitCast(SC->getValue(), Ty)); >> >> Shouldn't this one always bit a truncate? > > No, they could be the same size.
How? The two call sites are: if (SrcTy->getPrimitiveSize() > Ty->getPrimitiveSize()) return SCEVTruncateExpr::get(V, Ty); and: case Instruction::Trunc: if (I->getType()->isInteger() && I->getOperand(0)->getType()- >isInteger()) return SCEVTruncateExpr::get(getSCEV(I->getOperand(0)), I->getType()->getUnsignedVersion ()); The first can't be the same size, obviously. The second can't be the same size because it's coming from a trunc instruction. Further, the 'I->getOperand(0)->getType()->isInteger()' in the second code is also redundant with 'truncness'. >> >>> SCEVHandle SCEVZeroExtendExpr::get(const SCEVHandle &Op, const >>> Type *Ty) { >>> if (SCEVConstant *SC = dyn_cast<SCEVConstant>(Op)) >>> - return SCEVUnknown::get(ConstantExpr::getCast(SC->getValue(), >>> Ty)); >>> + return SCEVUnknown::get( >>> + ConstantExpr::getZExtOrBitCast(SC->getValue(), Ty)); >> >> Likewise, always a zext? > > No, they could be the same size. This is called in two places very similar to trunc. If you believe that these can be called with srcsize=destsize, please explain how. >> >>> @@ -998,11 +1000,10 @@ >>> Constant *LHSCV = LHSC->getValue(); >>> Constant *RHSCV = RHSC->getValue(); >>> if (LHSCV->getType()->isUnsigned()) >>> - LHSCV = ConstantExpr::getInferredCast( >>> - LHSCV, false, LHSCV->getType()->getSignedVersion(), >>> true); >>> + LHSCV = ConstantExpr::getBitCast(LHSCV, >>> + LHSCV->getType()- >>>> getSignedVersion()); >>> if (RHSCV->getType()->isUnsigned()) >>> - RHSCV = ConstantExpr::getInferredCast( >>> - RHSCV, false, LHSCV->getType(), true); >>> + RHSCV = ConstantExpr::getBitCast(RHSCV, LHSCV->getType()); >>> return SCEVUnknown::get(ConstantExpr::getSDiv(LHSCV, RHSCV)); >>> } >>> } >> >> As I mentioned before, these casts can all go away. sdiv is signless >> now. > > One thing at a time. This patch is getting rid of getInferredCast and > no more. Fair enough, please make sure it happens at some point though. -Chris _______________________________________________ llvm-commits mailing list llvm-commits@cs.uiuc.edu http://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits