Skip to content

Commit

Permalink
Merge pull request ispc#1102 from ncos/knc-fixes
Browse files Browse the repository at this point in the history
Removed dirty workaround that fixed 'soa-18.ispc' test. It broke badly in a different scenario
  • Loading branch information
dbabokin committed Sep 30, 2015
2 parents 8bf8911 + 68e686d commit 1d08598
Showing 1 changed file with 24 additions and 22 deletions.
46 changes: 24 additions & 22 deletions cbackend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4185,28 +4185,30 @@ void CWriter::visitCallInst(llvm::CallInst &I) {
if (Callee->getName() == "malloc" ||
Callee->getName() == "_aligned_malloc")
Out << "(uint8_t *)";

if (Callee->getName() == "__masked_store_i64") {
llvm::CallSite CS(&I);
llvm::CallSite::arg_iterator AI = CS.arg_begin();

if (is_vec16_i64_ty(llvm::cast<llvm::PointerType>((*AI)->getType())->getElementType())) {
Out << "/* Replacing store of vec16_i64 val into &vec16_i64 pointer with a simple copy */\n";
// If we are trying to get a pointer to from a vec16_i64 var
// It would be better to replace this instruction with a masked copy
if (llvm::isa<llvm::GetElementPtrInst>(*AI)) {
writeOperandDeref(*AI);
Out << " = __select(";
writeOperand(*(AI+2));
Out << ", ";
writeOperand(*(AI+1));
Out << ", ";
writeOperandDeref(*AI);
Out << ")";
return;
}
}
}

// This 'if' will fix 'soa-18.ispc' test (fails with optimizations off)
// Yet the way the case is fixed is quite dirty and leads to many other fails

//if (Callee->getName() == "__masked_store_i64") {
// llvm::CallSite CS(&I);
// llvm::CallSite::arg_iterator AI = CS.arg_begin();
// if (is_vec16_i64_ty(llvm::cast<llvm::PointerType>((*AI)->getType())->getElementType())) {
// Out << "/* Replacing store of vec16_i64 val into &vec16_i64 pointer with a simple copy */\n";
// // If we are trying to get a pointer to from a vec16_i64 var
// // It would be better to replace this instruction with a masked copy
// if (llvm::isa<llvm::GetElementPtrInst>(*AI)) {
// writeOperandDeref(*AI);
// Out << " = __select(";
// writeOperand(*(AI+2));
// Out << ", ";
// writeOperand(*(AI+1));
// Out << ", ";
// writeOperandDeref(*AI);
// Out << ")";
// return;
// }
// }
//}

if (NeedsCast) {
// Ok, just cast the pointer type.
Expand Down

0 comments on commit 1d08598

Please sign in to comment.