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:
14
cbackend.cpp
14
cbackend.cpp
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user