diff --git a/polly/include/polly/CodeGen/IslAst.h b/polly/include/polly/CodeGen/IslAst.h --- a/polly/include/polly/CodeGen/IslAst.h +++ b/polly/include/polly/CodeGen/IslAst.h @@ -26,6 +26,9 @@ #include "llvm/IR/PassManager.h" #include "isl/ctx.h" +/// Command line switch whether to model read-only accesses. +extern bool PollyParallel; + namespace polly { using llvm::SmallPtrSet; diff --git a/polly/lib/CodeGen/IslAst.cpp b/polly/lib/CodeGen/IslAst.cpp --- a/polly/lib/CodeGen/IslAst.cpp +++ b/polly/lib/CodeGen/IslAst.cpp @@ -59,10 +59,12 @@ using IslAstUserPayload = IslAstInfo::IslAstUserPayload; -static cl::opt - PollyParallel("polly-parallel", - cl::desc("Generate thread parallel code (isl codegen only)"), - cl::init(false), cl::ZeroOrMore, cl::cat(PollyCategory)); +bool PollyParallel; +static cl::opt + XPollyParallel("polly-parallel", + cl::desc("Generate thread parallel code (isl codegen only)"), + cl::ZeroOrMore, cl::cat(PollyCategory), + cl::location(PollyParallel), cl::init(false)); static cl::opt PrintAccesses("polly-ast-print-accesses", cl::desc("Print memory access functions"), diff --git a/polly/lib/Transform/MatmulOptimizer.cpp b/polly/lib/Transform/MatmulOptimizer.cpp --- a/polly/lib/Transform/MatmulOptimizer.cpp +++ b/polly/lib/Transform/MatmulOptimizer.cpp @@ -7,6 +7,7 @@ //===----------------------------------------------------------------------===// #include "polly/MatmulOptimizer.h" +#include "polly/CodeGen/IslAst.h" #include "polly/DependenceInfo.h" #include "polly/Options.h" #include "polly/ScheduleTreeTransform.h" @@ -1031,7 +1032,10 @@ const llvm::TargetTransformInfo *TTI, const Dependences *D) { MatMulInfoTy MMI; - if (isMatrMultPattern(Node, D, MMI)) { + // FIXME: Polly's parallel scheduler and the matrix multiplication + // pattern match produce invalid code. Disable the matrix pattern + // entirely if `-polly-parallel` is used. + if (!PollyParallel && isMatrMultPattern(Node, D, MMI)) { LLVM_DEBUG(dbgs() << "The matrix multiplication pattern was detected\n"); return optimizeMatMulPattern(Node, TTI, MMI); }