Some codestyle changes

This commit is contained in:
Vsevolod Livinskiy
2015-02-20 16:50:53 +03:00
parent 7b0eb0e4ad
commit 8c4d339f25

View File

@@ -4669,18 +4669,14 @@ SmearCleanupPass::getShuffleSmearValue(llvm::Instruction* inst) const {
return NULL; return NULL;
} }
fprintf(stderr, "getShuffleSmearValue\n");
shuffleInst->dump();
llvm::Constant* mask = llvm::Constant* mask =
llvm::dyn_cast<llvm::Constant>(shuffleInst->getOperand(2)); llvm::dyn_cast<llvm::Constant>(shuffleInst->getOperand(2));
// Check that the shuffle is a broadcast of the first element of the first vector, // Check that the shuffle is a broadcast of the element of the first vector,
// i.e. mask vector is all-zeros vector of expected size. // i.e. mask vector is vector with equal elements of expected size.
if (!(mask && if (!(mask &&
(mask->isNullValue() || (shuffleInst->getMask()->getSplatValue() != 0))&& (mask->isNullValue() || (shuffleInst->getMask()->getSplatValue() != 0))&&
llvm::dyn_cast<llvm::VectorType>(mask->getType())->getNumElements() == vectorWidth)) { llvm::dyn_cast<llvm::VectorType>(mask->getType())->getNumElements() == vectorWidth)) {
fprintf(stderr, "getShuffleSmearValue: mask\n");
return NULL; return NULL;
} }
@@ -4689,12 +4685,11 @@ SmearCleanupPass::getShuffleSmearValue(llvm::Instruction* inst) const {
llvm::dyn_cast<llvm::InsertElementInst>(shuffleInst->getOperand(0)); llvm::dyn_cast<llvm::InsertElementInst>(shuffleInst->getOperand(0));
// Check that it's an InsertElementInst that inserts a value to first element. // Check that it's an InsertElementInst that inserts a value to first element.
llvm::Value *result = shuffleInst->getOperand(0);
if (!(insertInst && if (!(insertInst &&
llvm::isa<llvm::Constant>(insertInst->getOperand(2)) && llvm::isa<llvm::Constant>(insertInst->getOperand(2)) &&
llvm::dyn_cast<llvm::Constant>(insertInst->getOperand(2))->isNullValue())) { llvm::dyn_cast<llvm::Constant>(insertInst->getOperand(2))->isNullValue())) {
fprintf(stderr, "getShuffleSmearValue: inst\n");
// Insert ExtractElementInstr to get value for smear
llvm::Function *extractFunc = module->getFunction("__extract_element"); llvm::Function *extractFunc = module->getFunction("__extract_element");
@@ -4706,7 +4701,6 @@ SmearCleanupPass::getShuffleSmearValue(llvm::Instruction* inst) const {
shuffleInst->getOperand(0)->getType()->getVectorElementType(), shuffleInst->getOperand(0)->getType()->getVectorElementType(),
shuffleInst->getOperand(0)->getType(), shuffleInst->getOperand(0)->getType(),
llvm::IntegerType::get(module->getContext(), 32), NULL); llvm::IntegerType::get(module->getContext(), 32), NULL);
fprintf(stderr, "getShuffleSmearValue: getOrInsertFunction\n");
extractFunc = llvm::dyn_cast<llvm::Function>(ef); extractFunc = llvm::dyn_cast<llvm::Function>(ef);
assert(extractFunc != NULL); assert(extractFunc != NULL);
extractFunc->setDoesNotThrow(); extractFunc->setDoesNotThrow();
@@ -4714,15 +4708,15 @@ SmearCleanupPass::getShuffleSmearValue(llvm::Instruction* inst) const {
} }
if (extractFunc == NULL) { if (extractFunc == NULL) {
fprintf(stderr, "getShuffleSmearValue: no function in module\n");
return NULL; return NULL;
} }
fprintf(stderr, "getShuffleSmearValue: function was found\n"); llvm::Instruction *extractCall =
llvm::Instruction *extractCall = llvm::ExtractElementInst::Create(shuffleInst->getOperand(0), mask->getSplatValue(), "__extract_element", inst); llvm::ExtractElementInst::Create(shuffleInst->getOperand(0), mask->getSplatValue(),
"__extract_element", inst);
return extractCall; return extractCall;
} }
result = insertInst->getOperand(1); llvm::Value *result = insertInst->getOperand(1);
return result; return result;
} }
@@ -4741,15 +4735,11 @@ SmearCleanupPass::runOnBasicBlock(llvm::BasicBlock &bb) {
continue; continue;
} }
fprintf(stderr, "==========================================================\n");
llvm::Type *smearType = smearValue->getType(); llvm::Type *smearType = smearValue->getType();
const char *smearFuncName = lGetTypedFunc("smear", smearType, vectorWidth); const char *smearFuncName = lGetTypedFunc("smear", smearType, vectorWidth);
fprintf(stderr, "smearFuncName: %s | %d\n", smearFuncName, smearFuncName != NULL);
if (smearFuncName != NULL) { if (smearFuncName != NULL) {
llvm::Function *smearFunc = module->getFunction(smearFuncName); llvm::Function *smearFunc = module->getFunction(smearFuncName);
if (smearFunc == NULL) { if (smearFunc == NULL) {
fprintf(stderr, "Smear decl\n");
// Declare the smear function if needed; it takes a single // Declare the smear function if needed; it takes a single
// scalar parameter and returns a vector of the same // scalar parameter and returns a vector of the same
// parameter type. // parameter type.