From 3a18a28001d822f73d45dd999d5ad9a138b63107 Mon Sep 17 00:00:00 2001 From: Anton Mitrokhin Date: Thu, 5 Mar 2015 13:11:16 +0300 Subject: [PATCH] fixed funcptr-varying-6/7/8 tests on knc --- cbackend.cpp | 42 +++++++++++++++++++++++++++++++++++++-- examples/intrinsics/knc.h | 11 ++++++++-- fail_db.txt | 40 ------------------------------------- 3 files changed, 49 insertions(+), 44 deletions(-) diff --git a/cbackend.cpp b/cbackend.cpp index f99c1bfb..042fcdd1 100644 --- a/cbackend.cpp +++ b/cbackend.cpp @@ -984,10 +984,34 @@ llvm::raw_ostream &CWriter::printType(llvm::raw_ostream &Out, llvm::Type *Ty, } void CWriter::printConstantArray(llvm::ConstantArray *CPA, bool Static) { + // vec16_i64 should be handled separately + llvm::VectorType *VTy = llvm::dyn_cast(CPA->getOperand(0)->getType()); + if ((VTy != NULL) && (VTy->getElementType()->isIntegerTy()) && + VTy->getElementType()->getPrimitiveSizeInBits() == 64) { + Out << "/* vec16_i64 should be loaded carefully on knc */"; + Out << "\n#if defined(KNC)\n"; + Out << "hilo2zmm"; + Out << "\n#endif\n"; + } + Out << "("; printConstant(llvm::cast(CPA->getOperand(0)), Static); + Out << ")"; + for (unsigned i = 1, e = CPA->getNumOperands(); i != e; ++i) { Out << ", "; + + + llvm::VectorType *VTy = llvm::dyn_cast(CPA->getOperand(0)->getType()); + if ((VTy != NULL) && (VTy->getElementType()->isIntegerTy()) && + VTy->getElementType()->getPrimitiveSizeInBits() == 64) { + Out << "/* vec16_i64 should be loaded carefully on knc */"; + Out << "\n#if defined(KNC) \n"; + Out << "hilo2zmm"; + Out << "\n#endif \n"; + } + Out << "("; printConstant(llvm::cast(CPA->getOperand(i)), Static); + Out << ")"; } } @@ -1566,7 +1590,7 @@ void CWriter::printConstant(llvm::Constant *CPV, bool Static) { else { // call init func of the struct it's wrapped in... printType(Out, CPV->getType()); - Out << "::init("; + Out << "::init ("; } if (llvm::ConstantArray *CA = llvm::dyn_cast(CPV)) { printConstantArray(CA, Static); @@ -1897,7 +1921,7 @@ void CWriter::writeInstComputationInline(llvm::Instruction &I) { if (NeedBoolTrunc) Out << "(("; - + visit(I); if (NeedBoolTrunc) @@ -2582,6 +2606,7 @@ bool CWriter::doInitialization(llvm::Module &M) { printType(Out, I->getType()->getElementType(), false, GetValueName(I)); + if (I->hasLinkOnceLinkage()) Out << " __attribute__((common))"; else if (I->hasWeakLinkage()) @@ -2600,7 +2625,20 @@ bool CWriter::doInitialization(llvm::Module &M) { // FIXME common linkage should avoid this problem. if (!I->getInitializer()->isNullValue()) { Out << " = " ; + + // vec16_i64 should be handled separately + llvm::VectorType *VTy = llvm::dyn_cast(I->getType()->getElementType()); + if ((VTy != NULL) && (VTy->getElementType()->isIntegerTy()) && + VTy->getElementType()->getPrimitiveSizeInBits() == 64) { + Out << "/* vec16_i64 should be loaded carefully on knc */\n"; + Out << "\n#if defined(KNC) \n"; + Out << "hilo2zmm"; + Out << "\n#endif \n"; + } + + Out << "("; writeOperand(I->getInitializer(), false); + Out << ")"; } else if (I->hasWeakLinkage()) { // We have to specify an initializer, but it doesn't have to be // complete. If the value is an aggregate, print out { 0 }, and let diff --git a/examples/intrinsics/knc.h b/examples/intrinsics/knc.h index a0d072fa..d2594437 100644 --- a/examples/intrinsics/knc.h +++ b/examples/intrinsics/knc.h @@ -220,7 +220,7 @@ typedef struct PRE_ALIGN(64) __vec16_i64 { __m512i v_lo; } POST_ALIGN(64) __vec16_i64; -static __vec16_i64 zmm2hilo(const __m512i v1, const __m512i v2){ +FORCEINLINE __vec16_i64 zmm2hilo(const __m512i v1, const __m512i v2){ __vec16_i64 v; v.v_hi = _mm512_mask_permutevar_epi32(_mm512_undefined_epi32(), 0xFF00, _mm512_set_16to16_pi(15,13,11,9,7,5,3,1,14,12,10,8,6,4,2,0), @@ -237,7 +237,7 @@ static __vec16_i64 zmm2hilo(const __m512i v1, const __m512i v2){ return v; } -static void hilo2zmm(const __vec16_i64 &v, __m512i &_v1, __m512i &_v2) { +FORCEINLINE void hilo2zmm(const __vec16_i64 &v, __m512i &_v1, __m512i &_v2) { _v2 = _mm512_mask_permutevar_epi32(_mm512_undefined_epi32(), 0xAAAA, _mm512_set_16to16_pi(15,15,14,14,13,13,12,12,11,11,10,10,9,9,8,8), v.v_hi); @@ -252,6 +252,13 @@ static void hilo2zmm(const __vec16_i64 &v, __m512i &_v1, __m512i &_v2) { v.v_lo); } +FORCEINLINE __vec16_i64 hilo2zmm(const __vec16_i64 &v) { + __vec16_i64 ret; + hilo2zmm(v, ret.v_hi, ret.v_lo); + return ret; +} + + template struct vec16 { FORCEINLINE vec16() { } diff --git a/fail_db.txt b/fail_db.txt index 1fa5ddb2..8c0769cc 100644 --- a/fail_db.txt +++ b/fail_db.txt @@ -389,44 +389,14 @@ ./tests/atomics-uniform-9.ispc compfail x86-64 generic-16 Linux LLVM 3.6 clang++3.4 -O0 * ./tests/ptr-assign-lhs-math-1.ispc compfail x86-64 knc Linux LLVM 3.4 icpc15.0 -O2 * ./tests/ptr-assign-lhs-math-1.ispc compfail x86-64 knc Linux LLVM 3.4 icpc13.1 -O2 * -./tests/funcptr-varying-6.ispc runfail x86-64 knc Linux LLVM 3.4 icpc15.0 -O0 * -./tests/funcptr-varying-6.ispc runfail x86-64 knc Linux LLVM 3.4 icpc13.1 -O0 * -./tests/funcptr-varying-7.ispc runfail x86-64 knc Linux LLVM 3.4 icpc15.0 -O0 * -./tests/funcptr-varying-7.ispc runfail x86-64 knc Linux LLVM 3.4 icpc13.1 -O0 * -./tests/funcptr-varying-8.ispc runfail x86-64 knc Linux LLVM 3.4 icpc15.0 -O0 * -./tests/funcptr-varying-8.ispc runfail x86-64 knc Linux LLVM 3.4 icpc13.1 -O0 * ./tests/ptr-assign-lhs-math-1.ispc compfail x86-64 knc Linux LLVM 3.5 icpc15.0 -O2 * ./tests/ptr-assign-lhs-math-1.ispc compfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O2 * -./tests/funcptr-varying-6.ispc runfail x86-64 knc Linux LLVM 3.5 icpc15.0 -O0 * -./tests/funcptr-varying-6.ispc runfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * -./tests/funcptr-varying-7.ispc runfail x86-64 knc Linux LLVM 3.5 icpc15.0 -O0 * -./tests/funcptr-varying-7.ispc runfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * -./tests/funcptr-varying-8.ispc runfail x86-64 knc Linux LLVM 3.5 icpc15.0 -O0 * -./tests/funcptr-varying-8.ispc runfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * ./tests/ptr-assign-lhs-math-1.ispc compfail x86-64 knc Linux LLVM 3.6 icpc15.0 -O2 * ./tests/ptr-assign-lhs-math-1.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O2 * -./tests/funcptr-varying-6.ispc runfail x86-64 knc Linux LLVM 3.6 icpc15.0 -O0 * -./tests/funcptr-varying-6.ispc runfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * -./tests/funcptr-varying-7.ispc runfail x86-64 knc Linux LLVM 3.6 icpc15.0 -O0 * -./tests/funcptr-varying-7.ispc runfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * -./tests/funcptr-varying-8.ispc runfail x86-64 knc Linux LLVM 3.6 icpc15.0 -O0 * -./tests/funcptr-varying-8.ispc runfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * -./tests/funcptr-varying-7.ispc runfail x86-64 knc Linux LLVM 3.4 icpc15.0 -O2 * -./tests/funcptr-varying-7.ispc runfail x86-64 knc Linux LLVM 3.4 icpc13.1 -O2 * -./tests/funcptr-varying-8.ispc runfail x86-64 knc Linux LLVM 3.4 icpc15.0 -O2 * -./tests/funcptr-varying-8.ispc runfail x86-64 knc Linux LLVM 3.4 icpc13.1 -O2 * ./tests/soa-18.ispc runfail x86-64 knc Linux LLVM 3.4 icpc15.0 -O0 * ./tests/soa-18.ispc runfail x86-64 knc Linux LLVM 3.4 icpc13.1 -O0 * -./tests/funcptr-varying-7.ispc runfail x86-64 knc Linux LLVM 3.5 icpc15.0 -O2 * -./tests/funcptr-varying-7.ispc runfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O2 * -./tests/funcptr-varying-8.ispc runfail x86-64 knc Linux LLVM 3.5 icpc15.0 -O2 * -./tests/funcptr-varying-8.ispc runfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O2 * ./tests/soa-18.ispc runfail x86-64 knc Linux LLVM 3.5 icpc15.0 -O0 * ./tests/soa-18.ispc runfail x86-64 knc Linux LLVM 3.5 icpc13.1 -O0 * -./tests/funcptr-varying-7.ispc runfail x86-64 knc Linux LLVM 3.6 icpc15.0 -O2 * -./tests/funcptr-varying-7.ispc runfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O2 * -./tests/funcptr-varying-8.ispc runfail x86-64 knc Linux LLVM 3.6 icpc15.0 -O2 * -./tests/funcptr-varying-8.ispc runfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O2 * ./tests/soa-18.ispc runfail x86-64 knc Linux LLVM 3.6 icpc15.0 -O0 * ./tests/soa-18.ispc runfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O0 * ./tests/exclusive-scan-add-1.ispc compfail x86-64 generic-16 Linux LLVM 3.6 clang++3.4 -O2 * @@ -549,10 +519,6 @@ ./tests/exclusive-scan-add-6.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O2 * ./tests/exclusive-scan-add-7.ispc compfail x86-64 knc Linux LLVM 3.6 icpc15.0 -O2 * ./tests/exclusive-scan-add-7.ispc compfail x86-64 knc Linux LLVM 3.6 icpc13.1 -O2 * -./tests/funcptr-varying-7.ispc runfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O2 * -./tests/funcptr-varying-7.ispc runfail x86-64 knc Linux LLVM 3.7 icpc13.1 -O2 * -./tests/funcptr-varying-8.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 icpc13.1 -O2 * ./tests/exclusive-scan-add-1.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 icpc13.1 -O2 * ./tests/exclusive-scan-add-10.ispc compfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O2 * @@ -567,12 +533,6 @@ ./tests/exclusive-scan-add-7.ispc compfail x86-64 knc Linux LLVM 3.7 icpc13.1 -O2 * ./tests/ptr-assign-lhs-math-1.ispc compfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O2 * ./tests/ptr-assign-lhs-math-1.ispc compfail x86-64 knc Linux LLVM 3.7 icpc13.1 -O2 * -./tests/funcptr-varying-6.ispc runfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O0 * -./tests/funcptr-varying-6.ispc runfail x86-64 knc Linux LLVM 3.7 icpc13.1 -O0 * -./tests/funcptr-varying-7.ispc runfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O0 * -./tests/funcptr-varying-7.ispc runfail x86-64 knc Linux LLVM 3.7 icpc13.1 -O0 * -./tests/funcptr-varying-8.ispc runfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O0 * -./tests/funcptr-varying-8.ispc runfail x86-64 knc Linux LLVM 3.7 icpc13.1 -O0 * ./tests/soa-18.ispc runfail x86-64 knc Linux LLVM 3.7 icpc15.0 -O0 * ./tests/soa-18.ispc runfail x86-64 knc Linux LLVM 3.7 icpc13.1 -O0 *