aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CGLoopInfo.cpp
diff options
context:
space:
mode:
authorMalhar <malhar.jajoo@arm.com>2021-02-13 15:57:21 -0600
committerMichael Kruse <llvm-project@meinersbur.de>2021-02-13 17:35:54 -0600
commit74ddacd30de54e19b28218bc8563bd0f34f32cad (patch)
tree8ebbefc3741c61d43f6e4a6e50dda7818851b4d5 /clang/lib/CodeGen/CGLoopInfo.cpp
parent53187f1eeccb22ab6ef3f5ba5acfbe0ebeed1dbd (diff)
downloadllvm-74ddacd30de54e19b28218bc8563bd0f34f32cad.zip
llvm-74ddacd30de54e19b28218bc8563bd0f34f32cad.tar.gz
llvm-74ddacd30de54e19b28218bc8563bd0f34f32cad.tar.bz2
[Clang] Ensure vector predication loop metadata is always emitted when pragma is specified.
This patch ensures that vector predication and vectorization width pragmas work together correctly/as expected. Specifically, this patch fixes the issue that when vectorization_width > 1, the vector predication behaviour (this would matter if it has NOT been disabled explicitly by a pragma) was getting ignored, which was incorrect. The fix here removes the dependence of vector predication on the vectorization width. The loop metadata corresponding to clang loop pragma vectorize_predicate is always emitted, if the pragma is specified, even if vectorization is disabled by vectorize_width(1) or vectorize(disable) since the option is also used for interleaving by the LoopVectorize pass. Reviewed By: dmgreen, Meinersbur Differential Revision: https://reviews.llvm.org/D94779
Diffstat (limited to 'clang/lib/CodeGen/CGLoopInfo.cpp')
-rw-r--r--clang/lib/CodeGen/CGLoopInfo.cpp11
1 files changed, 5 insertions, 6 deletions
diff --git a/clang/lib/CodeGen/CGLoopInfo.cpp b/clang/lib/CodeGen/CGLoopInfo.cpp
index 8ba4059..12a6cd8 100644
--- a/clang/lib/CodeGen/CGLoopInfo.cpp
+++ b/clang/lib/CodeGen/CGLoopInfo.cpp
@@ -250,12 +250,10 @@ LoopInfo::createLoopVectorizeMetadata(const LoopAttributes &Attrs,
Args.push_back(nullptr);
Args.append(LoopProperties.begin(), LoopProperties.end());
- // Setting vectorize.predicate
+ // Setting vectorize.predicate when it has been specified and vectorization
+ // has not been disabled.
bool IsVectorPredicateEnabled = false;
- if (Attrs.VectorizePredicateEnable != LoopAttributes::Unspecified &&
- Attrs.VectorizeEnable != LoopAttributes::Disable &&
- Attrs.VectorizeWidth < 1) {
-
+ if (Attrs.VectorizePredicateEnable != LoopAttributes::Unspecified) {
IsVectorPredicateEnabled =
(Attrs.VectorizePredicateEnable == LoopAttributes::Enable);
@@ -303,7 +301,8 @@ LoopInfo::createLoopVectorizeMetadata(const LoopAttributes &Attrs,
// explicitly requested fixed-width vectorization, i.e.
// vectorize.scalable.enable is false.
if (Attrs.VectorizeEnable != LoopAttributes::Unspecified ||
- IsVectorPredicateEnabled || Attrs.VectorizeWidth > 1 ||
+ (IsVectorPredicateEnabled && Attrs.VectorizeWidth != 1) ||
+ Attrs.VectorizeWidth > 1 ||
Attrs.VectorizeScalable == LoopAttributes::Enable ||
(Attrs.VectorizeScalable == LoopAttributes::Disable &&
Attrs.VectorizeWidth != 1)) {