Fixing MIC performance issue, which showed up when we switched to

LLVM 3.4 (due to more aggressive optimizations): vector of *the same*
constants should be generated as scalar value in cpp file, instead of
__extract_element(splat(value), 0).
I.e. <2,2,2,2> should appear in cpp as 2, but not
__extract_element(splat(2), 0);
This commit is contained in:
Dmitry Babokin
2014-04-17 21:03:42 +04:00
parent 94467fdb70
commit 096546f888
3 changed files with 39 additions and 14 deletions

View File

@@ -3286,10 +3286,16 @@ void CWriter::visitBinaryOperator(llvm::Instruction &I) {
if ((I.getOpcode() == llvm::Instruction::Shl ||
I.getOpcode() == llvm::Instruction::LShr ||
I.getOpcode() == llvm::Instruction::AShr)) {
if (LLVMVectorValuesAllEqual(I.getOperand(1))) {
Out << "__extract_element(";
writeOperand(I.getOperand(1));
Out << ", 0) ";
llvm::Value *splat = NULL;
if (LLVMVectorValuesAllEqual(I.getOperand(1), &splat)) {
if (splat) {
// Avoid __extract_element(splat(value), 0), if possible.
writeOperand(splat);
} else {
Out << "__extract_element(";
writeOperand(I.getOperand(1));
Out << ", 0) ";
}
}
else
writeOperand(I.getOperand(1));