From e573a9c03566814e925bf083c6c3c785273f80ae Mon Sep 17 00:00:00 2001 From: Sjoerd Meijer Date: Tue, 17 Sep 2019 08:43:11 +0000 Subject: [Clang] Pragma vectorize_width() implies vectorize(enable) Specifying the vectorization width was supposed to implicitly enable vectorization, except that it wasn't really doing this. It was only setting the vectorize.width metadata, but not vectorize.enable. This should fix PR27643. Differential Revision: https://reviews.llvm.org/D66290 llvm-svn: 372082 --- clang/lib/CodeGen/CGLoopInfo.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'clang/lib/CodeGen/CGLoopInfo.cpp') diff --git a/clang/lib/CodeGen/CGLoopInfo.cpp b/clang/lib/CodeGen/CGLoopInfo.cpp index 6822c6286fe..c21d4feee7a 100644 --- a/clang/lib/CodeGen/CGLoopInfo.cpp +++ b/clang/lib/CodeGen/CGLoopInfo.cpp @@ -270,6 +270,14 @@ LoopInfo::createLoopVectorizeMetadata(const LoopAttributes &Attrs, // Setting vectorize.width if (Attrs.VectorizeWidth > 0) { + // This implies vectorize.enable = true, but only add it when it is not + // already enabled. + if (Attrs.VectorizeEnable != LoopAttributes::Enable) + Args.push_back( + MDNode::get(Ctx, {MDString::get(Ctx, "llvm.loop.vectorize.enable"), + ConstantAsMetadata::get(ConstantInt::get( + llvm::Type::getInt1Ty(Ctx), 1))})); + Metadata *Vals[] = { MDString::get(Ctx, "llvm.loop.vectorize.width"), ConstantAsMetadata::get(ConstantInt::get(llvm::Type::getInt32Ty(Ctx), -- cgit v1.2.3