mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2025-06-14 14:24:05 +00:00
Loop Vectorize: optimize the vectorization of trunc(induction_var). The truncation is now done on scalars.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@169904 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
@ -1204,8 +1204,20 @@ InnerLoopVectorizer::vectorizeBlockInLoop(LoopVectorizationLegality *Legal,
|
||||
case Instruction::Trunc:
|
||||
case Instruction::FPTrunc:
|
||||
case Instruction::BitCast: {
|
||||
/// Vectorize bitcasts.
|
||||
CastInst *CI = dyn_cast<CastInst>(it);
|
||||
/// Optimize the special case where the source is the induction
|
||||
/// variable. Notice that we can only optimize the 'trunc' case
|
||||
/// because: a. FP conversions lose precision, b. sext/zext may wrap,
|
||||
/// c. other casts depend on pointer size.
|
||||
if (CI->getOperand(0) == OldInduction &&
|
||||
it->getOpcode() == Instruction::Trunc) {
|
||||
Value *ScalarCast = Builder.CreateCast(CI->getOpcode(), Induction,
|
||||
CI->getType());
|
||||
Value *Broadcasted = getBroadcastInstrs(ScalarCast);
|
||||
WidenMap[it] = getConsecutiveVector(Broadcasted);
|
||||
break;
|
||||
}
|
||||
/// Vectorize casts.
|
||||
Value *A = getVectorValue(it->getOperand(0));
|
||||
Type *DestTy = VectorType::get(CI->getType()->getScalarType(), VF);
|
||||
WidenMap[it] = Builder.CreateCast(CI->getOpcode(), A, DestTy);
|
||||
|
Reference in New Issue
Block a user