summaryrefslogtreecommitdiffstats
path: root/tools/llvm-stress/llvm-stress.cpp
diff options
context:
space:
mode:
authordim <dim@FreeBSD.org>2012-05-03 16:50:55 +0000
committerdim <dim@FreeBSD.org>2012-05-03 16:50:55 +0000
commit2c5e9d71aba3b1a85f07c08d2c09d40b8547264b (patch)
tree8575c732129e272992ac5d7b4c2519238fff4735 /tools/llvm-stress/llvm-stress.cpp
parent1fc08f5e9ef733ef1ce6f363fecedc2260e78974 (diff)
downloadFreeBSD-src-2c5e9d71aba3b1a85f07c08d2c09d40b8547264b.zip
FreeBSD-src-2c5e9d71aba3b1a85f07c08d2c09d40b8547264b.tar.gz
Vendor import of llvm release_31 branch r155985:
http://llvm.org/svn/llvm-project/llvm/branches/release_31@155985
Diffstat (limited to 'tools/llvm-stress/llvm-stress.cpp')
-rw-r--r--tools/llvm-stress/llvm-stress.cpp21
1 files changed, 12 insertions, 9 deletions
diff --git a/tools/llvm-stress/llvm-stress.cpp b/tools/llvm-stress/llvm-stress.cpp
index d284ea5..fb05a58 100644
--- a/tools/llvm-stress/llvm-stress.cpp
+++ b/tools/llvm-stress/llvm-stress.cpp
@@ -412,7 +412,7 @@ struct ExtractElementModifier: public Modifier {
Value *Val0 = getRandomVectorValue();
Value *V = ExtractElementInst::Create(Val0,
ConstantInt::get(Type::getInt32Ty(BB->getContext()),
- Ran->Rand() % cast<VectorType>(Val0->getType())->getNumElements()),
+ Ran->Rand() % cast<VectorType>(Val0->getType())->getNumElements()),
"E", BB->getTerminator());
return PT->push_back(V);
}
@@ -476,7 +476,7 @@ struct CastModifier: public Modifier {
DestTy = pickVectorType(VecTy->getNumElements());
}
- // no need to casr.
+ // no need to cast.
if (VTy == DestTy) return;
// Pointers:
@@ -487,9 +487,11 @@ struct CastModifier: public Modifier {
new BitCastInst(V, DestTy, "PC", BB->getTerminator()));
}
+ unsigned VSize = VTy->getScalarType()->getPrimitiveSizeInBits();
+ unsigned DestSize = DestTy->getScalarType()->getPrimitiveSizeInBits();
+
// Generate lots of bitcasts.
- if ((Ran->Rand() & 1) &&
- VTy->getPrimitiveSizeInBits() == DestTy->getPrimitiveSizeInBits()) {
+ if ((Ran->Rand() & 1) && VSize == DestSize) {
return PT->push_back(
new BitCastInst(V, DestTy, "BC", BB->getTerminator()));
}
@@ -497,11 +499,11 @@ struct CastModifier: public Modifier {
// Both types are integers:
if (VTy->getScalarType()->isIntegerTy() &&
DestTy->getScalarType()->isIntegerTy()) {
- if (VTy->getScalarType()->getPrimitiveSizeInBits() >
- DestTy->getScalarType()->getPrimitiveSizeInBits()) {
+ if (VSize > DestSize) {
return PT->push_back(
new TruncInst(V, DestTy, "Tr", BB->getTerminator()));
} else {
+ assert(VSize < DestSize && "Different int types with the same size?");
if (Ran->Rand() & 1)
return PT->push_back(
new ZExtInst(V, DestTy, "ZE", BB->getTerminator()));
@@ -531,14 +533,15 @@ struct CastModifier: public Modifier {
// Both floats.
if (VTy->getScalarType()->isFloatingPointTy() &&
DestTy->getScalarType()->isFloatingPointTy()) {
- if (VTy->getScalarType()->getPrimitiveSizeInBits() >
- DestTy->getScalarType()->getPrimitiveSizeInBits()) {
+ if (VSize > DestSize) {
return PT->push_back(
new FPTruncInst(V, DestTy, "Tr", BB->getTerminator()));
- } else {
+ } else if (VSize < DestSize) {
return PT->push_back(
new FPExtInst(V, DestTy, "ZE", BB->getTerminator()));
}
+ // If VSize == DestSize, then the two types must be fp128 and ppc_fp128,
+ // for which there is no defined conversion. So do nothing.
}
}
OpenPOWER on IntegriCloud