Merge pull request #962 from ncos/cbackend-cmpxchg

Fix llvm->c++ translation of cmxchg instruction
This commit is contained in:
Dmitry Babokin
2015-02-12 19:10:04 +03:00
2 changed files with 17 additions and 21 deletions

View File

@@ -501,8 +501,14 @@ namespace {
static bool isInlinableInst(const llvm::Instruction &I) {
// Always inline cmp instructions, even if they are shared by multiple
// expressions. GCC generates horrible code if we don't.
if (llvm::isa<llvm::CmpInst>(I) && llvm::isa<llvm::VectorType>(I.getType()) == false)
return true;
if (llvm::isa<llvm::CmpInst>(I) && llvm::isa<llvm::VectorType>(I.getType()) == false)
return true;
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4) // LLVM 3.5+
// This instruction returns a struct on LLVM older than 3.4, and can not be inlined
if (llvm::isa<llvm::AtomicCmpXchgInst>(I))
return false;
#endif
// Must be an expression, must be used exactly once. If it is dead, we
// emit it inline where it would go.
@@ -4512,13 +4518,21 @@ void CWriter::visitAtomicRMWInst(llvm::AtomicRMWInst &AI) {
void CWriter::visitAtomicCmpXchgInst(llvm::AtomicCmpXchgInst &ACXI) {
Out << "(";
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4)
printType(Out, ACXI.getType(), false);
Out << "::init("; // LLVM cmpxchg returns a struct, so we need make an assighment properly
#endif
Out << "__atomic_cmpxchg(";
writeOperand(ACXI.getPointerOperand());
Out << ", ";
writeOperand(ACXI.getCompareOperand());
Out << ", ";
writeOperand(ACXI.getNewValOperand());
Out << "))";
Out << ")";
#if !defined(LLVM_3_2) && !defined(LLVM_3_3) && !defined(LLVM_3_4)
Out << ", true /* There is no way to learn the value of this bit inside ISPC, so making it constant */)";
#endif
Out << ")";
}
///////////////////////////////////////////////////////////////////////////

View File

@@ -560,11 +560,8 @@
./tests/aossoa-7.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O2 *
./tests/aossoa-8.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O2 *
./tests/atomics-13.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O2 *
./tests/atomics-6.ispc compfail x86-64 knc Linux LLVM 3.5 icpc15.0 -O2 *
./tests/atomics-6.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O2 *
./tests/atomics-uniform-8.ispc compfail x86-64 knc Linux LLVM 3.5 icpc15.0 -O2 *
./tests/atomics-uniform-8.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O2 *
./tests/atomics-uniform-9.ispc compfail x86-64 knc Linux LLVM 3.5 icpc15.0 -O2 *
./tests/atomics-uniform-9.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O2 *
./tests/funcptr-varying-7.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O2 *
./tests/funcptr-varying-8.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O2 *
@@ -651,13 +648,10 @@
./tests/atomics-3.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 *
./tests/atomics-4.ispc compfail x86-64 knc Linux LLVM 3.5 icpc15.0 -O0 *
./tests/atomics-4.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 *
./tests/atomics-6.ispc compfail x86-64 knc Linux LLVM 3.5 icpc15.0 -O0 *
./tests/atomics-6.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 *
./tests/atomics-9.ispc compfail x86-64 knc Linux LLVM 3.5 icpc15.0 -O0 *
./tests/atomics-9.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 *
./tests/atomics-uniform-8.ispc compfail x86-64 knc Linux LLVM 3.5 icpc15.0 -O0 *
./tests/atomics-uniform-8.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 *
./tests/atomics-uniform-9.ispc compfail x86-64 knc Linux LLVM 3.5 icpc15.0 -O0 *
./tests/atomics-uniform-9.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 *
./tests/exclusive-scan-add-1.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 *
./tests/exclusive-scan-add-10.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 *
@@ -730,11 +724,8 @@
./tests/aossoa-7.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O2 *
./tests/aossoa-8.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O2 *
./tests/atomics-13.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O2 *
./tests/atomics-6.ispc compfail x86-64 knc Linux LLVM 3.6 icpc15.0 -O2 *
./tests/atomics-6.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O2 *
./tests/atomics-uniform-8.ispc compfail x86-64 knc Linux LLVM 3.6 icpc15.0 -O2 *
./tests/atomics-uniform-8.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O2 *
./tests/atomics-uniform-9.ispc compfail x86-64 knc Linux LLVM 3.6 icpc15.0 -O2 *
./tests/atomics-uniform-9.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O2 *
./tests/funcptr-varying-7.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O2 *
./tests/funcptr-varying-8.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O2 *
@@ -821,13 +812,10 @@
./tests/atomics-3.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 *
./tests/atomics-4.ispc compfail x86-64 knc Linux LLVM 3.6 icpc15.0 -O0 *
./tests/atomics-4.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 *
./tests/atomics-6.ispc compfail x86-64 knc Linux LLVM 3.6 icpc15.0 -O0 *
./tests/atomics-6.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 *
./tests/atomics-9.ispc compfail x86-64 knc Linux LLVM 3.6 icpc15.0 -O0 *
./tests/atomics-9.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 *
./tests/atomics-uniform-8.ispc compfail x86-64 knc Linux LLVM 3.6 icpc15.0 -O0 *
./tests/atomics-uniform-8.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 *
./tests/atomics-uniform-9.ispc compfail x86-64 knc Linux LLVM 3.6 icpc15.0 -O0 *
./tests/atomics-uniform-9.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 *
./tests/exclusive-scan-add-1.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 *
./tests/exclusive-scan-add-10.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 *
@@ -1014,9 +1002,6 @@
./tests/exclusive-scan-add-7.ispc compfail x86-64 knc Linux LLVM 3.6 icpc15.0 -O2 *
./tests/funcptr-varying-7.ispc runfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O2 *
./tests/funcptr-varying-8.ispc runfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O2 *
./tests/atomics-6.ispc compfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O2 *
./tests/atomics-uniform-8.ispc compfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O2 *
./tests/atomics-uniform-9.ispc compfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O2 *
./tests/exclusive-scan-add-1.ispc compfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O2 *
./tests/exclusive-scan-add-10.ispc compfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O2 *
./tests/exclusive-scan-add-2.ispc compfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O2 *
@@ -1042,7 +1027,4 @@
./tests/atomics-2.ispc compfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O0 *
./tests/atomics-3.ispc compfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O0 *
./tests/atomics-4.ispc compfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O0 *
./tests/atomics-6.ispc compfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O0 *
./tests/atomics-9.ispc compfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O0 *
./tests/atomics-uniform-8.ispc compfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O0 *
./tests/atomics-uniform-9.ispc compfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O0 *