https://github.com/kasuga-fj updated https://github.com/llvm/llvm-project/pull/135163
>From 79186af3df57357d40ec3b3e4eaf9da978b31ef6 Mon Sep 17 00:00:00 2001 From: Ryotaro Kasuga <kasuga.ryot...@fujitsu.com> Date: Fri, 4 Apr 2025 12:32:57 +0000 Subject: [PATCH 1/5] [clang][CodeGen] Fix metadata when vectorization is disabled by pragma There are two ways to disable vectorization with pragma, `vectorize(disable)` and `vectorize_width(1)`. The document (https://clang.llvm.org/docs/LanguageExtensions.html#vectorization-interleaving-and-predication) states: > Specifying a width/count of 1 disables the optimization, and is equivalent to `vectorize(disable)` or `interleave(disable)`. So the behavior should be the same when using either is used. However, the current implementation doesn't satisfy this. When `vectorize(disable)` is specified, it is converted internally to the same as `vectorize_width(1)`, and the metadata is generated as if vectorization is not explicitly specified as enabled or disabled. This can cause a problem when other transformations are also specified by pragma. For example, if `unroll_count(8)` is specified, the loop should have a metadata that contains the information directly, like: ``` !loop0 = !{!"loop0", !vectorize_disable, !unroll} !vectorize_disable = {...} !unroll = !{!"llvm.loop.unroll_count", i32 8} ``` But now it's attached into followup metadata for vectorization. ``` !loop0 = !{!"loop0", !vectorize_width, !followup} !vectorize_width = !{!"llvm.loop.vectorize.width", i32 1} !followup = !{!"llvm.loop.vectorize.followup_all", !unroll} !unroll = !{!"llvm.loop.unroll_count", i32 8} ``` As a result, the unroll attributes are ignored because the vectorization is not applied. This patch fixes this issue by generating metadata that disables vectorization when `vectorize(disable)` or `vectorize_width(1)` are specified. The document also says: > If the transformation is disabled (e.g. vectorize(disable)), that takes precedence over transformations option pragmas implying that transformation. Therefore, if vectorization is disabled, all other vectorize options like `vectorize_predicate` should be ignored. This patch also omits to generate attributes for vectorization when it is disabled. Fix #75839 --- clang/lib/CodeGen/CGLoopInfo.cpp | 7 ++--- clang/test/CodeGenCXX/pragma-loop-pr27643.cpp | 12 ++++---- .../test/CodeGenCXX/pragma-loop-predicate.cpp | 22 +++++++------- clang/test/CodeGenCXX/pragma-loop-safety.cpp | 4 +-- clang/test/CodeGenCXX/pragma-loop.cpp | 29 ++++++++++++++++--- 5 files changed, 47 insertions(+), 27 deletions(-) diff --git a/clang/lib/CodeGen/CGLoopInfo.cpp b/clang/lib/CodeGen/CGLoopInfo.cpp index 2b7d7881ab990..e9d622d78bf6d 100644 --- a/clang/lib/CodeGen/CGLoopInfo.cpp +++ b/clang/lib/CodeGen/CGLoopInfo.cpp @@ -200,7 +200,8 @@ LoopInfo::createLoopVectorizeMetadata(const LoopAttributes &Attrs, LLVMContext &Ctx = Header->getContext(); std::optional<bool> Enabled; - if (Attrs.VectorizeEnable == LoopAttributes::Disable) + if (Attrs.VectorizeEnable == LoopAttributes::Disable || + Attrs.VectorizeWidth == 1) Enabled = false; else if (Attrs.VectorizeEnable != LoopAttributes::Unspecified || Attrs.VectorizePredicateEnable != LoopAttributes::Unspecified || @@ -643,9 +644,7 @@ void LoopInfoStack::push(BasicBlock *Header, clang::ASTContext &Ctx, case LoopHintAttr::Disable: switch (Option) { case LoopHintAttr::Vectorize: - // Disable vectorization by specifying a width of 1. - setVectorizeWidth(1); - setVectorizeScalable(LoopAttributes::Unspecified); + setVectorizeEnable(false); break; case LoopHintAttr::Interleave: // Disable interleaving by speciyfing a count of 1. diff --git a/clang/test/CodeGenCXX/pragma-loop-pr27643.cpp b/clang/test/CodeGenCXX/pragma-loop-pr27643.cpp index 37e29776264b6..b4614c4d39be4 100644 --- a/clang/test/CodeGenCXX/pragma-loop-pr27643.cpp +++ b/clang/test/CodeGenCXX/pragma-loop-pr27643.cpp @@ -40,14 +40,14 @@ void loop4(int *List, int Length) { List[i] = i * 2; } -// CHECK: ![[LOOP1]] = distinct !{![[LOOP1]], [[MP:![0-9]+]], ![[VEC_WIDTH_1:.*]], ![[FIXED_WIDTH:.*]], ![[VEC_ENABLE:.*]]} -// CHECK: ![[VEC_WIDTH_1]] = !{!"llvm.loop.vectorize.width", i32 1} -// CHECK: ![[FIXED_WIDTH]] = !{!"llvm.loop.vectorize.scalable.enable", i1 false} -// CHECK: ![[VEC_ENABLE]] = !{!"llvm.loop.vectorize.enable", i1 true} +// CHECK: ![[LOOP1]] = distinct !{![[LOOP1]], [[MP:![0-9]+]], ![[VEC_DISABLE:[0-9]+]]} +// CHECK: ![[VEC_DISABLE]] = !{!"llvm.loop.vectorize.enable", i1 false} -// CHECK: ![[LOOP2]] = distinct !{![[LOOP2]], [[MP]], ![[VEC_WIDTH_2:.*]], ![[FIXED_WIDTH:.*]], ![[VEC_ENABLE]]} +// CHECK: ![[LOOP2]] = distinct !{![[LOOP2]], [[MP]], ![[VEC_WIDTH_2:.*]], ![[FIXED_WIDTH:[0-9]+]], ![[VEC_ENABLE:[0-9]+]]} // CHECK: ![[VEC_WIDTH_2]] = !{!"llvm.loop.vectorize.width", i32 2} +// CHECK: ![[FIXED_WIDTH]] = !{!"llvm.loop.vectorize.scalable.enable", i1 false} +// CHECK: ![[VEC_ENABLE]] = !{!"llvm.loop.vectorize.enable", i1 true} -// CHECK: ![[LOOP3]] = distinct !{![[LOOP3]], [[MP]], ![[VEC_WIDTH_1]], ![[FIXED_WIDTH]]} +// CHECK: ![[LOOP3]] = distinct !{![[LOOP3]], [[MP]], ![[VEC_DISABLE]]} // CHECK: ![[LOOP4]] = distinct !{![[LOOP4]], [[MP]], ![[VEC_WIDTH_2]], ![[FIXED_WIDTH]], ![[VEC_ENABLE]]} diff --git a/clang/test/CodeGenCXX/pragma-loop-predicate.cpp b/clang/test/CodeGenCXX/pragma-loop-predicate.cpp index 8a25ed8de6239..4877733f6ea2a 100644 --- a/clang/test/CodeGenCXX/pragma-loop-predicate.cpp +++ b/clang/test/CodeGenCXX/pragma-loop-predicate.cpp @@ -37,8 +37,8 @@ void test3(int *List, int Length) { List[i] = i * 2; } -// Check that disabling vectorization means a vectorization width of 1, and -// also that vectorization_predicate isn't enabled. +// Check that vectorize is disabled, and also that vectorization_predicate is +// ignored. void test4(int *List, int Length) { // CHECK-LABEL: @{{.*}}test4{{.*}}( // CHECK: br label {{.*}}, !llvm.loop ![[LOOP4:.*]] @@ -48,7 +48,7 @@ void test4(int *List, int Length) { List[i] = i * 2; } -// Check that vectorize and vectorize_predicate are disabled. +// Check that vectorize is disabled and vectorize_predicate is ignored. void test5(int *List, int Length) { // CHECK-LABEL: @{{.*}}test5{{.*}}( // CHECK: br label {{.*}}, !llvm.loop ![[LOOP5:.*]] @@ -114,16 +114,16 @@ void test9(int *List, int Length) { // CHECK-NEXT: ![[LOOP3]] = distinct !{![[LOOP3]], [[MP]], [[GEN6]], [[GEN3]]} // CHECK-NEXT: ![[LOOP4]] = distinct !{![[LOOP4]], [[MP]], [[GEN10:![0-9]+]]} -// CHECK-NEXT: [[GEN10]] = !{!"llvm.loop.vectorize.width", i32 1} +// CHECK-NEXT: [[GEN10]] = !{!"llvm.loop.vectorize.enable", i1 false} -// CHECK-NEXT: ![[LOOP5]] = distinct !{![[LOOP5]], [[MP]], [[GEN6]], [[GEN10]]} +// CHECK-NEXT: ![[LOOP5]] = distinct !{![[LOOP5]], [[MP]], [[GEN10]]} -// CHECK-NEXT: ![[LOOP6]] = distinct !{![[LOOP6]], [[MP]], [[GEN8]], [[GEN10]], [[GEN11:![0-9]+]]} -// CHECK-NEXT: [[GEN11]] = !{!"llvm.loop.vectorize.scalable.enable", i1 false} +// CHECK-NEXT: ![[LOOP6]] = distinct !{![[LOOP6]], [[MP]], [[GEN10]]} -// CHECK-NEXT: ![[LOOP7]] = distinct !{![[LOOP7]], [[MP]], [[GEN8]], [[GEN12:![0-9]+]], [[GEN11]], [[GEN3]]} -// CHECK-NEXT: [[GEN12]] = !{!"llvm.loop.vectorize.width", i32 4} +// CHECK-NEXT: ![[LOOP7]] = distinct !{![[LOOP7]], [[MP]], [[GEN8]], [[GEN11:![0-9]+]], [[GEN12:![0-9]+]], [[GEN3]]} +// CHECK-NEXT: [[GEN11]] = !{!"llvm.loop.vectorize.width", i32 4} +// CHECK-NEXT: [[GEN12]] = !{!"llvm.loop.vectorize.scalable.enable", i1 false} -// CHECK-NEXT: ![[LOOP8]] = distinct !{![[LOOP8]], [[MP]], [[GEN6]], [[GEN10]], [[GEN11]]} +// CHECK-NEXT: ![[LOOP8]] = distinct !{![[LOOP8]], [[MP]], [[GEN10]]} -// CHECK-NEXT: ![[LOOP9]] = distinct !{![[LOOP9]], [[MP]], [[GEN6]], [[GEN12]], [[GEN11]], [[GEN3]]} +// CHECK-NEXT: ![[LOOP9]] = distinct !{![[LOOP9]], [[MP]], [[GEN6]], [[GEN11]], [[GEN12]], [[GEN3]]} diff --git a/clang/test/CodeGenCXX/pragma-loop-safety.cpp b/clang/test/CodeGenCXX/pragma-loop-safety.cpp index db1b6769e0514..771570f62057b 100644 --- a/clang/test/CodeGenCXX/pragma-loop-safety.cpp +++ b/clang/test/CodeGenCXX/pragma-loop-safety.cpp @@ -53,6 +53,6 @@ void interleave_test(int *List, int Length) { // CHECK: ![[INTERLEAVE_1]] = !{!"llvm.loop.interleave.count", i32 1} // CHECK: ![[INTENABLE_1]] = !{!"llvm.loop.vectorize.enable", i1 true} // CHECK: ![[ACCESS_GROUP_8]] = distinct !{} -// CHECK: ![[LOOP2_HINTS]] = distinct !{![[LOOP2_HINTS]], [[MP]], ![[PARALLEL_ACCESSES_11:[0-9]+]], ![[UNROLL_DISABLE]], ![[WIDTH_1:[0-9]+]], ![[INTENABLE_1]]} +// CHECK: ![[LOOP2_HINTS]] = distinct !{![[LOOP2_HINTS]], [[MP]], ![[PARALLEL_ACCESSES_11:[0-9]+]], ![[UNROLL_DISABLE]], ![[VECTORIZE_DISABLED:[0-9]+]]} // CHECK: ![[PARALLEL_ACCESSES_11]] = !{!"llvm.loop.parallel_accesses", ![[ACCESS_GROUP_8]]} -// CHECK: ![[WIDTH_1]] = !{!"llvm.loop.vectorize.width", i32 1} +// CHECK: ![[VECTORIZE_DISABLED]] = !{!"llvm.loop.vectorize.enable", i1 false} diff --git a/clang/test/CodeGenCXX/pragma-loop.cpp b/clang/test/CodeGenCXX/pragma-loop.cpp index 4857299f1c037..c08c42c384c04 100644 --- a/clang/test/CodeGenCXX/pragma-loop.cpp +++ b/clang/test/CodeGenCXX/pragma-loop.cpp @@ -194,7 +194,7 @@ void for_test_scalable(int *List, int Length) { } } -// Verify for loop is performing scalable vectorization +// Verify for loop is NOT performing vectorization because the width is 1 void for_test_scalable_1(int *List, int Length) { #pragma clang loop vectorize_width(1, scalable) interleave_count(4) unroll(disable) distribute(disable) for (int i = 0; i < Length; i++) { @@ -203,6 +203,24 @@ void for_test_scalable_1(int *List, int Length) { } } +// Verify for loop is performing scalable vectorization +void for_test_scalable_2(int *List, int Length) { +#pragma clang loop vectorize_width(2, scalable) interleave_count(4) unroll(disable) distribute(disable) + for (int i = 0; i < Length; i++) { + // CHECK: br label {{.*}}, !llvm.loop ![[LOOP_20:.*]] + List[i] = i * 2; + } +} + +// Verify unroll attributes are directly attached to the loop metadata +void for_test_vectorize_disable_unroll(int *List, int Length) { +#pragma clang loop vectorize(disable) unroll_count(8) + for (int i = 0; i < Length; i++) { + // CHECK: br label {{.*}}, !llvm.loop ![[LOOP_21:.*]] + List[i] = i * 2; + } +} + // CHECK-DAG: ![[MP:[0-9]+]] = !{!"llvm.loop.mustprogress"} // CHECK-DAG: ![[UNROLL_DISABLE:[0-9]+]] = !{!"llvm.loop.unroll.disable"} @@ -220,9 +238,9 @@ void for_test_scalable_1(int *List, int Length) { // CHECK-DAG: ![[INTERLEAVE_16:[0-9]+]] = !{!"llvm.loop.interleave.count", i32 16} // CHECK-DAG: ![[VECTORIZE_ENABLE:[0-9]+]] = !{!"llvm.loop.vectorize.enable", i1 true} +// CHECK-DAG: ![[VECTORIZE_DISABLE:[0-9]+]] = !{!"llvm.loop.vectorize.enable", i1 false} // CHECK-DAG: ![[FIXED_VEC:[0-9]+]] = !{!"llvm.loop.vectorize.scalable.enable", i1 false} // CHECK-DAG: ![[SCALABLE_VEC:[0-9]+]] = !{!"llvm.loop.vectorize.scalable.enable", i1 true} -// CHECK-DAG: ![[WIDTH_1:[0-9]+]] = !{!"llvm.loop.vectorize.width", i32 1} // CHECK-DAG: ![[WIDTH_2:[0-9]+]] = !{!"llvm.loop.vectorize.width", i32 2} // CHECK-DAG: ![[WIDTH_5:[0-9]+]] = !{!"llvm.loop.vectorize.width", i32 5} // CHECK-DAG: ![[WIDTH_6:[0-9]+]] = !{!"llvm.loop.vectorize.width", i32 6} @@ -241,7 +259,7 @@ void for_test_scalable_1(int *List, int Length) { // CHECK-DAG: ![[LOOP_4]] = distinct !{![[LOOP_4]], ![[WIDTH_2]], ![[FIXED_VEC]], ![[INTERLEAVE_2]], ![[VECTORIZE_ENABLE]]} -// CHECK-DAG: ![[LOOP_5]] = distinct !{![[LOOP_5]], ![[MP]], ![[UNROLL_DISABLE]], ![[DISTRIBUTE_DISABLE]], ![[WIDTH_1]]} +// CHECK-DAG: ![[LOOP_5]] = distinct !{![[LOOP_5]], ![[MP]], ![[UNROLL_DISABLE]], ![[DISTRIBUTE_DISABLE]], ![[VECTORIZE_DISABLE]]} // CHECK-DAG: ![[LOOP_6]] = distinct !{![[LOOP_6]], ![[MP]], ![[WIDTH_2]], ![[FIXED_VEC]], ![[INTERLEAVE_2]], ![[VECTORIZE_ENABLE]], ![[FOLLOWUP_VECTOR_3]]} @@ -269,4 +287,7 @@ void for_test_scalable_1(int *List, int Length) { // CHECK-DAG: ![[LOOP_17]] = distinct !{![[LOOP_17]], ![[MP]], ![[UNROLL_DISABLE]], ![[DISTRIBUTE_DISABLE]], ![[FIXED_VEC]], ![[INTERLEAVE_4]], ![[VECTORIZE_ENABLE]]} // CHECK-DAG: ![[LOOP_18]] = distinct !{![[LOOP_18]], ![[MP]], ![[UNROLL_DISABLE]], ![[DISTRIBUTE_DISABLE]], ![[SCALABLE_VEC]], ![[INTERLEAVE_4]], ![[VECTORIZE_ENABLE]]} -// CHECK-DAG: ![[LOOP_19]] = distinct !{![[LOOP_19]], ![[MP]], ![[UNROLL_DISABLE]], ![[DISTRIBUTE_DISABLE]], ![[WIDTH_1]], ![[SCALABLE_VEC]], ![[INTERLEAVE_4]], ![[VECTORIZE_ENABLE]]} +// CHECK-DAG: ![[LOOP_19]] = distinct !{![[LOOP_19]], ![[MP]], ![[UNROLL_DISABLE]], ![[DISTRIBUTE_DISABLE]], ![[VECTORIZE_DISABLE]]} +// CHECK-DAG: ![[LOOP_20]] = distinct !{![[LOOP_20]], ![[MP]], ![[UNROLL_DISABLE]], ![[DISTRIBUTE_DISABLE]], ![[WIDTH_2]], ![[SCALABLE_VEC]], ![[INTERLEAVE_4]], ![[VECTORIZE_ENABLE]]} + +// CHECK-DAG: ![[LOOP_21]] = distinct !{![[LOOP_21]], ![[MP]], ![[VECTORIZE_DISABLE]], ![[UNROLL_8]]} >From aed6f105f1d11430318904206e096ca2d77302db Mon Sep 17 00:00:00 2001 From: Ryotaro Kasuga <kasuga.ryot...@fujitsu.com> Date: Fri, 11 Apr 2025 09:44:25 +0000 Subject: [PATCH 2/5] Fix OpenMP test --- clang/test/OpenMP/omp_with_loop_pragma.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/clang/test/OpenMP/omp_with_loop_pragma.c b/clang/test/OpenMP/omp_with_loop_pragma.c index c1536afa99017..d4d18b4e0e60e 100644 --- a/clang/test/OpenMP/omp_with_loop_pragma.c +++ b/clang/test/OpenMP/omp_with_loop_pragma.c @@ -2,7 +2,7 @@ // RUN: %clang_cc1 -verify -x c -emit-llvm %s -triple x86_64-unknown-linux -o - -femit-all-decls -disable-llvm-passes | FileCheck %s // expected-no-diagnostics -// CHECK: !{{[0-9]+}} = !{!"llvm.loop.vectorize.width", i32 1} +// CHECK: !{{[0-9]+}} = !{!"llvm.loop.vectorize.enable", i1 false} void sub(double *restrict a, double *restrict b, int n) { int i; >From 98bee49b8864d2979925613f8806cfd951a5b7b3 Mon Sep 17 00:00:00 2001 From: Ryotaro Kasuga <kasuga.ryot...@fujitsu.com> Date: Fri, 11 Apr 2025 09:47:11 +0000 Subject: [PATCH 3/5] Fix behavior when scalable is specified --- clang/lib/CodeGen/CGLoopInfo.cpp | 8 +++++++- clang/test/CodeGenCXX/pragma-loop.cpp | 29 ++++++++++++++++++--------- 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/clang/lib/CodeGen/CGLoopInfo.cpp b/clang/lib/CodeGen/CGLoopInfo.cpp index e9d622d78bf6d..15e3af3befa44 100644 --- a/clang/lib/CodeGen/CGLoopInfo.cpp +++ b/clang/lib/CodeGen/CGLoopInfo.cpp @@ -200,8 +200,14 @@ LoopInfo::createLoopVectorizeMetadata(const LoopAttributes &Attrs, LLVMContext &Ctx = Header->getContext(); std::optional<bool> Enabled; + + // Vectorization is disabled if: + // 1) it is disabled explicitly, or + // 2) it is implied when vectorize.width is set to 1 and scalable + // vectorization is not specified explicitly. if (Attrs.VectorizeEnable == LoopAttributes::Disable || - Attrs.VectorizeWidth == 1) + (Attrs.VectorizeWidth == 1 && + Attrs.VectorizeScalable != LoopAttributes::Enable)) Enabled = false; else if (Attrs.VectorizeEnable != LoopAttributes::Unspecified || Attrs.VectorizePredicateEnable != LoopAttributes::Unspecified || diff --git a/clang/test/CodeGenCXX/pragma-loop.cpp b/clang/test/CodeGenCXX/pragma-loop.cpp index c08c42c384c04..1bd58a4a474a0 100644 --- a/clang/test/CodeGenCXX/pragma-loop.cpp +++ b/clang/test/CodeGenCXX/pragma-loop.cpp @@ -194,7 +194,7 @@ void for_test_scalable(int *List, int Length) { } } -// Verify for loop is NOT performing vectorization because the width is 1 +// Verify for loop is performing scalable vectorization void for_test_scalable_1(int *List, int Length) { #pragma clang loop vectorize_width(1, scalable) interleave_count(4) unroll(disable) distribute(disable) for (int i = 0; i < Length; i++) { @@ -203,20 +203,30 @@ void for_test_scalable_1(int *List, int Length) { } } -// Verify for loop is performing scalable vectorization -void for_test_scalable_2(int *List, int Length) { -#pragma clang loop vectorize_width(2, scalable) interleave_count(4) unroll(disable) distribute(disable) +// Verify for loop is not performing vectorization +void for_test_width_1(int *List, int Length) { +#pragma clang loop vectorize_width(1) interleave_count(4) unroll(disable) distribute(disable) for (int i = 0; i < Length; i++) { // CHECK: br label {{.*}}, !llvm.loop ![[LOOP_20:.*]] List[i] = i * 2; } } +// Verify for loop is not performing vectorization +void for_test_fixed_1(int *List, int Length) { +#pragma clang loop vectorize_width(1, fixed) interleave_count(4) unroll(disable) distribute(disable) + for (int i = 0; i < Length; i++) { + // CHECK: br label {{.*}}, !llvm.loop ![[LOOP_21:.*]] + List[i] = i * 2; + } +} + + // Verify unroll attributes are directly attached to the loop metadata void for_test_vectorize_disable_unroll(int *List, int Length) { #pragma clang loop vectorize(disable) unroll_count(8) for (int i = 0; i < Length; i++) { - // CHECK: br label {{.*}}, !llvm.loop ![[LOOP_21:.*]] + // CHECK: br label {{.*}}, !llvm.loop ![[LOOP_22:.*]] List[i] = i * 2; } } @@ -241,6 +251,7 @@ void for_test_vectorize_disable_unroll(int *List, int Length) { // CHECK-DAG: ![[VECTORIZE_DISABLE:[0-9]+]] = !{!"llvm.loop.vectorize.enable", i1 false} // CHECK-DAG: ![[FIXED_VEC:[0-9]+]] = !{!"llvm.loop.vectorize.scalable.enable", i1 false} // CHECK-DAG: ![[SCALABLE_VEC:[0-9]+]] = !{!"llvm.loop.vectorize.scalable.enable", i1 true} +// CHECK-DAG: ![[WIDTH_1:[0-9]+]] = !{!"llvm.loop.vectorize.width", i32 1} // CHECK-DAG: ![[WIDTH_2:[0-9]+]] = !{!"llvm.loop.vectorize.width", i32 2} // CHECK-DAG: ![[WIDTH_5:[0-9]+]] = !{!"llvm.loop.vectorize.width", i32 5} // CHECK-DAG: ![[WIDTH_6:[0-9]+]] = !{!"llvm.loop.vectorize.width", i32 6} @@ -287,7 +298,7 @@ void for_test_vectorize_disable_unroll(int *List, int Length) { // CHECK-DAG: ![[LOOP_17]] = distinct !{![[LOOP_17]], ![[MP]], ![[UNROLL_DISABLE]], ![[DISTRIBUTE_DISABLE]], ![[FIXED_VEC]], ![[INTERLEAVE_4]], ![[VECTORIZE_ENABLE]]} // CHECK-DAG: ![[LOOP_18]] = distinct !{![[LOOP_18]], ![[MP]], ![[UNROLL_DISABLE]], ![[DISTRIBUTE_DISABLE]], ![[SCALABLE_VEC]], ![[INTERLEAVE_4]], ![[VECTORIZE_ENABLE]]} -// CHECK-DAG: ![[LOOP_19]] = distinct !{![[LOOP_19]], ![[MP]], ![[UNROLL_DISABLE]], ![[DISTRIBUTE_DISABLE]], ![[VECTORIZE_DISABLE]]} -// CHECK-DAG: ![[LOOP_20]] = distinct !{![[LOOP_20]], ![[MP]], ![[UNROLL_DISABLE]], ![[DISTRIBUTE_DISABLE]], ![[WIDTH_2]], ![[SCALABLE_VEC]], ![[INTERLEAVE_4]], ![[VECTORIZE_ENABLE]]} - -// CHECK-DAG: ![[LOOP_21]] = distinct !{![[LOOP_21]], ![[MP]], ![[VECTORIZE_DISABLE]], ![[UNROLL_8]]} +// CHECK-DAG: ![[LOOP_19]] = distinct !{![[LOOP_19]], ![[MP]], ![[UNROLL_DISABLE]], ![[DISTRIBUTE_DISABLE]], ![[WIDTH_1]], ![[SCALABLE_VEC]], ![[INTERLEAVE_4]], ![[VECTORIZE_ENABLE]]} +// CHECK-DAG: ![[LOOP_20]] = distinct !{![[LOOP_20]], ![[MP]], ![[UNROLL_DISABLE]], ![[DISTRIBUTE_DISABLE]], ![[VECTORIZE_DISABLE]]} +// CHECK-DAG: ![[LOOP_21]] = distinct !{![[LOOP_21]], ![[MP]], ![[UNROLL_DISABLE]], ![[DISTRIBUTE_DISABLE]], ![[VECTORIZE_DISABLE]]} +// CHECK-DAG: ![[LOOP_22]] = distinct !{![[LOOP_22]], ![[MP]], ![[VECTORIZE_DISABLE]], ![[UNROLL_8]]} >From 0e604031da9918d72184a0db4f0b389874a3e607 Mon Sep 17 00:00:00 2001 From: Ryotaro Kasuga <kasuga.ryot...@fujitsu.com> Date: Fri, 11 Apr 2025 09:52:59 +0000 Subject: [PATCH 4/5] Update the docs --- clang/docs/LanguageExtensions.rst | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/clang/docs/LanguageExtensions.rst b/clang/docs/LanguageExtensions.rst index 3b8a9cac6587a..c532545b3e42c 100644 --- a/clang/docs/LanguageExtensions.rst +++ b/clang/docs/LanguageExtensions.rst @@ -5237,8 +5237,8 @@ width/count of the set of target architectures supported by your application. ... } -Specifying a width/count of 1 disables the optimization, and is equivalent to -``vectorize(disable)`` or ``interleave(disable)``. +Specifying a *non-scalable* width/count of 1 disables the optimization, and is +equivalent to ``vectorize(disable)`` or ``interleave(disable)``. Vector predication is enabled by ``vectorize_predicate(enable)``, for example: >From 16b6d51cef70b12aa487447bc7573744686fc52b Mon Sep 17 00:00:00 2001 From: Ryotaro Kasuga <kasuga.ryot...@fujitsu.com> Date: Tue, 15 Apr 2025 09:00:48 +0000 Subject: [PATCH 5/5] Fix the comment, thanks! --- clang/test/CodeGenCXX/pragma-loop-predicate.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/clang/test/CodeGenCXX/pragma-loop-predicate.cpp b/clang/test/CodeGenCXX/pragma-loop-predicate.cpp index 4877733f6ea2a..32a8dd3d16e52 100644 --- a/clang/test/CodeGenCXX/pragma-loop-predicate.cpp +++ b/clang/test/CodeGenCXX/pragma-loop-predicate.cpp @@ -37,8 +37,7 @@ void test3(int *List, int Length) { List[i] = i * 2; } -// Check that vectorize is disabled, and also that vectorization_predicate is -// ignored. +// Check that vectorization is disabled. void test4(int *List, int Length) { // CHECK-LABEL: @{{.*}}test4{{.*}}( // CHECK: br label {{.*}}, !llvm.loop ![[LOOP4:.*]] _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits