-
Notifications
You must be signed in to change notification settings - Fork 14.7k
[LAA] Pre-commit tests exercising different types #151091
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
@llvm/pr-subscribers-llvm-analysis Author: Ramkumar Ramachandra (artagnon) ChangesPre-commit tests exercising different types of source/sink in depend_diff_types.ll, in preparation to weaken the HasSameSize check in LoopAccessAnalysis. Full diff: https://github.com/llvm/llvm-project/pull/151091.diff 1 Files Affected:
diff --git a/llvm/test/Analysis/LoopAccessAnalysis/depend_diff_types.ll b/llvm/test/Analysis/LoopAccessAnalysis/depend_diff_types.ll
index 1bf80489b1ea0..892cc916b2aa2 100644
--- a/llvm/test/Analysis/LoopAccessAnalysis/depend_diff_types.ll
+++ b/llvm/test/Analysis/LoopAccessAnalysis/depend_diff_types.ll
@@ -262,3 +262,220 @@ loop:
exit:
ret void
}
+
+define void @different_type_sizes_strided_accesses_independent(ptr %dst) {
+; CHECK-LABEL: 'different_type_sizes_strided_accesses_independent'
+; CHECK-NEXT: loop:
+; CHECK-NEXT: Report: unsafe dependent memory operations in loop. Use #pragma clang loop distribute(enable) to allow loop distribution to attempt to isolate the offending operations into a separate loop
+; CHECK-NEXT: Unknown data dependence.
+; CHECK-NEXT: Dependences:
+; CHECK-NEXT: Unknown:
+; CHECK-NEXT: store i16 0, ptr %gep.iv, align 2 ->
+; CHECK-NEXT: store i8 1, ptr %gep.10.iv, align 1
+; CHECK-EMPTY:
+; CHECK-NEXT: Run-time memory checks:
+; CHECK-NEXT: Grouped accesses:
+; CHECK-EMPTY:
+; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
+; CHECK-NEXT: SCEV assumptions:
+; CHECK-EMPTY:
+; CHECK-NEXT: Expressions re-written:
+;
+entry:
+ %gep.10 = getelementptr nuw i8, ptr %dst, i64 10
+ br label %loop
+
+loop:
+ %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
+ %gep.iv = getelementptr i8, ptr %dst, i64 %iv
+ store i16 0, ptr %gep.iv
+ %gep.10.iv = getelementptr i8, ptr %gep.10, i64 %iv
+ store i8 1, ptr %gep.10.iv
+ %iv.next = add i64 %iv, 8
+ %ec = icmp eq i64 %iv.next, 64
+ br i1 %ec, label %exit, label %loop
+
+exit:
+ ret void
+}
+
+define void @different_type_sizes_strided_accesses_dependent(ptr %dst) {
+; CHECK-LABEL: 'different_type_sizes_strided_accesses_dependent'
+; CHECK-NEXT: loop:
+; CHECK-NEXT: Report: unsafe dependent memory operations in loop. Use #pragma clang loop distribute(enable) to allow loop distribution to attempt to isolate the offending operations into a separate loop
+; CHECK-NEXT: Unknown data dependence.
+; CHECK-NEXT: Dependences:
+; CHECK-NEXT: Unknown:
+; CHECK-NEXT: store i64 0, ptr %gep.iv, align 4 ->
+; CHECK-NEXT: store i8 1, ptr %gep.10.iv, align 1
+; CHECK-EMPTY:
+; CHECK-NEXT: Run-time memory checks:
+; CHECK-NEXT: Grouped accesses:
+; CHECK-EMPTY:
+; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
+; CHECK-NEXT: SCEV assumptions:
+; CHECK-EMPTY:
+; CHECK-NEXT: Expressions re-written:
+;
+entry:
+ %gep.10 = getelementptr nuw i8, ptr %dst, i64 10
+ br label %loop
+
+loop:
+ %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
+ %gep.iv = getelementptr i8, ptr %dst, i64 %iv
+ store i64 0, ptr %gep.iv
+ %gep.10.iv = getelementptr i8, ptr %gep.10, i64 %iv
+ store i8 1, ptr %gep.10.iv
+ %iv.next = add i64 %iv, 8
+ %ec = icmp eq i64 %iv.next, 64
+ br i1 %ec, label %exit, label %loop
+
+exit:
+ ret void
+}
+
+define void @different_type_sizes_source_size_backwardvectorizible(ptr %dst) {
+; CHECK-LABEL: 'different_type_sizes_source_size_backwardvectorizible'
+; CHECK-NEXT: loop:
+; CHECK-NEXT: Report: unsafe dependent memory operations in loop. Use #pragma clang loop distribute(enable) to allow loop distribution to attempt to isolate the offending operations into a separate loop
+; CHECK-NEXT: Unknown data dependence.
+; CHECK-NEXT: Dependences:
+; CHECK-NEXT: Unknown:
+; CHECK-NEXT: store i16 0, ptr %gep.iv, align 2 ->
+; CHECK-NEXT: store i32 1, ptr %gep.10.iv, align 4
+; CHECK-EMPTY:
+; CHECK-NEXT: Run-time memory checks:
+; CHECK-NEXT: Grouped accesses:
+; CHECK-EMPTY:
+; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
+; CHECK-NEXT: SCEV assumptions:
+; CHECK-EMPTY:
+; CHECK-NEXT: Expressions re-written:
+;
+entry:
+ %gep.10 = getelementptr nuw i8, ptr %dst, i64 10
+ br label %loop
+
+loop:
+ %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
+ %gep.iv = getelementptr i8, ptr %dst, i64 %iv
+ store i16 0, ptr %gep.iv
+ %gep.10.iv = getelementptr i8, ptr %gep.10, i64 %iv
+ store i32 1, ptr %gep.10.iv
+ %iv.next = add i64 %iv, 8
+ %ec = icmp eq i64 %iv.next, 64
+ br i1 %ec, label %exit, label %loop
+
+exit:
+ ret void
+}
+
+define void @different_type_sizes_forward(ptr %dst) {
+; CHECK-LABEL: 'different_type_sizes_forward'
+; CHECK-NEXT: loop:
+; CHECK-NEXT: Memory dependences are safe
+; CHECK-NEXT: Dependences:
+; CHECK-NEXT: Forward:
+; CHECK-NEXT: store i32 0, ptr %gep.10.iv, align 4 ->
+; CHECK-NEXT: store i16 1, ptr %gep.iv, align 2
+; CHECK-EMPTY:
+; CHECK-NEXT: Run-time memory checks:
+; CHECK-NEXT: Grouped accesses:
+; CHECK-EMPTY:
+; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
+; CHECK-NEXT: SCEV assumptions:
+; CHECK-EMPTY:
+; CHECK-NEXT: Expressions re-written:
+;
+entry:
+ %gep.10 = getelementptr nuw i8, ptr %dst, i64 10
+ br label %loop
+
+loop:
+ %iv = phi i64 [ 0, %entry ], [ %iv.next, %loop ]
+ %gep.10.iv = getelementptr i8, ptr %gep.10, i64 %iv
+ store i32 0, ptr %gep.10.iv
+ %gep.iv = getelementptr i8, ptr %dst, i64 %iv
+ store i16 1, ptr %gep.iv
+ %iv.next = add i64 %iv, 8
+ %ec = icmp eq i64 %iv.next, 64
+ br i1 %ec, label %exit, label %loop
+
+exit:
+ ret void
+}
+
+define void @different_type_sizes_store_size_cannot_prevent_forwarding(ptr %A, ptr noalias %B) {
+; CHECK-LABEL: 'different_type_sizes_store_size_cannot_prevent_forwarding'
+; CHECK-NEXT: loop:
+; CHECK-NEXT: Report: unsafe dependent memory operations in loop. Use #pragma clang loop distribute(enable) to allow loop distribution to attempt to isolate the offending operations into a separate loop
+; CHECK-NEXT: Forward loop carried data dependence that prevents store-to-load forwarding.
+; CHECK-NEXT: Dependences:
+; CHECK-NEXT: ForwardButPreventsForwarding:
+; CHECK-NEXT: store i32 0, ptr %gep.A, align 4 ->
+; CHECK-NEXT: %l = load i16, ptr %gep.A.1, align 2
+; CHECK-EMPTY:
+; CHECK-NEXT: Run-time memory checks:
+; CHECK-NEXT: Grouped accesses:
+; CHECK-EMPTY:
+; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
+; CHECK-NEXT: SCEV assumptions:
+; CHECK-EMPTY:
+; CHECK-NEXT: Expressions re-written:
+;
+entry:
+ %A.1 = getelementptr i32, ptr %A, i64 1
+ br label %loop
+
+loop:
+ %iv = phi i64 [ 1022, %entry ], [ %iv.next, %loop ]
+ %gep.A = getelementptr inbounds i32, ptr %A, i64 %iv
+ store i32 0, ptr %gep.A
+ %gep.A.1 = getelementptr i32, ptr %A.1, i64 %iv
+ %l = load i16, ptr %gep.A.1
+ store i16 %l, ptr %B
+ %iv.next = add nsw i64 %iv, -1
+ %cmp = icmp eq i64 %iv, 0
+ br i1 %cmp, label %exit, label %loop
+
+exit:
+ ret void
+}
+
+define void @different_type_sizes_load_size_prevents_forwarding(ptr %A, ptr noalias %B) {
+; CHECK-LABEL: 'different_type_sizes_load_size_prevents_forwarding'
+; CHECK-NEXT: loop:
+; CHECK-NEXT: Report: unsafe dependent memory operations in loop. Use #pragma clang loop distribute(enable) to allow loop distribution to attempt to isolate the offending operations into a separate loop
+; CHECK-NEXT: Forward loop carried data dependence that prevents store-to-load forwarding.
+; CHECK-NEXT: Dependences:
+; CHECK-NEXT: ForwardButPreventsForwarding:
+; CHECK-NEXT: store i16 0, ptr %gep.A, align 2 ->
+; CHECK-NEXT: %l = load i32, ptr %gep.A.1, align 4
+; CHECK-EMPTY:
+; CHECK-NEXT: Run-time memory checks:
+; CHECK-NEXT: Grouped accesses:
+; CHECK-EMPTY:
+; CHECK-NEXT: Non vectorizable stores to invariant address were not found in loop.
+; CHECK-NEXT: SCEV assumptions:
+; CHECK-EMPTY:
+; CHECK-NEXT: Expressions re-written:
+;
+entry:
+ %A.1 = getelementptr i32, ptr %A, i64 1
+ br label %loop
+
+loop:
+ %iv = phi i64 [ 1022, %entry ], [ %iv.next, %loop ]
+ %gep.A = getelementptr inbounds i32, ptr %A, i64 %iv
+ store i16 0, ptr %gep.A
+ %gep.A.1 = getelementptr i32, ptr %A.1, i64 %iv
+ %l = load i32, ptr %gep.A.1
+ store i32 %l, ptr %B
+ %iv.next = add nsw i64 %iv, -1
+ %cmp = icmp eq i64 %iv, 0
+ br i1 %cmp, label %exit, label %loop
+
+exit:
+ ret void
+}
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many thanks for adding the missing test coverage!
74d974f
to
334119e
Compare
Gentle ping. |
@@ -262,3 +262,243 @@ loop: | |||
exit: | |||
ret void | |||
} | |||
|
|||
; The type-size of the source is different from that of the sink, | |||
; and the dependence distance is 10. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can you also add a test case where the store size is > than then dependence distance, e.g. store i128 for the test here
Pre-commit tests exercising different types of source/sink in depend_diff_types.ll, in preparation to weaken the HasSameSize check in LoopAccessAnalysis.
334119e
to
0590c70
Compare
It looks like in all cases, one of the accesses starts at the beginning of the region. Maybe we should add a test where both accesses are slightly offset, like this:
Also, for the sake of completeness, it would be good to include a test that spans across regions and covers/non-covers like this:
I hope the notation makes sense: - |
Pre-commit tests exercising different types of source/sink in depend_diff_types.ll, in preparation to weaken the HasSameSize check in LoopAccessAnalysis.