This revision was automatically updated to reflect the committed changes. Closed by commit rG74ddacd30de5: [Clang] Ensure vector predication loop metadata is always emitted when pragma… (authored by malharJ, committed by Meinersbur).
Repository: rG LLVM Github Monorepo CHANGES SINCE LAST ACTION https://reviews.llvm.org/D94779/new/ https://reviews.llvm.org/D94779 Files: clang/lib/CodeGen/CGLoopInfo.cpp clang/test/CodeGenCXX/pragma-loop-predicate.cpp Index: clang/test/CodeGenCXX/pragma-loop-predicate.cpp =================================================================== --- clang/test/CodeGenCXX/pragma-loop-predicate.cpp +++ clang/test/CodeGenCXX/pragma-loop-predicate.cpp @@ -58,6 +58,49 @@ List[i] = i * 2; } +// Check that vectorize_predicate is ignored when vectorization width is 1 +void test6(int *List, int Length) { +// CHECK-LABEL: @{{.*}}test6{{.*}}( +// CHECK: br label {{.*}}, !llvm.loop ![[LOOP6:.*]] + +#pragma clang loop vectorize_predicate(disable) vectorize_width(1) + for (int i = 0; i < Length; i++) + List[i] = i * 2; +} + + +// Check that vectorize_width(!=1) does not affect vectorize_predicate. +void test7(int *List, int Length) { +// CHECK-LABEL: @{{.*}}test7{{.*}}( +// CHECK: br label {{.*}}, !llvm.loop ![[LOOP7:.*]] + +#pragma clang loop vectorize_predicate(disable) vectorize_width(4) + for (int i = 0; i < Length; i++) + List[i] = i * 2; +} + + +// Check that vectorize_predicate is ignored when vectorization width is 1 +void test8(int *List, int Length) { +// CHECK-LABEL: @{{.*}}test8{{.*}}( +// CHECK: br label {{.*}}, !llvm.loop ![[LOOP8:.*]] + +#pragma clang loop vectorize_predicate(enable) vectorize_width(1) + for (int i = 0; i < Length; i++) + List[i] = i * 2; +} + + +// Check that vectorize_width(!=1) does not affect vectorize_predicate. +void test9(int *List, int Length) { +// CHECK-LABEL: @{{.*}}test9{{.*}}( +// CHECK: br label {{.*}}, !llvm.loop ![[LOOP9:.*]] + +#pragma clang loop vectorize_predicate(enable) vectorize_width(4) + for (int i = 0; i < Length; i++) + List[i] = i * 2; +} + // CHECK: ![[LOOP0]] = distinct !{![[LOOP0]], [[MP:![0-9]+]], [[GEN3:![0-9]+]]} // CHECK: [[MP]] = !{!"llvm.loop.mustprogress"} // CHECK-NEXT: [[GEN3]] = !{!"llvm.loop.vectorize.enable", i1 true} @@ -73,4 +116,14 @@ // CHECK-NEXT: ![[LOOP4]] = distinct !{![[LOOP4]], [[MP]], [[GEN10:![0-9]+]]} // CHECK-NEXT: [[GEN10]] = !{!"llvm.loop.vectorize.width", i32 1} -// CHECK-NEXT: ![[LOOP5]] = distinct !{![[LOOP5]], [[MP]], [[GEN10]]} +// CHECK-NEXT: ![[LOOP5]] = distinct !{![[LOOP5]], [[MP]], [[GEN6]], [[GEN10]]} + +// CHECK-NEXT: ![[LOOP6]] = distinct !{![[LOOP6]], [[MP]], [[GEN8]], [[GEN10]], [[GEN11:![0-9]+]]} +// CHECK-NEXT: [[GEN11]] = !{!"llvm.loop.vectorize.scalable.enable", i1 false} + +// CHECK-NEXT: ![[LOOP7]] = distinct !{![[LOOP7]], [[MP]], [[GEN8]], [[GEN12:![0-9]+]], [[GEN11]], [[GEN3]]} +// CHECK-NEXT: [[GEN12]] = !{!"llvm.loop.vectorize.width", i32 4} + +// CHECK-NEXT: ![[LOOP8]] = distinct !{![[LOOP8]], [[MP]], [[GEN6]], [[GEN10]], [[GEN11]]} + +// CHECK-NEXT: ![[LOOP9]] = distinct !{![[LOOP9]], [[MP]], [[GEN6]], [[GEN12]], [[GEN11]], [[GEN3]]} Index: clang/lib/CodeGen/CGLoopInfo.cpp =================================================================== --- clang/lib/CodeGen/CGLoopInfo.cpp +++ clang/lib/CodeGen/CGLoopInfo.cpp @@ -250,12 +250,10 @@ 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 @@ // 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)) {
Index: clang/test/CodeGenCXX/pragma-loop-predicate.cpp =================================================================== --- clang/test/CodeGenCXX/pragma-loop-predicate.cpp +++ clang/test/CodeGenCXX/pragma-loop-predicate.cpp @@ -58,6 +58,49 @@ List[i] = i * 2; } +// Check that vectorize_predicate is ignored when vectorization width is 1 +void test6(int *List, int Length) { +// CHECK-LABEL: @{{.*}}test6{{.*}}( +// CHECK: br label {{.*}}, !llvm.loop ![[LOOP6:.*]] + +#pragma clang loop vectorize_predicate(disable) vectorize_width(1) + for (int i = 0; i < Length; i++) + List[i] = i * 2; +} + + +// Check that vectorize_width(!=1) does not affect vectorize_predicate. +void test7(int *List, int Length) { +// CHECK-LABEL: @{{.*}}test7{{.*}}( +// CHECK: br label {{.*}}, !llvm.loop ![[LOOP7:.*]] + +#pragma clang loop vectorize_predicate(disable) vectorize_width(4) + for (int i = 0; i < Length; i++) + List[i] = i * 2; +} + + +// Check that vectorize_predicate is ignored when vectorization width is 1 +void test8(int *List, int Length) { +// CHECK-LABEL: @{{.*}}test8{{.*}}( +// CHECK: br label {{.*}}, !llvm.loop ![[LOOP8:.*]] + +#pragma clang loop vectorize_predicate(enable) vectorize_width(1) + for (int i = 0; i < Length; i++) + List[i] = i * 2; +} + + +// Check that vectorize_width(!=1) does not affect vectorize_predicate. +void test9(int *List, int Length) { +// CHECK-LABEL: @{{.*}}test9{{.*}}( +// CHECK: br label {{.*}}, !llvm.loop ![[LOOP9:.*]] + +#pragma clang loop vectorize_predicate(enable) vectorize_width(4) + for (int i = 0; i < Length; i++) + List[i] = i * 2; +} + // CHECK: ![[LOOP0]] = distinct !{![[LOOP0]], [[MP:![0-9]+]], [[GEN3:![0-9]+]]} // CHECK: [[MP]] = !{!"llvm.loop.mustprogress"} // CHECK-NEXT: [[GEN3]] = !{!"llvm.loop.vectorize.enable", i1 true} @@ -73,4 +116,14 @@ // CHECK-NEXT: ![[LOOP4]] = distinct !{![[LOOP4]], [[MP]], [[GEN10:![0-9]+]]} // CHECK-NEXT: [[GEN10]] = !{!"llvm.loop.vectorize.width", i32 1} -// CHECK-NEXT: ![[LOOP5]] = distinct !{![[LOOP5]], [[MP]], [[GEN10]]} +// CHECK-NEXT: ![[LOOP5]] = distinct !{![[LOOP5]], [[MP]], [[GEN6]], [[GEN10]]} + +// CHECK-NEXT: ![[LOOP6]] = distinct !{![[LOOP6]], [[MP]], [[GEN8]], [[GEN10]], [[GEN11:![0-9]+]]} +// CHECK-NEXT: [[GEN11]] = !{!"llvm.loop.vectorize.scalable.enable", i1 false} + +// CHECK-NEXT: ![[LOOP7]] = distinct !{![[LOOP7]], [[MP]], [[GEN8]], [[GEN12:![0-9]+]], [[GEN11]], [[GEN3]]} +// CHECK-NEXT: [[GEN12]] = !{!"llvm.loop.vectorize.width", i32 4} + +// CHECK-NEXT: ![[LOOP8]] = distinct !{![[LOOP8]], [[MP]], [[GEN6]], [[GEN10]], [[GEN11]]} + +// CHECK-NEXT: ![[LOOP9]] = distinct !{![[LOOP9]], [[MP]], [[GEN6]], [[GEN12]], [[GEN11]], [[GEN3]]} Index: clang/lib/CodeGen/CGLoopInfo.cpp =================================================================== --- clang/lib/CodeGen/CGLoopInfo.cpp +++ clang/lib/CodeGen/CGLoopInfo.cpp @@ -250,12 +250,10 @@ 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 @@ // 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)) {
_______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits