diff options
author | Reid Spencer <rspencer@reidspencer.com> | 2006-11-27 01:05:10 +0000 |
---|---|---|
committer | Reid Spencer <rspencer@reidspencer.com> | 2006-11-27 01:05:10 +0000 |
commit | 3da59db637a887474c1b1346c1f3ccf53b6c4663 (patch) | |
tree | b061e2133efdb9ea9bb334c1b15ceea881bb88f8 /lib/Transforms/Scalar/LoopStrengthReduce.cpp | |
parent | 5fed9b90447a9a95a1f670ccd9c23aea8c937451 (diff) | |
download | llvm-3da59db637a887474c1b1346c1f3ccf53b6c4663.tar.gz llvm-3da59db637a887474c1b1346c1f3ccf53b6c4663.tar.bz2 llvm-3da59db637a887474c1b1346c1f3ccf53b6c4663.tar.xz |
For PR950:
The long awaited CAST patch. This introduces 12 new instructions into LLVM
to replace the cast instruction. Corresponding changes throughout LLVM are
provided. This passes llvm-test, llvm/test, and SPEC CPUINT2000 with the
exception of 175.vpr which fails only on a slight floating point output
difference.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@31931 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'lib/Transforms/Scalar/LoopStrengthReduce.cpp')
-rw-r--r-- | lib/Transforms/Scalar/LoopStrengthReduce.cpp | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/lib/Transforms/Scalar/LoopStrengthReduce.cpp b/lib/Transforms/Scalar/LoopStrengthReduce.cpp index 3ac4df7c99..f6551ee076 100644 --- a/lib/Transforms/Scalar/LoopStrengthReduce.cpp +++ b/lib/Transforms/Scalar/LoopStrengthReduce.cpp @@ -627,10 +627,9 @@ static bool isTargetConstant(const SCEVHandle &V, const TargetLowering *TLI) { if (SCEVUnknown *SU = dyn_cast<SCEVUnknown>(V)) if (ConstantExpr *CE = dyn_cast<ConstantExpr>(SU->getValue())) - if (CE->getOpcode() == Instruction::Cast) { + if (CE->getOpcode() == Instruction::PtrToInt) { Constant *Op0 = CE->getOperand(0); - if (isa<GlobalValue>(Op0) && - TLI && + if (isa<GlobalValue>(Op0) && TLI && TLI->isLegalAddressImmediate(cast<GlobalValue>(Op0))) return true; } @@ -899,7 +898,7 @@ unsigned LoopStrengthReduce::CheckForIVReuse(const SCEVHandle &Stride, // FIXME: Only handle base == 0 for now. // Only reuse previous IV if it would not require a type conversion. if (isZero(II->Base) && - II->Base->getType()->isLosslesslyConvertibleTo(Ty)) { + II->Base->getType()->canLosslesslyBitCastTo(Ty)) { IV = *II; return Scale; } @@ -1044,9 +1043,10 @@ void LoopStrengthReduce::StrengthReduceStridedIVUsers(const SCEVHandle &Stride, if (!C || (!C->isNullValue() && !isTargetConstant(SCEVUnknown::get(CommonBaseV), TLI))) - // We want the common base emitted into the preheader! - CommonBaseV = new CastInst(CommonBaseV, CommonBaseV->getType(), - "commonbase", PreInsertPt); + // We want the common base emitted into the preheader! This is just + // using cast as a copy so BitCast (no-op cast) is appropriate + CommonBaseV = new BitCastInst(CommonBaseV, CommonBaseV->getType(), + "commonbase", PreInsertPt); } // We want to emit code for users inside the loop first. To do this, we @@ -1092,12 +1092,13 @@ void LoopStrengthReduce::StrengthReduceStridedIVUsers(const SCEVHandle &Stride, // If BaseV is a constant other than 0, make sure that it gets inserted into // the preheader, instead of being forward substituted into the uses. We do - // this by forcing a noop cast to be inserted into the preheader in this - // case. + // this by forcing a BitCast (noop cast) to be inserted into the preheader + // in this case. if (Constant *C = dyn_cast<Constant>(BaseV)) { if (!C->isNullValue() && !isTargetConstant(Base, TLI)) { - // We want this constant emitted into the preheader! - BaseV = new CastInst(BaseV, BaseV->getType(), "preheaderinsert", + // We want this constant emitted into the preheader! This is just + // using cast as a copy so BitCast (no-op cast) is appropriate + BaseV = new BitCastInst(BaseV, BaseV->getType(), "preheaderinsert", PreInsertPt); } } |