Skip to content

Conversation

artagnon
Copy link
Contributor

The isSafeDependenceDistance routine is guarded by a HasSameSize check which can be removed, as the test demonstrates.

The isSafeDependenceDistance routine is guarded by a HasSameSize check
which can be removed, as the test demonstrates.
@artagnon artagnon requested review from fhahn and igogo-x86 September 29, 2025 17:35
@llvmbot llvmbot added the llvm:analysis Includes value tracking, cost tables and constant folding label Sep 29, 2025
@llvmbot
Copy link
Member

llvmbot commented Sep 29, 2025

@llvm/pr-subscribers-llvm-analysis

Author: Ramkumar Ramachandra (artagnon)

Changes

The isSafeDependenceDistance routine is guarded by a HasSameSize check which can be removed, as the test demonstrates.


Full diff: https://github.com/llvm/llvm-project/pull/161244.diff

1 Files Affected:

  • (modified) llvm/test/Analysis/LoopAccessAnalysis/depend_diff_types.ll (+41)
diff --git a/llvm/test/Analysis/LoopAccessAnalysis/depend_diff_types.ll b/llvm/test/Analysis/LoopAccessAnalysis/depend_diff_types.ll
index 023a8c056968f..27a85c7a46084 100644
--- a/llvm/test/Analysis/LoopAccessAnalysis/depend_diff_types.ll
+++ b/llvm/test/Analysis/LoopAccessAnalysis/depend_diff_types.ll
@@ -560,3 +560,44 @@ loop:
 exit:
   ret void
 }
+
+; TODO: Relax HasSameSize check in isSafeDependenceDistance.
+define void @different_type_sizes_safe_dep_dist(i16  %n, ptr %p) {
+; CHECK-LABEL: 'different_type_sizes_safe_dep_dist'
+; 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 i32 0, ptr %gep.iv, align 1 ->
+; CHECK-NEXT:            store i16 1, ptr %gep.off.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:
+  %n.pos = icmp sgt i16 %n, 0
+  br i1 %n.pos, label %ph, label %exit
+
+ph:
+  %gep.off = getelementptr i32, ptr %p, i16 %n
+  br label %loop
+
+loop:
+  %iv = phi i16 [ 0, %ph ], [ %iv.next, %loop ]
+  %gep.iv = getelementptr inbounds i32, ptr %p, i16 %iv
+  store i32 0, ptr %gep.iv, align 1
+  %gep.off.iv = getelementptr i32, ptr %gep.off, i16 %iv
+  store i16 1, ptr %gep.off.iv, align 1
+  %iv.next = add i16 %iv, 1
+  %exit.cond = icmp eq i16 %iv.next, %n
+  br i1 %exit.cond, label %exit, label %loop
+
+exit:
+  ret void
+}

Copy link
Contributor

@fhahn fhahn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM ,thanks

@artagnon artagnon merged commit 6e52e53 into llvm:main Oct 2, 2025
11 checks passed
@artagnon artagnon deleted the laa-samsz-safedepdist-test branch October 2, 2025 08:17
mahesh-attarde pushed a commit to mahesh-attarde/llvm-project that referenced this pull request Oct 3, 2025
The isSafeDependenceDistance routine is guarded by a HasSameSize check
which can be removed, as the test demonstrates.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

llvm:analysis Includes value tracking, cost tables and constant folding

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants