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