[llvm] 5d35342 - [LAA] Add extra test for #70819 showing incorrect Forward dep.
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 20 03:18:37 PST 2023
Author: Florian Hahn
Date: 2023-11-20T11:18:13Z
New Revision: 5d353423c97517ae1dc66506186e265538b0111f
URL: https://github.com/llvm/llvm-project/commit/5d353423c97517ae1dc66506186e265538b0111f
DIFF: https://github.com/llvm/llvm-project/commit/5d353423c97517ae1dc66506186e265538b0111f.diff
LOG: [LAA] Add extra test for #70819 showing incorrect Forward dep.
Add an additional test case where we currently incorrectly identify a
dependence as Foward instead of ForwardButPreventsForwarding.
Also cleans up the names in the tests a bit to improve readability.
Added:
Modified:
llvm/test/Analysis/LoopAccessAnalysis/forward-negative-step.ll
Removed:
################################################################################
diff --git a/llvm/test/Analysis/LoopAccessAnalysis/forward-negative-step.ll b/llvm/test/Analysis/LoopAccessAnalysis/forward-negative-step.ll
index 89c1737fb730513..35e2109ab74476d 100644
--- a/llvm/test/Analysis/LoopAccessAnalysis/forward-negative-step.ll
+++ b/llvm/test/Analysis/LoopAccessAnalysis/forward-negative-step.ll
@@ -1,3 +1,4 @@
+; NOTE: Assertions have been autogenerated by utils/update_analyze_test_checks.py UTC_ARGS: --version 4
; RUN: opt -passes='print<access-info>' -disable-output < %s 2>&1 | FileCheck %s
target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
@@ -9,32 +10,76 @@ target datalayout = "e-m:e-i64:64-i128:128-n32:64-S128"
; A[i+1] = A[i] + 1;
; }
-; CHECK: function 'vectorizable_Read_Write':
-; CHECK-NEXT: for.body:
-; CHECK-NEXT: Report: unsafe dependent memory operations in loop
-; CHECK-NEXT: Forward loop carried data dependence that prevents store-to-load forwarding.
-; CHECK-NEXT: Dependences:
-; CHECK-NEXT: ForwardButPreventsForwarding:
-; CHECK-NEXT: %0 = load i32, ptr %arrayidx, align 4 ->
-; CHECK-NEXT: store i32 %add, ptr %gep, align 4
-
define void @vectorizable_Read_Write(ptr nocapture %A) {
+; CHECK-LABEL: 'vectorizable_Read_Write'
+; 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: %l = load i32, ptr %gep.A, align 4 ->
+; CHECK-NEXT: store i32 %add, ptr %gep.A.plus.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:
- %invariant.gep = getelementptr i32, ptr %A, i64 1
- br label %for.body
+ %A.plus.1 = getelementptr i32, ptr %A, i64 1
+ br label %loop
-for.cond.cleanup:
- ret void
+loop:
+ %iv = phi i64 [ 1022, %entry ], [ %iv.next, %loop ]
+ %gep.A = getelementptr inbounds i32, ptr %A, i64 %iv
+ %l = load i32, ptr %gep.A, align 4
+ %add = add nsw i32 %l, 1
+ %gep.A.plus.1 = getelementptr i32, ptr %A.plus.1, i64 %iv
+ store i32 %add, ptr %gep.A.plus.1, align 4
+ %iv.next = add nsw i64 %iv, -1
+ %cmp.not = icmp eq i64 %iv, 0
+ br i1 %cmp.not, label %exit, label %loop
-for.body:
- %indvars.iv = phi i64 [ 1022, %entry ], [ %indvars.iv.next, %for.body ]
- %arrayidx = getelementptr inbounds i32, ptr %A, i64 %indvars.iv
- %0 = load i32, ptr %arrayidx, align 4
- %add = add nsw i32 %0, 1
- %gep = getelementptr i32, ptr %invariant.gep, i64 %indvars.iv
- store i32 %add, ptr %gep, align 4
- %indvars.iv.next = add nsw i64 %indvars.iv, -1
- %cmp.not = icmp eq i64 %indvars.iv, 0
- br i1 %cmp.not, label %for.cond.cleanup, label %for.body
+exit:
+ ret void
}
+; FIXME: There's a forward dependency that prevents forwarding here.
+define void @neg_step_ForwardButPreventsForwarding(ptr nocapture %A, ptr noalias %B) {
+; CHECK-LABEL: 'neg_step_ForwardButPreventsForwarding'
+; CHECK-NEXT: loop:
+; CHECK-NEXT: Memory dependences are safe
+; CHECK-NEXT: Dependences:
+; CHECK-NEXT: Forward:
+; CHECK-NEXT: store i32 0, ptr %gep.A, align 4 ->
+; CHECK-NEXT: %l = load i32, ptr %gep.A.plus.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.plus.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, align 4
+ %gep.A.plus.1 = getelementptr i32, ptr %A.plus.1, i64 %iv
+ %l = load i32, ptr %gep.A.plus.1, align 4
+ store i32 %l, ptr %B
+ %iv.next = add nsw i64 %iv, -1
+ %cmp.not = icmp eq i64 %iv, 0
+ br i1 %cmp.not, label %exit, label %loop
+
+exit:
+ ret void
+}
More information about the llvm-commits
mailing list