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.
llvm-svn: 31931
diff --git a/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp b/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp
index a0c5164..b62df63 100644
--- a/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp
+++ b/llvm/lib/Transforms/Scalar/ScalarReplAggregates.cpp
@@ -624,7 +624,8 @@
assert((NV->getType()->isInteger() ||
isa<PointerType>(NV->getType())) && "Unknown promotion!");
}
- NV = new CastInst(NV, LI->getType(), LI->getName(), LI);
+ NV = CastInst::createInferredCast(NV, LI->getType(), LI->getName(),
+ LI);
}
}
LI->replaceAllUsesWith(NV);
@@ -646,12 +647,12 @@
ConstantInt::get(Type::UIntTy, Elt),
"tmp", SI);
} else {
- // If SV is signed, convert it to unsigned, so that the next cast zero
- // extends the value.
+ // Always zero extend the value.
if (SV->getType()->isSigned())
- SV = new CastInst(SV, SV->getType()->getUnsignedVersion(),
- SV->getName(), SI);
- SV = new CastInst(SV, Old->getType(), SV->getName(), SI);
+ SV = CastInst::createInferredCast(SV,
+ SV->getType()->getUnsignedVersion(), SV->getName(), SI);
+ SV = CastInst::createInferredCast(SV, Old->getType(), SV->getName(),
+ SI);
if (Offset && Offset < TD.getTypeSize(SV->getType())*8)
SV = new ShiftInst(Instruction::Shl, SV,
ConstantInt::get(Type::UByteTy, Offset),